Reputation: 555
I'm currently fetching top posts in JSON format with code like this:
https://www.reddit.com/r/sub/top.json?t=week
I would like to do similar with hot posts, but seems like it doesn't work, unless I'm missing something
Upvotes: 0
Views: 1109
Reputation: 1632
You can use the /hot
endpoint to get the hot posts for a subreddit. The /top
endpoint allows you to specify a time period for the top posts, but the /hot
endpoint does not have this option.
Here is an example URL that you can use to get the hot posts for a subreddit called sub
:
https://www.reddit.com/r/sub/hot.json
Keep in mind that the /hot
endpoint only returns the default set of hot posts for a subreddit, which is determined by Reddit's algorithm. If you want more control over the posts that are returned, you may want to use the /search
endpoint instead. You can use the q
query parameter to specify a search query, and the sort
query parameter to specify how the results should be sorted (e.g. relevance
, hot
, top
, etc.).
Here is an example URL that you can use to search for hot posts in a subreddit called sub:
https://www.reddit.com/r/sub/search.json?q=&sort=hot
Upvotes: 1