---
title: "Media"
description: "Download a TikTok post's file, base64-encoded: a video's MP4, or one picture of a photo post."
---

```http
GET | POST /v1/tiktok/media
```

Send parameters as a query string with `GET`, or as a JSON body with `POST`. Both are equivalent.

## What to Pass

| Pass | Reads | Notes |
|---|---|---|
| `post` | The video's MP4, or one picture of a photo post | `index` picks the picture: 1-based, default 1 |

Pass one source per call. Every identifier also takes the page URL.

## Parameters

| Parameter | Type | Required | Notes |
|---|---|---|---|
| `index` | integer 1–100 |  | Photo posts: which picture, 1-based (default 1). |
| `post` | string |  | The post whose file to download: numeric id or URL. A video gives its MP4, a photo post one picture. |

## Request

```bash tab="cURL"
curl "https://gateway.apinoa.com/v1/tiktok/media?post=7698770783367171359" \
  -H "x-api-key: $APINOA_API_KEY"
```

```js tab="JavaScript"
const params = new URLSearchParams({ post: "7698770783367171359" });
const res = await fetch(`https://gateway.apinoa.com/v1/tiktok/media?${params}`, {
  headers: { "x-api-key": process.env.APINOA_API_KEY },
});
const { success, data, error } = await res.json();
```

```python tab="Python"
import os

import requests

res = requests.get(
    "https://gateway.apinoa.com/v1/tiktok/media",
    params={"post": "7698770783367171359"},
    headers={"x-api-key": os.environ["APINOA_API_KEY"]},
)
body = res.json()
```

## Response

Returns a media file in `data`. A real response, shortened: arrays keep their first entries and long text is cut.

```json
{
  "success": true,
  "data": {
    "platform": "tiktok",
    "postId": "7698770783367171359",
    "contentType": "video/mp4",
    "bytes": 22592237,
    "encoding": "base64",
    "data": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAVYbbW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAD6AABnMkAAQAAAQAAAAAAAAAAAAAAAAEAAAA…"
  }
}
```

For a photo post, `index` picks the picture and the answer adds `index` and `count`, the number of pictures in the post. `?post=7681723633164717325&index=2` answers:

```json
{
  "success": true,
  "data": {
    "platform": "tiktok",
    "postId": "7681723633164717325",
    "contentType": "image/jpeg",
    "bytes": 198005,
    "encoding": "base64",
    "data": "/9j/4AAQSkZJRgABAQAASABIAAD/4QBMRXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAEOKADAAQAAAA…",
    "index": 2,
    "count": 2
  }
}
```

## Errors

| Status | Code | Meaning |
|---|---|---|
| 400 | `INVALID_PARAMS` | A parameter is missing, unknown or out of range. The message names it. |
| 401 | `UNAUTHORIZED` | The `x-api-key` header is missing, or the key is revoked or unknown. |
| 402 | `INSUFFICIENT_BALANCE` | The balance does not cover this call. Top up in the dashboard. |
| 404 | `NOT_FOUND` | The account, post or group does not exist, or is private, deleted or age-restricted. |
| 429 | `MARKETPLACE_SATURATED` | Too many concurrent calls. Retry after the `Retry-After` seconds. |
| 502 | `UPSTREAM_ERROR` | The platform answered with something unusable. Retry with backoff. |

Every code is listed in [Errors](/docs/errors). Failed calls are not billed.

## Pricing

**Price** $0.002 per call. [List price](https://apinoa.com/en/pricing); the rate steps down above 1,000 calls a day.

## Notes

- The response is `{postId, contentType, bytes, encoding: "base64", data}`, plus `index` and `count` for a photo post. Decode `data` to get the file: the MP4 of a video, or the picture (`contentType` says which, e.g. `image/jpeg`).
- An `index` past the last picture answers `400 INVALID_PARAMS` with the post's picture count. A video has one file, so any `index` above 1 is refused the same way.
- Files over 64 MB answer `400 VIDEO_TOO_LARGE`. A call costs 2 units.
