TikTok videos by hashtag
Beta GET /v1/tiktok/search/hashtag
GET /v1/tiktok/search/hashtag
Videos under a hashtag, with the hashtag (its video and view counts) as parent. TikTok may return duplicates.
- Cost: 1 credit
- Status: Beta. Built and tested against recorded responses; the shape may still gain fields.
- Cache: Results are kept up to 30 days; send
max_age_daysto reuse them for free. - Timeout: A request still running after about 25 seconds answers
202with a job to poll (Batch and jobs).
Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
hashtag | string | yes | Hashtag, with or without #. |
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:truefor a smaller response withoutnullfields andextra.raw:trueto also get the platform's original object asraw.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/hashtag" \
-H "x-api-key: $SOCIALSCRAPE_API_KEY" \
--data-urlencode "hashtag=booktok"Python
import os
import requests
params = {
"hashtag": "booktok",
}
res = requests.get(
"https://api.socialscrape.io/v1/tiktok/search/hashtag",
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/hashtag");
url.search = new URLSearchParams({
"hashtag": "booktok"
}).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 videos by hashtag",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
0,
0
],
"parameters": {
"method": "GET",
"url": "https://api.socialscrape.io/v1/tiktok/search/hashtag",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "hashtag",
"value": "booktok"
}
]
},
"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_49afe33dffbc45a5543ead4e",
"data": {
"object": "list",
"items": [
{
"object": "post",
"platform": "tiktok",
"id": "7223827494913215786",
"url": "https://www.tiktok.com/@jenna_bushhager/video/7223827494913215786",
"type": "video",
"author": {
"id": "6915876645917082629",
"handle": "jenna_bushhager",
"name": "Jenna Bush Hager",
"url": "https://www.tiktok.com/@jenna_bushhager",
"avatar_url": "https://p16-common-sign.tiktokcdn-us.com/tos-useast8-avt-0068-tx2/0707efff51851e19e5e88f36bd87a298~tplv-tiktokx-cropcenter:100:100.jpeg?dr=9640&refresh_token=6027098e&x-expires=1793498400&x-signature=fGha%2BdwsIq6v%2F%2FaMATUa3dFNyhE%3D&t=4...",
"verified": true
},
"title": null,
"text": "#WorldBookDay is 4/23, and I've joined the #BookTok community to share our favorite books with you all! Duet to share your favorite read! #PassTheBook",
"published_at": "2023-04-19T18:20:30Z",
"duration_seconds": 82.0,
"language": "en",
"hashtags": [
"worldbookday",
"booktok",
"passthebook"
],
"mentions": null,
"stats": {
"views": 39200,
"likes": 997,
"comments": 34,
"shares": 36,
"saves": 134,
"dislikes": null
},
"media": {
"thumbnail_url": "https://p16-common-sign.tiktokcdn-us.com/tos-useast5-p-0068-tx/ce0ee016ff8a483e8271ed4b4faebb3a~tplv-tiktokx-origin.image?dr=9636&x-expires=1793498400&x-signature=ebvVH4y0xpWGPFIusfLzWXLrS20%3D&t=4d5b0474&ps=13740610&shp=81f88b70&shcp=43f4a...",
"video_url": "https://v16-webapp-prime.us.tiktok.com/video/tos/useast5/tos-useast5-pve-0068-tx/oYkCgfIAkEiPzzfwArwjfy27IJH4AwHIAhgRyG/?a=1988&bti=ODszNWYuMDE6&&bt=1083&ft=4KJMyMzm8Zmo0aSSla4jVc1uQpWrKsd.&mime_type=video_mp4&rc=PDU7aGY6N2lmZ2g1Njc3Z0BpMzU...",
"audio_url": null,
"image_urls": null,
"width": 708,
"height": 1262
},
"song": {
"id": "7223827501163006766",
"title": "original sound",
"artist": "Jenna Bush Hager",
"url": "https://www.tiktok.com/music/original-sound-7223827501163006766"
},
"location": null,
"is_pinned": null,
"is_sponsored": false,
"extra": {
"ai_label_shown": true,
"author_followers": 223900,
"caption_languages": [
"eng-US"
],
"category_type": 120,
"comments_disabled": false,
"duet_enabled": true,
"is_private": false,
"music_is_original": true,
"reposts": 0,
"stitch_enabled": true,
"video_definition": "720p"
}
},
{
"object": "post",
"platform": "tiktok",
"id": "7211513837298781483",
"url": "https://www.tiktok.com/@oprahsbookclub/video/7211513837298781483",
"type": "video",
"author": {
"id": "7194562071920690219",
"handle": "oprahsbookclub",
"name": "Oprah’s Book Club",
"url": "https://www.tiktok.com/@oprahsbookclub",
"avatar_url": "https://p19-common-sign.tiktokcdn-us.com/tos-useast8-avt-0068-tx2/944d9f8fe6d976884002d17e0a651363~tplv-tiktokx-cropcenter:100:100.jpeg?dr=9640&refresh_token=1e6b8a80&x-expires=1793498400&x-signature=Y5s56j3okFuwP95g5aMGKvAseG8%3D&t=4d5b047...",
"verified": true
},
"title": null,
"text": "Drew Barrymore and Maria Shriver are now a part of Oprah’s Book Club! #booktok #hellobeautiful #fyp",
"published_at": "2023-03-17T13:57:03Z",
"duration_seconds": 22.0,
"language": "en",
"hashtags": [
"booktok",
"hellobeautiful",
"fyp"
],
"mentions": null,
"stats": {
"views": 556400,
"likes": 32400,
"comments": 490,
"shares": 542,
"saves": 1532,
"dislikes": null
},
"media": {
"thumbnail_url": "https://p19-common-sign.tiktokcdn-us.com/tos-useast5-p-0068-tx/5e637949d05948ca9dfce4bdf11cca0a_1679061424~tplv-tiktokx-dmt-logom:tos-useast5-i-0068-tx/4730ae3ab2e8400ea2407fcd4af350aa.image?dr=9634&x-expires=1793498400&x-signature=UlugW5%2...",
"video_url": "https://v16-webapp-prime.us.tiktok.com/video/tos/useast5/tos-useast5-ve-0068c001-tx/40ee8547970e4e68bca692a6504b5681/?a=1988&bti=ODszNWYuMDE6&&bt=2057&ft=4KJMyMzm8Zmo0aSSla4jVc1uQpWrKsd.&mime_type=video_mp4&rc=NjNmPDlmZWVlPDk8aWc3OUBpM3FwOm...",
"audio_url": null,
"image_urls": null,
"width": 720,
"height": 1280
},
"song": {
"id": "7211513809272507182",
"title": "original sound",
"artist": "Oprah’s Book Club",
"url": "https://www.tiktok.com/music/original-sound-7211513809272507182"
},
"location": null,
"is_pinned": null,
"is_sponsored": false,
"extra": {
"ai_label_shown": true,
"author_followers": 156900,
"caption_languages": [
"eng-US"
],
"category_type": 101,
"comments_disabled": false,
"duet_enabled": true,
"is_private": false,
"music_is_original": true,
"reposts": 0,
"stitch_enabled": true,
"video_definition": "720p"
}
}
],
"cursor": null,
"has_more": false,
"parent": {
"object": "collection",
"platform": "tiktok",
"id": "1622962893630470",
"url": "https://www.tiktok.com/tag/BookTok",
"kind": "topic",
"title": "#BookTok",
"description": "Calling all book creators! Share your favorite reads, recommendations, reviews, reactions, reading journeys, book hauls, literary insights, or creative takes inspired by any book you love. Whether you’re into fiction, nonfiction, classics,...",
"owner": null,
"item_count": 88646803,
"cover_url": null,
"updated_at": null,
"extra": {
"is_commerce": false,
"view_count": 562657233676
}
}
},
"cursor": null,
"has_more": false
}Response#
A list of Post 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.
| Code | HTTP | Retry | Meaning |
|---|---|---|---|
invalid_params | 400 | no | A parameter is missing, unknown or has the wrong type. |
not_found | 404 | no | The 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.
Example error:
{
"ok": false,
"error": {
"code": "not_found",
"message": "The platform says this profile, post or item does not exist.",
"retryable": false
},
"credits_charged": 0,
"request_id": "req_be33703c83b0cb728faadf0a"
}Related endpoints#
- TikTok profile (
GET /v1/tiktok/profile) - TikTok profile videos (
GET /v1/tiktok/profile/videos) - TikTok collection videos (
GET /v1/tiktok/collection/videos) - TikTok video details (
GET /v1/tiktok/video) - TikTok video transcript (
GET /v1/tiktok/video/transcript) - TikTok video comments (
GET /v1/tiktok/video/comments) - TikTok comment replies (
GET /v1/tiktok/video/comment/replies) - TikTok user search (
GET /v1/tiktok/search/users)