BlogCore API

TikTok Video Download API: Get the MP4 From Any TikTok Link

Why TikTok downloads work on your laptop and fail on servers, the free route if you control the machine, and one API call for the MP4, audio or transcript.

On this page5 sections

If your app lets users paste a TikTok link and you need the actual video file, the first version usually works on your laptop and then falls over in production:

  • It breaks on the server. The same request that works from home comes back empty, blocked or asking for a login once it runs on AWS, GCP, Fly, a Vercel function or an agent sandbox. TikTok treats datacenter traffic very differently from a phone on a home connection.
  • The page keeps changing. Scraping the video URL out of the page or an unofficial endpoint works until TikTok changes it, and then every download fails at once.
  • Links come in several shapes. Users paste full /video/ links, short share links from the app, and links with tracking parameters. Each needs resolving before you reach the media.
  • Audio-only is a separate job. For transcription or sound reuse you want just the audio, and TikTok usually serves one file with both, so you have to extract it yourself.

The free route, if you control the machine

TikTok's official developer APIs let you embed and display videos and read some metadata, but they don't hand you the video file for an arbitrary public link. So people who self-host use an open-source command-line downloader on their own computer. For a handful of videos from your own machine, that's the right answer and it costs nothing.

What it costs you is upkeep: keeping the tool updated every time TikTok changes something, an extra step to pull the audio out, and a retry and error-handling layer around it. From servers and agent sandboxes it often stops working altogether, because those IPs are the first to be blocked.

One call with Importly

Importly takes the TikTok link your user pasted and gives you the video file, from servers and agent sandboxes where TikTok normally blocks you.

bash
curl https://api.importly.io/import \
  -H "Authorization: Bearer $IMPORTLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.tiktok.com/@<user>/video/<id>",
    "webhookUrl": "https://your.app/webhooks/import"
  }'

When the job finishes, the webhook (or GET /import/status?id=<jobId>) gives you a signed link to the MP4 plus its title, duration and thumbnail. The link lasts 7 days; set "store": true to have the file copied straight into your own S3, R2 or B2 bucket instead.

A few things worth knowing:

  • Portrait video gets the right quality. videoQuality is measured on the short side of the frame, so 720p on a TikTok means 720×1280, the full-width portrait video.
  • Audio only: set "includeVideo": false to get just the soundtrack. TikTok rarely serves a separate audio stream, so you're billed for the smallest video Importly downloads to get it, which still comes to cents.
  • Transcript: add "includeTranscript": true to get a timestamped transcript in the same job. If the video has no captions, add "transcriptProvider": "importly" for AI speech-to-text at $0.01 a minute.
  • Check before you pay: POST /metadata/basic returns the title and duration for $0.003, so you can reject a 40-minute live replay before downloading it.
  • Private, deleted or login-only videos fail fast with a clear code (VIDEO_PRIVATE, VIDEO_UNAVAILABLE, AUTH_REQUIRED), so you can tell the user instead of retrying. Failed imports aren't charged.

What it costs

Downloads are $0.002 per MB, with a $0.01 minimum per import. A 30-second TikTok at 720p is usually a few MB, so it costs about one or two cents. Set maxCostDollars on a request and Importly checks the price before downloading anything. New accounts get $3 of free credit, no card. See pricing for the full list.

Have your AI agent build it in

Connect https://mcp.importly.io/mcp to Claude Code, Cursor or another coding agent and ask it to add TikTok downloads to your app. It gets working code for your stack, writes the integration and tests real calls with your API key, and your backend uses the same key. The steps are in Have your agent build Importly into your app.

FAQ

Is there an official TikTok API for downloading videos?

Not for arbitrary public videos. TikTok's developer APIs cover login, embedding, posting and limited metadata, not handing you the file for any link a user pastes.

Why does my TikTok downloader work locally but fail on my server?

TikTok is much stricter with traffic from cloud and datacenter IPs than with home connections. Code that works on your laptop often gets blocked or empty responses once it's deployed. Importly works from servers and agent sandboxes.

Can I get just the audio from a TikTok?

Yes. Set includeVideo to false and you get the audio track only.

Can I get the caption, author and other details?

Yes. Every completed import includes the title, duration and thumbnail, and POST /metadata returns the full metadata for a link without downloading it.

Related: Video downloader API, Reddit video download API, Supported sites, Importly docs.

Keep reading

Put video and audio links to work in your app

One API for files, transcripts and metadata. Free to try, no card required.

Try free →