In my last post, I showed you how to integrate the Reddit API with Google Sheets.
Note: the Reddit Ads API is available only for whitelisted accounts. To be whitelisted to access the Reddit Ads API, contact your Reddit sales representative. If you don’t have a Reddit sales rep but want to request one, contact their sales team by clicking the “Advertising at Scale” button on this page.
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:
To create an “app” that’s able to access the Reddit Ads API, first go to https://www.reddit.com/prefs/apps/ and click the “are you a developer? create an app” button:
On the next page:
Then after filling in those fields, click the create app button:
You can use any valid link as the redirect URL, including https://apipheny.io/
Your app will then be created:
On the dashboard for your new app, you will see the app ID and secret. Copy these values to a safe location because you will need them in the upcoming steps.
Note: the “app ID” is the value under “personal use script” in the screenshot above.
Next, give your developer application access to your account by visiting this URL in your browser:
On that link, replace the various identifiers with the following values:
After filling in those details, click the “Allow” button:
You will now then be redirected to the redirect URL that you provided earlier. Two query parameters (
code) will be added in your browser’s address bar, as parameters of this redirect URL. The
code parameter is a single use login code that we will now use to acquire a refreshable access token:
Next, open up a command prompt window for Windows OS or a terminal for Mac OS and compose the following curl command:
curl -X POST https://www.reddit.com/api/v1/access_token \\ -H 'content-type: application/x-www-form-urlencoded' \\ -A 'CLIENT_NAME' \\ -u CLIENT_ID:APP_SECRET \\ -d 'grant_type=authorization_code&code=CODE&redirect_uri=REDIRECT_URL'
You’ll need to fill in a few parts:
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).
The response access_token may be used in order to access the ads API for up to one hour. The refresh_token may be used to get a new access token when that hour is up. Refreshing the access token can be done with the following command:
curl -X POST https://www.reddit.com/api/v1/access_token \\ -A 'CLIENT_NAME' \\ -u CLIENT_ID:APP_SECRET \\ -d 'grant_type=refresh_token&refresh_token=REFRESH_TOKEN'
CLIENT_NAME, CLIENT_ID and APP_SECRET are the same as described before. REFRESH_TOKEN should be replaced with the value of the refresh_token field from the previous command’s response.
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.
In this section, I’ll show you how to browse the Reddit Ads API documentation to find an API endpoint URL that retrieves the specific information you need from your Reddit Ads account. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 5.
First, open the Reddit Ads API documentation page: https://ads-api.reddit.com/docs/
The menu on the left contains general information about Reddit Ads and a list of grouped API endpoints:
An example endpoint group is Ad Groups. This endpoint group contains two endpoints: Get all groups belonging to an advertiser and Get an ad group by ID.
In this case, we will describe the Get an ad group by ID endpoint, that retrieves an ad group by its ID:
The documentation for this endpoint contains a short description of the endpoint’s purpose, the authorizations used by the endpoint, the accepted path parameters, and the responses it can return:
All API calls to the Reddit Ads API should be made using the https://ads-api.reddit.com/api/v2.0 base domain. All endpoints and parameters would be appended to this base domain.
Reddit Ads API base domain/root URL:
Okay, we’re in the home stretch. Now 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:
API URL: In Step 4, I explained how you can find the Reddit Ads API endpoint that you need. Now copy the complete API URL into the Apipheny add-on, where it says API URL Path (JSON / CSV), followed by any GET parameters required for your query.
For this example, we are using the Get an account by ID endpoint, that gets information about an account by its ID. The corresponding URL for this endpoint is:
The account_id parameter in this API URL is the account ID that is obtained by accessing the following link in your browser: https://www.reddit.com/user/your_username/about.json
Replace your_username with your Reddit username.
In the Headers of the Apipheny add-on section, add two rows, with the following keys and values:
Header 1 Key: Content-Type Value: application/json
Header 2 Key: Authorization Value: Bearer your_token
You can copy the first header exactly. In the second header, 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.
The last step is to click the Run button at the bottom of the Apipheny add-on and then your Reddit Ads data will be imported into your Google Sheet.
After making a successful request to the Reddit Ads API, try querying a different Reddit Ads API endpoint, or try using one of the more advanced features in the Apipheny add-on.
Make a GET request
Make a POST request
PUT, PATCH, & DELETE Requests
Save requests for later
Schedule requests for automatic updates
Reference cell values in requests
=APIPHENY custom function
Stack multiple URLs in a single request
Run all saved requests at once
Modify your request settings
Import & export saved API settings
Crypto API tutorials and more:
Alpha Vantage API
Constant Contact API
Facebook Graph API
Facebook Ads API
Google SERP API
Linkedin Ads API
Product Hunt API
Reddit Ads API
Riot Games API