How to import data from Snapchat into Google Sheets using the Snapchat API

In this tutorial, I’ll show you how to connect the Snapchat API to Google Sheets in 8 steps:

  1. Install the Apipheny Add-on
  2. Create a Snapchat Ad Account
  3. Create a Snapchat OAuth App
  4. Get a Snapchat authorization code
  5. Get a Snapchat access token and refresh access token
  6. Choose your Snapchat API endpoint
  7. Enter your Snapchat API request into Apipheny
  8. Run the Snapchat API request in your Google Sheet

Step 1.) Install and open the Apipheny add-on for Google Sheets

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.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Create a new Snapchat Ad Account

Next, log in to your Snapchat account: https://ads.snapchat.com/

Then, in the menu on the left, click the Ad Accounts option, then click the “+ New Ad Account” button:

Create a new ad account in your Snapchat business account
Create a new ad account in your Snapchat business account

Choose the advertiser details and then click the Account Details button:

Choose your advertiser details and then click "Account Details"
Choose your advertiser details and then click “Account Details”

In the Account Details section, choose a name for your account, a billing type, a billing center, an account type advertising organization, a currency, and a time zone.

Then click the Create Account button:

Enter your new add account details and then click "Create Account"
Enter your new add account details and then click “Create Account”

Your ad account has been created.

You can now choose your payment method and save it by clicking the Save Payment Method button:

Enter your payment details and click "Save Payment Method"
Enter your payment details and click “Save Payment Method”

Your new account will then be displayed in the Ad Accounts list:

Newly created Snapchat ad account
Newly created Snapchat ad account

Copy and paste your ad account ID somewhere safe because you’ll need it in the next steps.

Step 3.) Create a Snapchat OAuth App

Next, click the Business Details menu item in your Snapchat ads account.

Then click the +OAuth App button in the bottom right corner:

In your Snapchat account, choose "Business Details" and then click "OAuth App"
In your Snapchat account, choose “Business Details” and then click “OAuth App”

A popup will be shown, prompting you to check the Terms and Conditions checkbox. After you click to agree to the Snapchat API terms and conditions, click the Save button:

Click the checkbox to agree to the Snapchat API terms and conditions and then click "Save"
Click the checkbox to agree to the Snapchat API terms and conditions and then click “Save”

Next, complete the App Name and Snap Redirect URI fields, then click the Save button:

Enter your App Name and Snap Redirect URI then click Save
Enter your App Name and Snap Redirect URI then click Save

Your app will then be created.

Copy and paste your Client ID and Secret to a safe location because you will need them in the next steps.

Then click the Done button once you’ve saved your Client ID and Secret:

Copy your Client ID and Secret to a safe location
Copy your Client ID and Secret to a safe location

Step 4.) Get a Snapchat authorization code

To get your Snapchat authorization code, copy the following link, then go to your browser’s address bar, paste it, and press Enter:

https://accounts.snapchat.com/login/oauth2/authorize?client_id=your_client_id&redirect_uri=your_redirect_uri&response_type=code&scope=snapchat-marketing-api
  • Replace your_client_id with the client id value that you obtained in the previous step
  • Replace your_redirect_uri with any valid URI string (you can use https://www.apipheny.io/ as your redirect uri, for example)

Next, you will be asked for a list of required permissions and you will have to click the Continue button:

Press "Continue" once you see this screen
Press “Continue” once you see this screen

After you allow access to the app, your code will be displayed in the address bar, as a value for the code parameter of your API URL:

Your "code" will then be displayed in the address bar of your browser
Your “code” will then be displayed in the address bar of your browser

Copy and paste this code somewhere safe because you will need it in the next steps.

Step 5.) Get an access token and a refresh access token

In your command prompt window for Windows OS or a terminal for Mac OS, write the following command to obtain your Snapchat API access token:

curl -X POST -d "grant_type=authorization_code" -d "client_id=your_client_id" -d "client_secret=your_client_secret" -d "code=your_code" -d "redirect_uri=your_redirect_uri" https://accounts.snapchat.com/login/oauth2/access_token

You’ll need to replace a few values of the command with the appropriate values:

  • your_code is the code you obtained in the previous step, replace “your_code” with the code you got in step 4
  • your_client_secret and your_client_id are the two values you copied in Step 3, after creating your app
  • your_redirect_uri is the redirect URI from your app settings
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).
Get your Snapchat API access token via console
Get your Snapchat API access token via console
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.

Executing this command will return your Snapchat API access token and a Snapchat refresh access token in the response.

Copy and paste these two tokens somewhere safe, because you will need them in the next steps.

The access token will be used in API queries, whereas the refresh token will allow you to obtain a new access token when the current one expires.

If you want to obtain a new access token, just call the same command as above, but change the parameters:

  • Don’t use the code and the redirect_uri parameters
  • Set the grant_type parameter to the “refresh_token” value
  • Add a refresh_token parameter and populate it with the value of your refresh token

Step 6.) Choose your Snapchat API endpoint

In this section, I’ll show you how to browse the Snapchat API documentation to find an API endpoint URL that retrieves the specific information you need from your Snapchat account.

If you already know your API URL/endpoint, or you want to use the same example URL as us, just skip to Step 7.

To get your endpoint, first open the Snapchat API documentation page: https://developers.snapchat.com/api/docs/

The menu on the left contains an Introduction section and a list of available Snapchat API categories, each with it’s own endpoints:

Snapchat API documentation
Snapchat API documentation

If you click on an API, the page will scroll to that API’s section, which contains a list of associated endpoints for that API.

For example, if you click the “User” category, the page scrolls to the list of the available endpoints for the “User” API. In this case, there is only one endpoint: Get Authenticated User. This is the URL for that endpoint:

https://adsapi.snapchat.com/v1/me

Each endpoint’s documentation contains a short description of the endpoint’s purpose, the HTTP method used (eg. GET) and the URL for that specific endpoint, as well as a description of the available parameters for that endpoint:

Example of Snapchat API endpoint documentation
Example of Snapchat API endpoint documentation

All API calls to the Snapchat API should be made to this base URL:

https://adsapi.snapchat.com/v1/

All Snapchat API endpoints should be appended to this base URL.

Step 7.) Enter your Snapchat API request into Apipheny

Now, to get your Snapchat data in your Google Sheet, go back to your Google Sheet and make sure that you’ve installed the Apipheny add-on and you have it opened to the Import tab.

With the Import Tab, enter the following details into the Apipheny add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your Snapchat API endpoint. For this example, I am using the “GET” method.

API URL: In Step 6, I explained how you can find the Snapchat API endpoint that you need. Now copy your complete Snapchat API URL into the Apipheny add-on, in the field that says API URL Path (JSON / CSV), followed by any GET parameters required for your query (if applicable).

For this example, we are using the Get All Ads under an Ad Account endpoint from the Ads category, which retrieves all ads within a specified ad account. The corresponding URL for this endpoint is:

https://adsapi.snapchat.com/v1/adaccounts/ad_account_id/ads 

If you’re following the same example as me, copy and paste this Snapchat API URL into the Apipheny add-on, but replace ad_account_id with your actual account ID that you copied in step 2.

Headers: In the Headers section of the Apipheny add-on, add one row with the following key and value:

Header
Key:
Authorization
Value:
Bearer your_token

Just replace your_token with the value of the token you obtained previously, in Step 5. There should be a literal space between Bearer and your_token.

Here’s what your Snapchat API request should look like when entered into the Apipheny add-on, if you’re following the same example as me:

Snapchat API request entered into the Apipheny add-on in Google Sheets
Snapchat API request entered into the Apipheny add-on in Google Sheets

Step 8.) Run the Snapchat API Request in your Google Sheet

The last step to get Snapchat data in your Google Sheet is to click the Run button at the bottom of the Apipheny add-on. Your Snapchat data will then be imported into your Google Sheets, congratulations!

Snapchat API data imported into Google Sheets using Apipheny
Snapchat API data imported into Google Sheets using Apipheny

That’s it! That’s how you can connect the Snapchat API to Google Sheets using Apipheny.

After making a successful request to the Snapchat API in your Google Sheet, try querying a different Snapchat API endpoint, or try using one of the more advanced features in the Apipheny add-on.


API Tutorials



API Knowledge

What is an API?
What is an API URL?
What are parameters?
What is an endpoint?
What is an API key/token?
What is basic authentication?
What are headers?
What is a GET request?
What is a POST request?