Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 18

A tip for developers working with the Stack Exchange API.

2 votes

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

Here is a similar function in PHP: function Pluralize($amount, $unit) { if($amount == 1) return "$amount $unit ago"; else return "$amount {$unit}s ago"; } function RelativeTi …
Nathan Osman's user avatar
  • 23.3k
0 votes

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

Looks good. I did a very similar thing for stack.PHP, but it wasn't as elagant. Is this code public domain? P.S. On SO, it would look something like this: 0 sec. ago - 59 sec. ago 1 min. ago - 59 …
Nathan Osman's user avatar
  • 23.3k
0 votes

How to format an url-friendly slug for question urls

Can't this easily be constructed by appending a '/' and the title from the question? In PHP: $question_url .= '/' . preg_replace('/[^\w_]/','',str_replace(' ','_'$question->title));
Nathan Osman's user avatar
  • 23.3k
2 votes

How to format reputation numbers similar to Stack Exchange sites

Good ole' PHP: // Any number larger than 1000 gets returned like '4.5k' function Numberify($num) { if($num > 1000) return (floor($num / 100) / 10) . 'k'; return $num } Do you like …
Nathan Osman's user avatar
  • 23.3k
0 votes

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

Okay, here is sort of what happens with StackMobile: The list of sites is retrieved and stored in an associative array with the name of the site as the key. A new list is created by enumerating over …
Nathan Osman's user avatar
  • 23.3k
4 votes
1 answer
115 views

How to retrieve notifications for a given user.

There seems to be a few of these "dev-tips" so I'll share a problem I have. To notify a user of comments directed to them, we use the users/{id}/mentioned method. However, notifying a user of answer …
4 votes
0 answers
218 views

Announcement: StackExchange API Development Wiki

RIP August 24, 2010 - April 26, 2013 Due to lack of interest and the increasing burden of maintenance, I have decided to close down this wiki. Most of the information that it contains is eithe …
Nathan Osman's user avatar
  • 23.3k