Is there anyway to get access to stackoverflow's awesome tagging system? I would like to borrow Stack's awesome auto-suggest and tag mini-explanation boxes for my own site. Obviously, I can use the jQuery UI auto-suggest for tags but I would really like to also include the cool little tag descriptions as well. If not, can someone tell me where all these explanation/descriptions came from so that I can implement a similar system?
-
5The code is here: `view-source:http://stackoverflow.com/`. – Derek 朕會功夫 Jun 18 '12 at 04:34
-
1Yeah, but I don't want to hotlink or rip them off without permission. – Thomas Jun 18 '12 at 04:43
-
Then you should probably contact them directly rather than in a question. – sosborn Jun 18 '12 at 04:45
-
Well, it seemed something that would be interesting to lots of other folks, so I thought I would leave it open. Judging from the number of up-votes this got in such a short amount of time, it seems like it must be on other peoples' minds as well. – Thomas Jun 18 '12 at 04:49
-
2@Thomas - You might want to look at the `StackExchange` object. (in the console, type `window.StackExchange`) – Derek 朕會功夫 Jun 18 '12 at 04:52
-
wouldn't this be a more appropriate question for [meta](http://meta.stackoverflow.com/)? – philipvr Jun 18 '12 at 04:59
-
@philipvr: seems like a "proper" dev question - but that's just an imo – Oleg Jun 18 '12 at 05:06
-
Yeah, it seemed like a grey-area to me. But more people look at stack so thats why I went that way. – Thomas Jun 18 '12 at 05:06
-
@Thomas - See my answer, figured out how the api works. – Derek 朕會功夫 Jun 18 '12 at 05:42
-
2@philipvr: Just because it mentions Stack Overflow doesn't mean it goes to meta. – BoltClock Jun 18 '12 at 05:58
-
1+1 for caring about permissions even though others suggest not to. – Ingo Bürk Nov 30 '13 at 20:24
2 Answers
Line 308:
$.get("/filter/tags", {q: a,newstyle: !0}, "json").done(function(c) {
C["t_" + a] = c;
StackExchange.helpers.removeSpinner();
b(c)
})
This might help you out!
It turns out that,
the API url is this:
https://stackoverflow.com/filter/tags?q=STRING&newstyle=BOOLEAN
q
- Query text.newstyle
- Require new style or not. Result in new style will be returned in JSON with additional information such as synonyms and excerpt.
DEMO: http://jsfiddle.net/DerekL/bXXb7/ (with Cross Domain Requests jQuery plguin)
For example:
https://stackoverflow.com/filter/tags?q=htm
would give you:
"html|99829\nhtml5|16359\nxhtml|4143\nhtml-parsing|1461\nhtml-lists|1328\nhtml5-video|949"
where 99829
is the amount of questions. It took me 15 minutes looking at the source code to find out this api. -_-"
Putting in javascript
in new style gives you this: here
[{"Name":"javascript","Synonyms":"classic-javascript|javascript-execution","Count":223223,"Excerpt":"JavaScript is a dynamic language commonly used for scripting in web browsers. It is NOT the same as Java. Use this tag for questions regarding ECMAScript and its dialects/implementations (excluding ActionScript and JScript). If a framework or library, such as jQuery, is used, include that tag as well. Questions that don't include a framework/library tag, such as jQuery, implies that the question requires a pure JavaScript answer."},{"Name":"javascript-events","Synonyms":"javascript-event","Count":5707,"Excerpt":"Creating and handling JavaScript events inline in HTML or through a script."},{"Name":"facebook-javascript-sdk","Synonyms":"","Count":992,"Excerpt":"Facebook's JavaScript SDK provides a rich set of client-side functionality for accessing Facebook's server-side API calls. These include all of the features of the REST API, Graph API, and Dialogs."},{"Name":"javascript-library","Synonyms":"","Count":675,"Excerpt":"A JavaScript library is a library of pre-written JavaScript which allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies."},{"Name":"javascript-framework","Synonyms":"","Count":563,"Excerpt":"A JavaScript framework is a library of pre-written JavaScript which allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies."},{"Name":"unobtrusive-javascript","Synonyms":"","Count":340,"Excerpt":"Unobtrusive JavaScript is a general approach to the use of JavaScript in web pages."}]
What you can get from there:
- All tags start with
javascript
- Synonyms
- Tag counts
- Nice tag descriptions

- 1
- 1

- 92,235
- 44
- 185
- 247
-
I think so, I just need to try and implement it to see if there are any cross-server issues with calling it. Otherwise, if I can use it to build similar auto-suggest boxes with the same supplemental content - it will be just what I was looking for. – Thomas Jun 18 '12 at 06:31
-
It should be fine if you use PHP. By the way, may I have an upvote? :) – Derek 朕會功夫 Jun 18 '12 at 06:33
-
If you're looking for high-level logic, in a nutshell it's just a custom auto-complete that's blazing-fast.
Whenever you type a tag (i.e. a new word or one separated by a space from previous tags), an AJAX request would be made to the server with a JSON object which is then interpreted by the client-side script and presented in the usable layout.
Comparing the autocomplete JSON objects for letter "h" and word "html" should give you enough insight into how this particular implementation works (if prompted, these can be opened with any text editor).
On a somewhat unrelated note: the autocomplete responses have to be fast. Depending on the complexity of the data autocomplete is run against, you may find how IMDb magic search works intriguing.
Update:
Seeing your comment about accessing the content of the tag library, this may in fact be more of a meta question. I struggle to think of a scenario where using an API if any or just the tag library from an external resource would be beneficial to SO - however content here is provided under Creative Commons so you may be able to use it with proper attribution. This does not constitute legal advice :)
-
2I understand how the guts work. I guess I am really interested in the library of descriptions and tags they have. There are thousands and I have a hard time believing that they paid anyone to write and curiate those individually, so I want to figure out where I can get access to the same library. If they did originate with stack, I'd love to get an api or something to pull them into my own site. – Thomas Jun 18 '12 at 05:28
-
1@Thomas: Those snippets are from the [tag wikis](http://stackoverflow.com/tags/html/info) which are [managed by Stack Overflow users](http://stackoverflow.com/edit-tag-wiki/2). – Wesley Murch Jun 18 '12 at 05:34