# Export captions

`GET https://api.vidmoat.com/v1/projects/{id}/captions`

- Scope: `projects.read`
- Cost: Free

The project's captions as a subtitle file: SRT or WebVTT, one cue per caption clip in timeline seconds, UTF-8. Upload it beside the video, or hand it to a translator.

> **Note.** The same file as the editor's Download .srt / .vtt buttons. Lines are wrapped at 42 characters, 16 for Chinese. SRT is written with a UTF-8 byte order mark so Windows players read Chinese correctly.

### Path parameters

- `id` (string, required): The project id.

### Query parameters

- `format` (string, optional, default `srt`): `srt`, `vtt`, or `json` for `{ projectId, cues: [{ start, end, lines }] }`.

## Response

Returns `200` (application/x-subrip, text/vtt or application/json).

### Response fields

- `(body)` (text): The file, `application/x-subrip` or `text/vtt`, as an attachment named after the project. `X-Caption-Cues` says how many cues it holds. With `format=json`, a JSON object instead (see `format`).

## Errors

Besides the errors any request can get ([authentication](https://developer.vidmoat.com/developer/docs/authentication#when-a-request-is-refused), [rate limits](https://developer.vidmoat.com/developer/docs/rate-limits)):

| Status | Code | When |
| --- | --- | --- |
| 404 | [`not_found`](https://developer.vidmoat.com/developer/docs/errors#not_found) | No such project, or it is not yours. The two are indistinguishable on purpose. |
| 400 | [`invalid_request`](https://developer.vidmoat.com/developer/docs/errors#invalid_request) | `format` is not srt, vtt or json. |

## Request examples

```bash curl
curl "https://api.vidmoat.com/v1/projects/$ID/captions?format=srt" \
  -H "Authorization: Bearer $VIDMOAT_KEY" -o captions.srt
```

```js Node
const ID = 'YOUR_PROJECT_ID';

const res = await fetch(`https://api.vidmoat.com/v1/projects/${ID}/captions?format=srt`, {
  headers: {
    Authorization: `Bearer ${process.env.VIDMOAT_KEY}`,
  },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
await (await import('node:fs/promises')).writeFile('captions.srt', Buffer.from(await res.arrayBuffer()));
```

```python Python
import os
import requests

ID = "YOUR_PROJECT_ID"

res = requests.get(
    f"https://api.vidmoat.com/v1/projects/{ID}/captions?format=srt",
    headers={"Authorization": f"Bearer {os.environ['VIDMOAT_KEY']}"},
    timeout=60,
)
res.raise_for_status()
with open("captions.srt", "wb") as f:
    f.write(res.content)
```

## Example response

```json
1
00:00:01,000 --> 00:00:02,500
大家好，今天我们来说说

2
00:00:02,500 --> 00:00:04,000
Made for the long weekend
```

---

Source: https://developer.vidmoat.com/developer/docs/api/projects/export-captions
Previous: [Validate commands](https://developer.vidmoat.com/developer/docs/api/projects/validate-commands.md)
Next: [Get the storyboard](https://developer.vidmoat.com/developer/docs/api/projects/get-storyboard.md)
All documentation: https://developer.vidmoat.com/llms-full.txt
