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, we’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 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 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.

Open up a command prompt window (for Windows OS) or a terminal (for Mac OS) and 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 (APP SECRET, APP ID, and AUTH_CODE) with the values you got in the previous steps.

Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).

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.

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.

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://business-api.tiktok.com/open_api/v1.2/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://business-api.tiktok.com/open_api/v1.2/ base domain.

TikTok API root/base URL:

https://business-api.tiktok.com/open_api/v1.2/

All endpoints should be appended to this base URL.

Note: Check their documentation to confirm the latest version and update the version number in the URL if necessary.

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://business-api.tiktok.com/open_api/v1.2/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.

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

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

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.


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?