In this tutorial, I’ll show you how to connect the Reddit API to Google Sheets in 6 steps:
Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.
1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install
2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.
In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.
Tip: you can open a new Google Sheet by entering this URL in your browser:
This step is necessary to call the Reddit API. First make sure you’re logged in to your reddit account.
Then, to create a Reddit API App, first go to https://www.reddit.com/prefs/apps/ and click the “are you a developer? create an app” button:
Then complete the steps:
Once you have all the fields filled in, click the create app button:
You can use any valid link as the redirect URL, including https://apipheny.io/.
After you click “create app”, your app will be created:
On this dashboard page of your new app, you will find the app ID and secret. Copy and paste these values to a safe location because you’ll need them in the upcoming steps.
Note: the “app ID” is the value under “personal use script” in the screenshot above.
In your command prompt window for Windows OS or a terminal for Mac OS, write the command below to obtain your Reddit API token:
curl -A -X -d "grant_type=password&username=YOUR_USERNAME&password=YOUR_PASSWORD" --user "APP_ID:APP_SECRET" https://www.reddit.com/api/v1/access_token
You’ll need to fill in a few parts of the code with your own values:
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).
Executing this command will return your Reddit API access token in the response. Copy your access token and paste it somewhere safe as you will need it in the next steps.
Note: If the token/key that you generate has an expiration time, you will need to complete this same process again to get a new token when the old one expires.
Every API has an endpoint. The endpoint is the latter part of the API URL that tells the API what specific data you’re looking for.
In this section, I’ll show you how to browse the Reddit API documentation to find an API endpoint URL that retrieves the information you need from Reddit. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 5.
To browse the reddit API docs, first open the Reddit API documentation page by going to the following link: https://www.reddit.com/dev/api
The menu on the left of the page contains a list of methods/endpoints for the Reddit API:
An example method/endpoint is /api/v1/collections/subreddit_collections, used to fetch collections for a subreddit. This is the whole URL for that endpoint:
The documentation for this endpoint contains the endpoint’s HTTP method (GET) and path, a short description of the endpoint’s purpose, and the accepted parameters:
All API calls to Reddit should be made using the https://oauth.reddit.com/api/v1/ base domain. All endpoints and parameters would be appended to this endpoint.
Reddit API base domain/root URL: https://oauth.reddit.com/api/v1/
We’re in the final stretch. Go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import Tab open, enter these details into the add-on:
Method: At the top of the Apipheny add-on, select the HTTP method (GET or POST) required by your API endpoint. For this example, we are using the GET method.
API URL: In Step 4, we explained how you can find the Reddit API endpoint that you need. Now copy the complete URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.
For this example, we are using the team.info method, that gets information about the current team. The corresponding URL for this API is:
In the Headers section of Apipheny, add one row with the following key and value:
Headers Key: Authorization Value: Bearer your_token
your_token is the value of the token you obtained previously, in Step 3. There should be a literal space between Bearer and your_token.
Here’s what our Reddit API request looks like in Apipheny:
Finally, click the Run button at the bottom of the Apipheny add-on and then the data your requesting from Reddit will be pulled into your Google Sheet, like so:
After making a successful request to the Reddit API, try querying a different Reddit endpoint (method), or try using one of the more advanced features in the Apipheny add-on.
Schedule requests for automatic updates
Reference cell values in requests
Stack multiple URLs in a single request
Run all saved requests at once
Crypto API tutorials and more:
Sponsored by Zink Virtual Tip Jar & Rewording.io Paraphrasing Tool
Accept donations on Twitch | Accept donations on Discord | Accept donations on YouTube | Accept donations on Telegram | Accept donations on Twitter | Accept donations on TikTok | Accept donations on Instagram | Accept donations on LinkedIn | Accept donations on Facebook | Accept donations on your Website