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 the Apipheny add-on for Google Sheets

To pull data from the Snapchat API to Google Sheets without writing any code, first install and open the Apipheny Google Sheets add-on.

Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests to the Snapchat API, connect to unlimited API data sources, save your API requests, schedule API requests to refresh the data in your spreadsheet, and more. Click here for more info about Apipheny. There’s a free trial included.

1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the next page: https://gsuite.google.com/marketplace/app/apipheny/966163326746

Install the Apipheny Google Sheets add-on in the G-Suite Marketplace
Install the Apipheny Google Sheets add-on in the G-Suite Marketplace

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons option in the top menu. In the add-ons menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets, like so:

Open the Apipheny add-on in your Google Sheet to make an API request to the Snapchat API
Open the Apipheny add-on in your Google Sheet to make an API request to the Snapchat API

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 console window, 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
Get your Snapchat API access token via console
Get your Snapchat API access token via console

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

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 URL into the Apipheny add-on

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>”. Do not include the brackets “<>” around 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, such as:

  • Save and schedule your Snapchat API request
  • Make a POST request to the Snapchat API (if available)
  • Use the custom =APIPHENY() function to call the Snapchat API directly inside a cell of your spreadsheet
  • Create an Snapchat API request based on the value of a cell, by referencing the cell inside your API URL with three curly braces eg. {{{Sheet1!A1}}}

If you want to get Snapchat data in Google Data Studio, just follow the same steps above, and then connect your Google Sheet to Google Data Studio.

Importing API into Google Sheets – Apipheny demo

Related articles:

Related Posts