How to import TikTok ads and marketing data into Google Sheets

TikTok is currently the world’s fastest growing social media platform.

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

  1. Install the Apipheny API add-on
  2. Create a TikTok API app and get a TikTok App ID
  3. Get your TikTok authorization URL
  4. Direct advertisers to access the Authorization URL to complete the Authorization
  5. Obtain a long-term TikTok API Access Token
  6. Choose a TikTok API URL endpoint
  7. Enter your TikTok API request into Apipheny
  8. Run the TikTok API request in your Google Sheet

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

To pull data from the TikTok Ads 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 TikTok API, as well as connect to other API data sources, save your API requests, schedule API requests, 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 add-on in order to connect the TikTok API to Google Sheets
Install the Apipheny add-on in order to connect the TikTok API to Google Sheets

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

Then click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.

Opening the Apipheny add-on in Google Sheets, you should see it in the "Add-ons" menu items after installing it
Opening the Apipheny add-on in Google Sheets, you should see it in the “Add-ons” menu items after installing it

Step 2.) Create a TikTok API app and obtain an App ID

Next, login to your TikTok developer account and click on “My Apps“:

Log in to your TikTok developer account and click "My Apps"
Log in to your TikTok developer account and click “My Apps”

Click on “Create App ID” to create a new app:

Click "Create API ID" after clicking on "My Apps"
Click “Create API ID” after clicking on “My Apps”

Fill out the required information and click “Confirm” to submit your application:

Enter the App ID details and then click "Confirm"
Enter the App ID details and then click “Confirm”

After submitting your application, the status of the app will be shown as “Pending verification” (this takes at most one business day):

The status of your TikTok API app will be "Pending verification" until verified
The status of your TikTok API app will be “Pending verification” until verified

Once approved, the status then changes to “Approved”.

Once approved, you’ll see your app’s ID, secret key, and authorization link in the “My Apps” dashboard:

Verified TikTok API app with the App ID and Secret
Verified TikTok API app with the App ID and Secret

You have now successfully a TikTok API app and obtained your App ID.

Copy and paste the values for your App ID and App Secret somewhere safe because you will need them in the next steps.

Step 3.) Get a TikTok authorization URL

In the My Apps dashboard, click on your app to access the app’s settings page.

Scroll down until you find the Authorized URL, then copy and paste it somewhere safe because you will need it in the next steps:

In your app's settings, copy your Authorized URL somewhere safe
In your app’s settings, copy your Authorized URL somewhere safe

Step 4.) Direct advertisers to access the Authorization URL to complete the Authorization

Once you’ve copied your authorization URL, you’ll need to send it to your TikTok advertising client, who will then need to access it in their browser. If you are the TikTok advertiser, you can copy and paste the authorization URL in your browser window.

When you visit the URL, you/the advertiser will be prompted to log in to your TikTok Ads account.

The browser will then redirect and display a dedicated authorization page, like so:

This is the page you see when you visit the TikTok authorization URL, you'll be prompted to log in to your TikTok ads account and give permissions to the TikTok API App your created in the previous step
This is the page you see when you visit the TikTok authorization URL, you’ll be prompted to log in to your TikTok ads account and give permissions to the TikTok API App your created in the previous step

When you/the advertiser clicks on Confirm, the page will then redirect to the callback address, where you’ll see auth_code and state as parameter values in the URL:

From the URL, copy and paste the auth_code value to a safe place because you will need it in the next steps.

Step 5.) Obtain a long-term Access Token

Next you need to get a long term access token for the TikTok APi.

In your console window, run the following command:

curl -H "Content-Type:application/json" -X POST -d "{\"secret\": \"<App Secret>\", \"app_id\": \"<App ID>\", \"auth_code\": \"<auth_code>\"}" https://ads.tiktok.com/open_api/oauth2/access_token_v2/

Don’t forget to replace the values between the brackets “<>” (App Secret, App Id, and auth_code) with the values you got in the previous steps. Do not include the brackets “<>” around the values when running your command.

Your access token will then be displayed in the response:

Getting a long term access token for the TikTok API by running a console command

Copy and paste your access token value to a safe location because you will need it in the next steps.

Step 6.) Choose a TikTok API endpoint

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

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

To browse a list of available TikTok API endpoints, first open the TikTok API documentation page: https://ads.tiktok.com/marketing_api/docs?id=100509

The menu on the left contains a list of categories for the TikTok API endpoints:

TikTok API documentation
TikTok API documentation

An example endpoint is the Getting creative materials endpoint from the Ads category, which returns an automated ad’s creative materials, including call-to-actions, texts, ad names, images, and/or videos.

The API URL for this endpoint is:

https://ads.tiktok.com/open_api/v1.1/ad/dynamic/get/

The documentation for each endpoint contains a paragraph describing the endpoint’s purpose, the HTTP method used (GET), the full URL, and a table describing the required/optional headers and parameters for the endpoint:

TikTok API endpoint documentation example
TikTok API endpoint documentation example

All API calls to TikTok Marketing API should be made to the https://ads.tiktok.com/open_api/v1.1/ base domain.

TikTok API root/base URL:

https://ads.tiktok.com/open_api/v1.1/

All endpoints should be appended to this base URL.

Step 7.) Enter your TikTok API request into the Apipheny add-on

Now, to get your TikTok 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 open, enter the following details into the Apipheny add-on:

Method: At the top of the Apipheny add-on, select the HTTP method (eg. GET or POST) required by your TikTok API endpoint. For this example, we are using the “GET” method.

API URL: In Step 6, we explained how you can find the TikTok API endpoint that you need. Now copy your complete TikTok 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 User Information endpoint that returns authorized user information granted to a developer App. The corresponding URL for this endpoint is:

https://ads.tiktok.com/open_api/v1.1/user/info/

If you’re following the same example as us, you can copy and paste this API URL into the Apipheny add-on.

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

Header
Key:
Access-Token
Value:
<your_token>

Replace <your_token> with the value of the token you generated previously, in Step 5. Do not include the brackets “<>” around the token.

Here’s what your TikTok API request should look like when entered into the Apipheny add-on:

TikTok API request entered in the Apipheny add-on
TikTok API request entered in the Apipheny add-on

Step 8.) Import your TikTok data in your Google Sheet

The last step is to click the Run button at the bottom of the Apipheny add-on and then your TikTok data will be imported into your Google Sheets, congratulations!

TikTok API connected with Google Sheets and TikTok data imported into Google Sheets using the Apipheny add-on
TikTok API connected with Google Sheets and TikTok data imported into Google Sheets using the Apipheny add-on

That’s it! That’s how you can connect the TikTok API with Google Sheets API using the Apipheny add-on.

After making a successful request to the TikTok API, try querying a different TiKTok API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:

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

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

Importing API data into Google Sheets – Apipheny demo

Related articles:

Related Posts