Tag Info

Hot answers tagged

25

Protip: when working with any API that returns JSON, install the JSONView Firefox Extension. By default, Firefox wants to download the application/json content type. This is not very helpful. JSONView changes the behavior so that you view the JSON in the browser, and additionally get syntax hi-lighting and expand/collapse.


13

Regarding paged results: The API's handling of empty paged results seems inconsistent. Some methods return empty sets, some throw a 404. It is my opinion that an empty set should be returned for any result that is paged and a 404 should be returned when a specific, singular resource is not found (the number of these methods seems to be shrinking). Having ...


10

Another scenario to consider is testing. Granted tests shouldn't really be hitting the service that hard but I know for my library I have at least 50 integration test that when run all at once would it the /questions method with the same parameters many times in a minute. These requests are done anonymously (with no api key) so I am not sure if you treat ...


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.


7

I think we should provide a JSON-Schema style description instead of or in addition to the current ?help syntax. This would make it much easier to consume, and comply to at least somewhat of a proposed standard.


6

A very low friction introduction to the API can be had with SOAPI-EXPLORE. It is always in sync with the current API and provides a documented interface for querying each route. It is a single file JavaScript application and requires no installation and may be right-click/saved or view source/saved and run locally if desired.


5

The current version of the API is read only, meaning you can not have users login and post answers/comments/questions. Theres documentation on the API, which you can get by click on the API documentation and help just here on the right column >>>>


5

You can fetch live data for one. The data explorer uses data that is up to a month old.


4

You may not post data to the api but retrieving data in c# is quite simple. Create a project and get an api key. To get started, just make use your project's name, whatever it is and your profile url as the app's website. This information can be modified at any time in the future. Download the source code for Soapi.CS Either build or add a project ...


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

Obvious, but perhaps worth stating: An easy way for desktop apps to reduce API usage is to detect when the screensaver is active or the workstation is locked, and throttle or pause API calls. Use separate polling intervals for different types of data: you may need questions every minute, but can live with reputation updates every 5 minutes. Favor fewer API ...


3

Another good way to be conscientious to the API is think about timing. If your app has certain peaks hours, slow down on the calls after hours (If 75% of users are US, run at 1 call/min from 9-5, and 1 call/5 min the rest of the time) The same goes vice-versa. If your application isn't completely reliant on up-to-minute data during the day, slow down on the ...


3

You can get meta data about a site as well as about all sites and users within the Stack Exchange sites network, see e.g. the following routes: Api Routes /stats Gets various system statistics. StackAuth Routes /sites Returns a list of all the sites in the StackExchange network /users/{id}/associated Gets all the associated user accounts across ...


2

"I have established that I need to use this url: https://api.stackexchange.com/2.1/users/1272330?order=desc&sort=reputation&site=stackoverflow ..." That is the correct path to use, but the order and sort query string parameters are unnecessary since you will always be receiving only one item in the response. "I have a knowledge of PHP, HTML, ...


1

Another very useful tool when working with APIs is the Chrome app "Postman - REST Client". You can even make POST requests, save the requests you make and organize them into collections. Check it out here!


1

Chrome users, check out the Chrome extension JSONView for Chrome. It's an unofficial port of JSONView for Firefox.


1

Another feature only available is the /user timed_penalty_date which is the time when a user leaves the penalty box.


1

Issues: The revisions routes' date keys diverge from the established naming convention. e.g. all other routes use todate and fromdate whereas the revisions use toDate and fromDate. Are keys case sensitive? If so, could this be addressed? I am building a wrapper and this single exception gives me a rash. for badges/name, name seems to be vestigal. ...



Only top voted, non community-wiki answers of a minimum length are eligible