Hot answers tagged api-help
8
Do you mean to say how do I use this stuff?
You can find the documentation here or there's a Get Started section at the right of this page.
For example if you want to see a list of users you could send a web request to http://api.stackoverflow.com/1.0/users and parse then JSON response.
Now if you want to find out details about a particular user lets say ...
7
You are getting the GZipped stream of the response content. Use DownloadData instead of DownloadString and uncompress the stream before passing it to the JSON deserializer (or whatever you plan to use).
Alternatively, you can use the StackOverflow.Net library.
5
I believe that's a correct approach.
There's a way to optimize it saving one request but it's a little bit unsafe for this bug:
call /questions/{id};
If you get a result with a title parameter it's a question
If you get a result without a title parameter it's an answer, thus you should call /answers/{id} for the title
EDIT:
I've just realized that ...
4
First of all, I'm guessing the HTTP 400 errors are directly related to the fact that you are transmitting the access_token over standard HTTP instead of HTTPS. The API (if I remember correctly) throws an error if you try to pass an access token over standard HTTP and immediately invalidates the token.
You actually don't need to include an access_token to ...
4
See Kevin's answer here: http://stackapps.com/questions/408/what-is-the-errors-endpoint-used-for/411#411
RequestLimitExceeded = 4004
4
All responses from the API are compressed. You can specify the compression scheme (gzip or deflate) in the Accept-Encoding header. If you don't specify, one will be chosen for you.
We used to throw up an error when a non-compressed request was received, but a frustrating number of proxies don't pass Accept-Encoding through properly; so instead we silently ...
4
As I learned from George Edison in his comment, the server handles time in UTC format. Just replace your calls to DateTime.Now with DateTime.UtcNow or you can convert any DateTime to UTC format with the ToUniversalTime method. Just make sure not to call ToUniversalTime on the server's time, or it'll get messed up.
4
Note: I'm the author of stack.PHP.
You're likely running into rate limit issues. The API only allows you to make som many requests per second. Quoting from the question I linked to:
The API will cut you off if you make more than 30 requests over 5 seconds to any single endpoint.
Based on past experience, what you need to do is make sure that there is ...
4
You're talking about a number of things here, so let me see if I can explain them all:
The code powering the API is (presumably) written in C# and is closed-source.
The content provided by the API is licensed under a Creative Commons (w/ attribution) license.
The applications / libraries that use the API can be under any license you choose.
The logos, ...
3
Look to your right------> (where it says Get Started)
Api is a REST implementation and as such has no 'download'
You may access it right from your browser address bar or leverage one of the many client libraries that have been implemented.
http://stackapps.com/questions/288/list-of-libraries
If you are using JavaScript or C#, I would be remiss, as a ...
3
They have moved also these favicons (hard-coded in Swatch):
http://sstatic.net/sf/favicon.ico
http://sstatic.net/su/favicon.ico
http://sstatic.net/sa/favicon.ico
2
We're using number in the JSON sense of the word. number in that context does cover all the data types we're returning.
I suppose it could be tightened up a bit, though...
Descriptions of the types of number coming back are now part of the /help docs.
2
As Jeff mentioned in the comment of my other answer, this information would be best put elsewhere... so...
I have set up a MediaWiki installation for this here:
http://stackoverflow.quickmediasolutions.com/wiki/
2
Honestly, I don't think it is a big enough deal to warrant all of this attention. I don't see why posting code samples should be Community Wiki, but if a Moderator believes that they should be, then that's fine.
It was getting a bit annoying to see C# code samples posted all over the active question's page. I think a few is ok, but in my opinion, it was ...
2
Thanks for wrapping that up (+1) - a couple of recent topics are missing though, so here are
More Common Questions
Why is there no stable sort order for /sites?
See How to order /sites result in a user friendly way to use it in our apps. for comments, discussion and workarounds.
Why is the site creation date not available?
See Can we add a ...
2
The body of a post is optionally returned on all methods that return "posts."
/questions, /questions/{id}/answers, /users/{id}/questions, /answers/{id}, etc. all return the same "post object" I guess you'd say. The same code can be used to parse the post subset of fields, anyway. Kind of complicated, unfortunately.
However, since /search is so expensive ...
1
By definition all /search and /similar queries are made on one specific site. There is currently no way to search more than one site.
Example:
http://api.stackoverflow.com/1.1/search?intitle=linq
This example will search only Stack Overflow for the term linq.
1
/me/associated is the preferred way to turn an access_token into a list of users, it returns the collection of per-site user details that can be quickly fetched. It's basically the user's account tab.
If you need more details about a user on a give site, then turn around and hit /me (or /users/{ids}) on the sites you've discovered via /me/associated.
As ...
1
/questions take's a semi-colon delimited list of tags in the tagged parameter. If tagged is set, questions returned will have all the passed tags (ie. it's an AND operator).
https://api.stackexchange.com/docs/questions#order=desc&sort=votes&tagged=python&filter=default&site=stackoverflow&run=true
^ for example, that query returns all ...
1
For one use the current API version (2.1) instead of an old one (1.1 in your case).
Furthermore, when using JSONP you do not have to parse the result. The data object you get in your success method already is a JavaScript object you can work with.
$(function(){
$.ajax({
url: ...
1
The API expects JSONP requests to specify the callback as the jsonp parameter, not the callback that jQuery uses by default.
While really you should consider upgrading to API 2.1, which does expect callback (and allows CORS, for that matter), you can fix your code by putting in the jsonp parameter placeholder:
$.ajax({
...
1
You should be able to achieve this via the non optional "is_question" field of route /revisions/{id}:
"is_question": {
"description": "if the post is a question",
"values": "boolean",
"optional": false
},
See for example the results for:
your question, which returns true accordingly
my answer, which returns false ...
1
Suggested buffer size is just a suggestion, you've always been required to handle larger values should they be encountered. Exactly how you do so is an [app] specific detail.
In this case, the field backing about_me on the server has been resized since the API was released. It makes about_me a more acute case, but its always been possible to craft a ...
1
"Vectorized" does not imply anything about the order of its constituent components. The name comes from Vector Processors, a nicer name for the SIMD scheme.
The parameters are all treated identically, the documentation for each will be brought into sync on the next code push.
1
Hmmm.
Currently {tags} is a space delimited set of tag names. It really ought to be a semicolon delimited set.
So, the next code push will switch to the semicolon behavior. The documentation will be updated to reflect this.
This code has been deployed now.
1
If you call /revisions/{id} where {id} is a post id (question or answer) you'll get a list of revisions to that post. Each revision has a unique GUID that identifies it.
If you call /revisions/{id}/{guid} where {id} is a post id and {guid} is one of those revision GUIDs you'll get just that one revision.
{id} is technically vectorized in both cases, but ...
Only top voted, non community-wiki answers of a minimum length are eligible