Search API Connector Documentation
Import Reddit Data to Google Sheets
In this guide, we’ll walk through how to pull data from the Reddit API directly into Google Sheets, using the API Connector add-on for Sheets.
We'll be accessing public data so we don't need any API keys or other authorization. Let's jump right in!
- Before You Begin
- Part 1: Pull Reddit API Data into Sheets
- Part 2: More Example Requests
- Part 3: Handle Pagination
- Part 4: API Documentation and Resources
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Pull Reddit API Data into Google Sheets
For this example request, we'll access top posts from a specific subreddit for the past year
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following. Substitute your own subreddit of interest where it says
- Request URL:
- (Optional) The Reddit API sends back dozens or even hundreds of columns by default, including details about the awards received, links to thumbnails of different sizes, and various other minor data points. To filter these out and speed up your request, let's add the following JMESPath expression. Just copy/paste this block into the Output options > JMESPath field:
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see a list of the top 10 posts from the subreddit populate your sheet.
Part 2: More Example API Requests
You can check the documentation for the full set of endpoints and parameters, but if you just want to check it out, try the following examples:
- Search a subreddit for a keyword (keep the same JMESPath shown above to avoid pulling in excessive columns)
- Search all subreddit titles for a keyword
- Get a list of popular subreddits
Part 3: Handle Pagination
Note that the Reddit limits the number of records returned in each request. By default, only 10 records will be returned unless you use the
limit parameter, like this:
The limit parameter has a maximum value of 100 per page, so if you still need to retrieve more records, you'll need to paginate through as described in their documentation.
With API Connector, you can handle this automatically through pagination handling, like this:
- API URL: enter your request URL, including limit=100
- Pagination: cursor
- Next token parameter: after
- Next token path: data.after
- Run until: choose when to stop fetching data
Part 4: API Documentation and Resources
- Official API documentation: https://www.reddit.com/dev/api/
- Generally you can access any of the endpoints marked "rss support" without further authorization. Endpoints returning private data about your account will require an OAuth connection.
- Pushshift.io is an alternative to the official Reddit API. It provides additional functionality like the ability to search by date. API Connector contains a direct integration with Pushshift, simply select Reddit from API Connector's application menu.