# Extract Subtitles

> Get existing YouTube and Bilibili subtitle tracks with direct download URLs

Source: https://platform.snapany.com/docs/extract-subtitles

[`POST /openapi/v1/extract/subtitles`](https://platform.snapany.com/docs/api#POST/extract/subtitles) — 1 credit per call.

Returns video metadata and **existing subtitle tracks**, including manual and auto-generated tracks. YouTube supplies `srt`, `vtt`, `ttml`, `json3`, `srv1`, `srv2` and `srv3`. **Bilibili supplies native BCC `json`**. Convert it to SRT/VTT or other formats as needed.

Bilibili supports BV/av video links, a selected part (`?p=2`), individual episodes (`ep836876`) and `b23.tv` short links. It does not extract comments or create subtitles for videos without them. The international site `bilibili.tv` is not currently supported by this endpoint.

```bash
curl -X POST https://api.snapany.com/openapi/v1/extract/subtitles \
  -H "Authorization: Bearer sk_snapany_xxx" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://www.youtube.com/watch?v=jNQXAC9IVRw"}'
```

The response contains:

- **id / title / text / duration / published_at / thumbnail_url**: video metadata
- **subtitles**: one entry per track (not necessarily one per language) — `language_name` (display name; auto-generated tracks are labeled, e.g. `English (auto-generated)`), `language_tag` (BCP 47 style), and `urls` with a direct download link per format

Download the URL of the format you need — `srt`/`vtt` for players and editors, `json3` for programmatic processing with per-cue timestamps.

## Bilibili BCC JSON

Each track provides one download URL with `format: "json"`. The BCC `body` is an array of subtitle cues, each with `from` and `to` timestamps in seconds and a `content` text field.

Multiple tracks can share `language_tag`. Keep each track as a distinct entry, using its original index in addition to the tag. `language_name` marks automatic tracks with ` (auto-generated)`; it does not distinguish automatic translation from speech recognition.

A video with no subtitles fails with code `no_subtitles` (HTTP 404) and is **not charged** — catch that code and fall back to [Transcription](https://platform.snapany.com/docs/transcription).

Full schema and a real-shaped response example: [API Reference](https://platform.snapany.com/docs/api#POST/extract/subtitles).

## Subtitles vs. Transcription

- **This endpoint** returns the subtitles YouTube or Bilibili already has — 1 credit, but only for videos that have them.
- **[Transcription](https://platform.snapany.com/docs/transcription)** runs Whisper large-v3 on the audio — works on any video (including those without subtitles) and supports speaker diarization, at 4 credits per minute.

A common pipeline: try `/extract/subtitles` first; on a `no_subtitles` error, fall back to [`/transcriptions`](https://platform.snapany.com/docs/transcription).

## Billing

1 credit per successful call, deducted after the extraction succeeds. Failed calls (invalid URL, unsupported site, no subtitles) are never charged. See [Credits & Billing](https://platform.snapany.com/docs/credits).
