TikTok is a popular social media platform that allows users to create and share short videos. With its growing popularity, many businesses and researchers are looking for ways to extract valuable insights from TikTok data. One of the most useful types of data to extract is video transcripts.
In this guide, we'll walk through how to get TikTok video transcripts using an API called Scrape Creators. This API allows you to scrape TikTok videos and extract the transcript of the video.
In this guide we are going to be using Node.js
Setting Up Your Environment
Before we dive into the code, let's set up our development environment:
- Install Node.js: If you haven't already, download and install Node.js from nodejs.org.
-
We will be using axios to make requests to the Scrape Creators API.
Install it using npm:
npm install axios
-
Make sure type: module is set in your package.json file.
{ "type": "module" }
Getting an API Key
To get an API key, you need to sign up for a Scrape Creators account.
Once you have signed up, you can get your API key from the Scrape Creators dashboard.
Getting the Video Transcript
Now that we have our API key, we can start scraping TikTok videos.
We will be using the axios
library to make requests to
the Scrape Creators API.
Here is the code to get the transcript of a TikTok video:
const axios = require('axios');
import axios from 'axios';
const apiKey = 'YOUR_API_KEY';
const videoUrl = 'https://www.tiktok.com/@stoolpresidente/video/7457284028102806830';
const { data } = await axios.get(`https://api.scrapecreators.com/v1/tiktok/video?url=${videoUrl}&get_transcript=true`, {
headers: {
'X-API-KEY': apiKey
}
})
console.log(data);
Notice you also need the param get_transcript=true
to get
the transcript.
This will return a JSON object. The transcript will be in the
transcript
property.
You can also get the video description, hashtags, and other metadata using the same API.
And that's it!
To get even more data from TikTok, or other social media platforms, check out the Scrape Creators API.