For those who didn't know already... Reddit offers it's data for subreddits publically. You can access this data by simply adding .json to the end of the subreddit url like so https://www.reddit.com/r/all.json.
Let's grab this data using jQuery and display some lovely data. I've written a simple function that you can throw your variables at.
function getReddit(sub, order, limit) {
$.getJSON(`https://www.reddit.com/r/${sub}/${order}.json?limit=${limit}`, function(data) {
$.each(data.data.children, function(i, item) {
var title = item.data.title;
var url = item.data.url;
$('body').append(`${title} - ${url}<br>`)
});
});
}
And using it goes a little something like this
getReddit(subreddit, order, limit);
Here's an example...
getReddit('all', 'new', 100);
Thanks for reading. x