Reddit's API documentation: https://www.reddit.com/dev/api
Description of the API's return data: https://github.com/reddit/reddit/wiki/JSON
Terminology
Reddit's API is slightly inconsistent in its naming; "id" sometimes refers to a thing's short ID, and sometimes to its fullname (the combination of its prefix and id). To avoid confusion, this guide will always refer to things in the following way:
Term | Description | Example |
---|---|---|
fullname | A thing's complete ID with prefix. The type of thing can be determined by the first two characters ("t1" for comment, "t3" for post, etc). | t1_cvp5afk |
id | A thing's short ID without prefix. Seen in your address bar when viewing, for example, a post or comment. Useful for constructing URLs. | 3npkj4 |
Listings
Methods that return lists of things can accept several optional parameters:
Parameter | Type | Description |
---|---|---|
limit | integer | How many things to return. Default 25, maximum 100. If limit is present but false, this is interpreted as "no limit" and the maximum is returned. |
before | fullname | Return results that occur before fullname in the listing. |
after | fullname | Return results that occur after fullname in the listing. |
count | integer | Appears to be used by Reddit to number listings after the first page. Does not seem to have a use in the API. |
only | "links" or "comments" | Return only links or comments. |
show_all | boolean | Return items that would have been omitted, for example posts you have hidden, or were hidden because you are using the option to hide posts after you've upvoted/downvoted them. Default false. |
Note that 'before' and 'after' mean before and after in the listing, not necessarily in time. It's best to think of Reddit as a database where new lines are constantly inserted at the top, because that's basically what it is.
Types of Thing
t1 | Comment |
t2 | Account |
t3 | Link |
t4 | Message |
t5 | Subreddit |
t6 | Award |
t8 | PromoCampaign |