This was requested in 1 and declined because of a missing authentication method.
Now that authentication is in place, is there a way to retrieve the favorited tags of a user (myself)?
This was requested in 1 and declined because of a missing authentication method.
Now that authentication is in place, is there a way to retrieve the favorited tags of a user (myself)?
UPDATE: The feature appears to be present in the, so far, undocumented API version 2.3. See captncraig's answer on this page.
After all these years, it looks like this might never get implemented. However, it's not too hard to get the information via page scraping.
From a browser or scraper that is logged in as the user, fetch the site's question page. (EG: http://stackapps.com/questions
)
Parse the #interestingTags > a.post-tag
nodes.
For example, this javascript will work in the browser console while logged in to and browsing any Stack Exchange page:
var favTagNodes = $('<div><a class="post-tag">** Error loading favorite tags. **</a></div>')
.load ("/questions #interestingTags>a.post-tag", function (response, status, xhr) {
var favoriteTags = favTagNodes.find ("a.post-tag").map ( function () {
return this.textContent;
} )
.get ();
console.log ("favoriteTags: ", favoriteTags);
} );
It can be made into a bookmarklet, or userscript, or browser extension.
It even works cross-domain when using GM_xmlhttpRequest
and a full URL.
Be sure to cache the results for at least an hour to avoid excessive scrapes of the page and possible banning. See also: Etiquette of Screen-scraping Stack Overflow?.
Good news! The (yet undocumented) api version 2.3 has this feature.
https://api.stackexchange.com/2.3/users/{id}/tag-preferences?access_token=...&key=...&site=StackOverflow.com
will give you something like:
{
"items": [
{
"tag_preference_type": "favorite_tag",
"user_id": 9999999,
"tag_name": "git"
}, {
"tag_preference_type": "favorite_tag",
"user_id": 9999999,
"tag_name": "go"
}, {
"tag_preference_type": "ignored_tag",
"user_id": 9999999,
"tag_name": "java"
}
...
],
"has_more": false,
"quota_max": 10000,
"quota_remaining": 9997
}
api.stackexchange.com/2.3/users/me/tag-preferences
does not yet work.
Commented
May 4, 2017 at 21:20