Skip to main content

Questions tagged [dev-tip]

A tip for developers working with the Stack Exchange API.

Filter by
Sorted by
Tagged with
7 votes
0 answers

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 ...
13 votes
0 answers

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 ...
12 votes
1 answer

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 ...
9 votes
3 answers

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 ...
Steffen Opel's user avatar
  • 1,380
5 votes
2 answers

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 ...
4 votes
8 answers

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 // ...
3 votes
4 answers

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 [,meta....
9 votes
7 answers

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 + " years";...
6 votes
0 answers

How to get the count of a query efficiently

To get the count of a query without returning results, simply specify pagesize=0. { "total": 1161, "page": 1, "...
4 votes
0 answers

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 ...
Sky Sanders's user avatar
  • 12.1k
3 votes
3 answers

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 ...
systempuntoout's user avatar
3 votes
1 answer

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 ...
systempuntoout's user avatar