Docs menu

TikTok search suggestions

Beta GET /v1/tiktok/search/suggestions

GET /v1/tiktok/search/suggestions

The autocomplete suggestions TikTok shows while someone types in search.

  • Cost: 1 credit
  • Status: Beta. Built and tested against recorded responses; the shape may still gain fields.
  • Cache: Results are kept up to 1 day; send max_age_days to reuse them for free.
  • Timeout: A request still running after about 25 seconds answers 202 with a job to poll (Batch and jobs).

Parameters#

NameTypeRequiredDescription
querystringyesPartial or complete search text. Also accepted as keyword, q.

Every request also accepts:

  • cursor: the cursor from the previous page (Pagination).
  • region: two-letter country code for results that vary by country. Changing it restarts the cursor chain.
  • trim: true for a smaller response without null fields and extra.
  • raw: true to also get the platform's original object as raw.
  • max_age_days: accept a cached result up to this many days old, for 0 credits (Caching).

Example request#

Set your key in the environment first (see Authentication).

curl
curl -G "https://api.socialscrape.io/v1/tiktok/search/suggestions" \
  -H "x-api-key: $SOCIALSCRAPE_API_KEY" \
  --data-urlencode "query=dogs"
Python
import os
import requests

params = {
    "query": "dogs",
}
res = requests.get(
    "https://api.socialscrape.io/v1/tiktok/search/suggestions",
    headers={"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]},
    params=params,
)
body = res.json()

if body["ok"]:
    print(body["data"])
else:
    print(body["error"]["code"], body["error"]["message"])
TypeScript
const url = new URL("https://api.socialscrape.io/v1/tiktok/search/suggestions");
url.search = new URLSearchParams({
  "query": "dogs"
}).toString();
const res = await fetch(url, {
  headers: { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! },
});
const body = await res.json();

if (body.ok) {
  console.log(body.data);
} else {
  console.error(body.error.code, body.error.message);
}
n8n
{
  "nodes": [
    {
      "name": "SocialScrape TikTok search suggestions",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "method": "GET",
        "url": "https://api.socialscrape.io/v1/tiktok/search/suggestions",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "dogs"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $env.SOCIALSCRAPE_API_KEY }}"
            }
          ]
        }
      }
    }
  ],
  "connections": {}
}

Example response#

This is a sample from a recorded response, lists and long text are shortened. Status 200.

{
  "ok": true,
  "credits_charged": 1,
  "credits_remaining": 4999,
  "cached": false,
  "cached_at": null,
  "request_id": "req_892207eaf0d593d9a6f77607",
  "data": {
    "object": "list",
    "items": [
      {
        "object": "suggestion",
        "platform": "tiktok",
        "kind": "query",
        "text": "dogs hotel",
        "id": null,
        "handle": null,
        "url": null,
        "image_url": null,
        "verified": null,
        "extra": null
      },
      {
        "object": "suggestion",
        "platform": "tiktok",
        "kind": "query",
        "text": "dogs toys",
        "id": null,
        "handle": null,
        "url": null,
        "image_url": null,
        "verified": null,
        "extra": null
      }
    ],
    "cursor": null,
    "has_more": false,
    "parent": null
  },
  "cursor": null,
  "has_more": false
}

Response#

A list of Suggestion objects in data.items, with data.cursor and data.has_more.

See Data models for every field. The envelope around data is described in Responses.

Errors#

Failures are free: credits_charged is 0. Branch on error.code, never on the message.

CodeHTTPRetryMeaning
invalid_params400noA parameter is missing, unknown or has the wrong type.
not_found404noThe platform says this profile, post or item does not exist.

Every request can also fail with the account and platform errors listed on the Errors page.