A tip for developers working with the Stack Exchange API.

learn more… | top users | synonyms

5
votes
0answers
415 views

How to use min/max with sort

While some sort values make inference of the expected min/max values less than ambiguous, others do not. Pending formal documentation, I hope this can serve as an informal reference. Aggregated sort ...
9
votes
3answers
159 views

Should we adjust the format of the dev-tip questions early on?

Update: I've 'averaged' the few answers and comments and included the respective result below each question (all results are executed accordingly for some time already in most dev-tip posts). The ...
8
votes
0answers
8k views

How to call the API via JSONP in Plain Old JavaScript

This tips demonstrates how to call the API in JavaScript without the need of jQuery or other frameworks. In a lot of cases you will find that the JSONP implementations provided in various frameworks ...
3
votes
8answers
821 views

How to format reputation numbers similar to Stack Exchange sites

UPDATE For JavaScript, see CMS's implementation below. It is much more elegant than the one I provide in the body of this Q. // formats a number similar to the way stack exchange sites ...
4
votes
2answers
1k views

API compliant request throttle implementations

Balancing compliance with Request Throttling Limits with maximum allowable throughput in our applications and libraries with any reliability requires self-throttling. This post is meant to be a repo ...
8
votes
7answers
1k views

How to format time since xxx e.g. “4 minutes ago” similar to Stack Exchange sites

function timeSince(date) { var seconds = Math.floor((new Date() - date) / 1000); var interval = Math.floor(seconds / 31536000); if (interval > 1) { return interval + " ...
8
votes
1answer
256 views

How the /sites method is meant to be used

The /sites method is used to enumerate all sites in the network. If your [app] is meant to run against more than a single site (and many are) this method is how you should be discovering new sites in ...
3
votes
0answers
799 views

Dev-Tip: How to call the API in C# and Silverlight

This tip shows a simple and reliable way to create HttpWebRequest that are configured to properly query the api. With the exception of the AutomaticDecompression assignment, this code can be used in ...
2
votes
4answers
141 views

How to order /sites result in a user friendly way to use it in our apps.

Since ordering of /sites is not guaranteed, how do i effectively order sites in a user-friendly way? General requirements: Trilogy must stay on the top of the list ...
5
votes
0answers
138 views

How to get the count of a query efficiently

To get the count of a query without returning results, simply specify pagesize=0. http://api.stackoverflow.com/0.9/users?filter=mike&sort=name&pagesize=0 { "total": 1161, "page": 1, ...
3
votes
3answers
467 views

How to format an url-friendly slug for question urls

I would like to construct a slug starting from the question title. It would be useful to apps that want to show the original link to the question in a human readable way. On StackPrinter i have this ...
2
votes
1answer
113 views

How to check if a given question is changed

What is the fastest way to check if a question is changed using the API calls? For my purpose (a cache), a question is considered changed if: A new comment is added to the question or to any of its ...