-
Notifications
You must be signed in to change notification settings - Fork 157
"Info" API
In many applications, such as Socialite, it is valuable to look up information about a link on reddit. Currently, there are two good ways to do this using the JSON API:
Info call
Example: http://www.reddit.com/api/info.json?count=1&url=STORYURL
The API “info” call is an ideal way to look up reddit stories by URL. However, in some cases, looking up stories by URL alone presents problems:
1. URLs are not mapped to stories on a one-to-one basis. Since the same URL can be posted to many subreddits, when looking up stories by URL, it becomes necessary to constrain the search by subreddit, e.g.: http://www.reddit.com/r/subreddit/api/info.json?count=1&url=STORYURL
2. Reddit “self posts” do not seem to be accessible by URL. Looking up a self post with this method returns no results.
Comments page
http://www.reddit.com/comments/IDNUM/.json (or equivalently, http://www.reddit.com/info/IDNUM/.json)
To avoid the above problems, if the id of the story is known, then the comments page can be used to get the same info. Unfortunately, the JSON returned includes all of the comments. This can make the file unacceptably large:
1.2K http://www.reddit.com/api/info.json?url=http://voices.washingtonpost.com/the-trail/2008/09/08/obama_to_palin_dont_mock_the_c.html&count=1
116K http://www.reddit.com/comments/70ehq/obama_to_palindont_mock_the_constitution_dont/.json
Note: the related page can be used instead of comments for a smaller filesize, but it’s just a hack.
For quick UI updates, the comments JSON is way overkill and a load upon reddit servers.
Proposed solution
Add an id parameter to the “info” API call in http://code.reddit.com/browser/r2/r2/controllers/api.py#L95. If an id is present, the call should return a listing containing only the single story. Otherwise, the call should act as normal, using a URL id. If neither an id or URL are specified, the call should fail.
Pasted from <http://code.reddit.com/ticket/154#comment:2>
Changed 2 days ago by ketralnis ¶
• status changed from assigned to closed
• resolution set to fixed
You can now query for http://www.reddit.com/by_id/t3_96c10,t3_96dte/.json
Pasted from <http://code.reddit.com/ticket/154#comment:2>