Documentation Index
Fetch the complete documentation index at: https://mintlify.com/KevxxAlva/tiktok-bot-downloader/llms.txt
Use this file to discover all available pages before exploring further.
GET /api/proxy-download acts as a server-side relay between the browser and TikTok’s CDN. It fetches the media file on the server, buffers it entirely, and then sends it to the client with a Content-Disposition: attachment header — which causes the browser to save the file rather than open it. This endpoint is used for every file download in the TikTokSaver frontend, including videos, watermarked variants, audio tracks, and slideshow images.
Endpoint
Why a Proxy Is Needed
TikTok CDN URLs frequently reject direct browserfetch() or <a href> requests. Specifically:
- TikTok’s CDN checks the
Refererheader and may return403 Forbiddenif the request does not appear to originate from TikTok’s own pages. - Browsers cannot set arbitrary
User-AgentorRefererheaders on<a href>downloads due to CORS and security restrictions. - CDN links returned by TikWM often do not include proper
Content-Dispositionheaders, so browsers open them in a new tab rather than prompting a save dialog.
Content-Disposition header before forwarding the binary to the client.
Parameters
The media URL to proxy. This is typically the
url field from a DownloadOption object returned by GET /api/download, a result.music audio URL, or an individual image URL from result.images. The value must be URL-encoded.The desired filename for the downloaded file. Defaults to
tiktok_video.mp4 if omitted. All characters outside [a-zA-Z0-9._-] are replaced with _ to prevent HTTP header injection from special characters or emoji. The extension may be automatically corrected based on the upstream Content-Type (see Behavior below).Behavior
The endpoint performs the following steps on every request:-
First fetch attempt — sends a
GETrequest to the upstreamurlwith:User-Agent: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36Referer: https://www.tiktok.com/Range: bytes=0-
-
403 retry — if the upstream server returns
403 Forbidden, the request is immediately retried with the sameUser-Agentbut without theRefererheader. -
Buffer — the full response body is loaded into memory as an
ArrayBufferbefore any response headers are sent to the client. This ensuresContent-Lengthcan be set accurately. -
Smart extension correction — the final filename is adjusted based on the upstream
Content-Type:- If
Content-Typecontainsaudioand the filename ends in.mp4, the extension is changed to.mp3. - If
Content-Typecontainsimageand the filename ends in.mp4, the extension is changed to.jpeg.
- If
-
Response headers sent to the client:
Content-Disposition: attachment; filename="<finalFilename>"Content-Type: <upstream Content-Type>(falls back toapplication/octet-stream)Content-Length: <buffer byte length>
Success Response
HTTP 200 — binary file data with the following headers:| Header | Value |
|---|---|
Content-Disposition | attachment; filename="<finalFilename>" |
Content-Type | Mirrored from upstream (e.g. video/mp4, audio/mpeg, image/jpeg) |
Content-Length | Exact byte size of the buffered file |
Error Responses
Returned when the
url query parameter is missing.Returned when the upstream fetch fails (non-OK status after the optional 403 retry) or when an unexpected runtime error occurs.