# yt2txt Developer Documentation (full) > The complete yt2txt REST API documentation as one file, for AI assistants > and for any client that would rather read one document than crawl a site. > This is the content of https://yt2txt.com/developers.html in markdown. > > Short overview of the product: https://yt2txt.com/llms.txt > Machine-readable contract: https://yt2txt.com/openapi.json > Interactive explorer: https://yt2txt.com/docs yt2txt transcribes YouTube videos to text. It works on videos with no subtitles, by transcribing the audio directly. ## Base URL Every path below is relative to `https://yt2txt.com`. ## Authentication Every endpoint needs a credential, and there are two kinds. Send one of them on every request. ### Bearer token `POST /auth/login` answers with a JWT. Send it as `Authorization: Bearer `. This is the browser's credential, and the only one that can manage API keys. ```bash curl -X POST https://yt2txt.com/v1/transcribe \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}' ``` ### API key Create a key with `POST /keys`, which needs a bearer token, and send the key as `X-API-Key`. Keys start `yttr_`, and the full value is shown once, at creation; afterwards only the prefix is readable. API access is part of the Pro and Max plans, and an AI action run with an API key below Pro is refused with `PRO_REQUIRED`. ```bash curl -X POST https://yt2txt.com/v1/transcribe \ -H "X-API-Key: yttr_your_key" \ -H "Content-Type: application/json" \ -d '{"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}' ``` A request carrying neither header is answered 401 with the code `MISSING_TOKEN`. A request carrying a credential that cannot be used is answered 401 with `INVALID_TOKEN`. The two are kept apart on purpose: the first means attach a credential, the second means get a new one. ### Language Send `X-Language: es` to receive error messages in Spanish. English is the default. The transcript's own language is set by the `language` field of the transcribe request, not by this header. ## Rate limits Limits are per plan, and there are three of them: requests an hour, minutes a day, and minutes a month. | Plan | Requests/hour | Daily minutes | Monthly minutes | | --- | --- | --- | --- | | Free | 5 | 15 | 300 | | Starter | 30 | 100 | 5,000 | | Pro | 120 | 300 | 15,000 | | Max | 300 | 500 | Unlimited | - Too many requests in an hour is answered 429 with `RATE_LIMITED` and a `Retry-After` header saying how many seconds to wait. - Not enough of today's minutes left is answered 429 with `DAILY_LIMIT_EXCEEDED`. The daily counter resets at midnight UTC. - A video longer than the plan's whole daily allowance is answered 429 with `VIDEO_OVER_DAILY_LIMIT`, which says that waiting will not help: a shorter video or a larger plan will. - An account's first video may be up to 30 minutes long on any plan whose daily allowance is smaller, so on Free a first video of 16 to 30 minutes is accepted rather than answered `VIDEO_OVER_DAILY_LIMIT`. - Nothing left for the month and no credits is answered 402 with `QUOTA_EXCEEDED`. Purchased credit minutes do not expire at the end of the period, and are spent after the subscription allowance. `GET /v1/account` reports all three balances, so a client can ask what it has left before spending it. ## POST /v1/transcribe Submit a YouTube video for transcription. Synchronous by default: the request is held open until the transcript is ready, then answered 200 with the whole transcript. Send `"async": true` to be answered 202 straight away with a job id, and poll `GET /v1/jobs/{job_id}` for the result. Async is the right choice for anything but a short video. A video that cannot be transcribed is refused before a job is created, so nothing is charged for it: too long, a live stream still running, or spoken in a language on the refused list. ### Request body | Field | Type | Required | Description | | --- | --- | --- | --- | | `url` | string | yes | YouTube video URL. `youtube.com/watch?v=...`, `youtu.be/...` and `youtube.com/shorts/...` are all accepted | | `language` | string | no | ISO 639-1 code for the spoken language, such as `en` or `es`. Detected automatically when omitted | | `async` | boolean | no | If true, answer 202 with a job id instead of blocking. Default `false` | | `notify_by_email` | boolean | no | Async only. Email the account owner once, when the job finishes or fails. Default `false`, so an integration starting many jobs does not send many emails | ### Request example ```bash curl -X POST https://yt2txt.com/v1/transcribe \ -H "X-API-Key: yttr_your_key" \ -H "Content-Type: application/json" \ -d '{"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "async": true, "notify_by_email": false}' ``` ### Response 202 Async mode. `poll_url` is the job endpoint for this job, already built, so there is no need to assemble it. ```json { "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "status": "processing", "message": "Transcription started. Poll the job endpoint for results.", "poll_url": "/v1/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890", "email_on_finish": false } ``` `email_on_finish` is true only when the email was asked for, email is configured on the server, and the account has not turned these emails off. ### Response 200 Synchronous mode: the finished transcript. ```json { "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "status": "completed", "video": { "id": "dQw4w9WgXcQ", "title": "Example Video Title", "channel": "Example Channel", "duration_seconds": 212.0, "thumbnail_url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg" }, "transcription": { "text": "This is the cleaned transcript text...", "raw_text": "this is the raw transcript text...", "language": "en", "word_count": 350, "segments": [ {"start": 0.0, "end": 5.2, "text": "This is the first segment"} ] }, "usage": { "minutes_consumed": 3.53, "minutes_remaining": 56.47 } } ``` The `video` object carries `id`, `title`, `channel`, `duration_seconds` and `thumbnail_url`; every field but `id` can be null when the video reported nothing. The `transcription` object carries `text` (cleaned), `raw_text` (as transcribed), `language`, `word_count` and `segments`, where each segment has `start`, `end` and `text` in seconds. The `usage` object carries `minutes_consumed` by this request and `minutes_remaining` afterwards. ## GET /v1/jobs List your transcription jobs, newest first, paginated. ### Query parameters | Field | Type | Default | Description | | --- | --- | --- | --- | | `limit` | integer | 20 | Jobs per page, 1 to 100 | | `offset` | integer | 0 | Jobs to skip | ### Request example ```bash curl "https://yt2txt.com/v1/jobs?limit=10&offset=0" \ -H "X-API-Key: yttr_your_key" ``` ### Response 200 ```json { "jobs": [ { "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "youtube_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "video_title": "Example Video Title", "status": "completed", "duration_seconds": 212.0, "processing_method": "whisper", "cost_usd": 0.0042, "created_at": "2026-11-05T12:00:00Z" } ], "total": 1, "limit": 10, "offset": 0 } ``` `status` is one of `pending`, `processing`, `completed`, `failed` or `cancelled`. `processing_method` says how the transcript was obtained: `subtitle` when the video already had usable subtitles, `whisper` when the audio was transcribed. It is null until the job finishes. ## GET /v1/jobs/{job_id} Everything known about one job. This is the endpoint an async client polls until `status` is `completed` or `failed`. ### Request example ```bash curl https://yt2txt.com/v1/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \ -H "X-API-Key: yttr_your_key" ``` ### Response 200 ```json { "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "youtube_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "status": "processing", "created_at": "2026-11-05T12:00:00Z", "completed_at": null, "duration_seconds": 212.0, "processing_method": null, "estimate": { "elapsed_seconds": 31.4, "estimated_total_seconds": 90.0, "estimated_remaining_seconds": 58.6, "basis": "history", "overdue": false }, "video": null, "transcription": null, "usage": null, "action_results": null, "error_code": null, "error_message": null } ``` - `video`, `transcription` and `usage` fill in once the job completes, and have the same shape as in the synchronous transcribe response. - `estimate` is sent only while the job is still running. `basis` says where the prediction came from: `history` (the median of recent completed jobs), `default` (no history yet) or `unknown` (no prediction — the video's length is not known yet). `overdue` turns true once the job looks stuck rather than merely slow; it is the point at which cancelling is more sensible than waiting. It is deliberately later than the prediction, because a median is a figure half of healthy jobs cross. - `action_results` holds the result of each AI action already run on this job, keyed by action name. - `error_code` and `error_message` are filled in on a failed job. The codes are listed under Job failure codes below. ## POST /v1/jobs/{job_id}/cancel Stop a job that is still pending or processing, and refund its minutes. Cancelling a job that has already stopped by itself — cancelled already, or timed out — also succeeds, and settles the refund. A completed job cannot be cancelled: that is answered 400 with `CANNOT_CANCEL`. ### Request example ```bash curl -X POST https://yt2txt.com/v1/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890/cancel \ -H "X-API-Key: yttr_your_key" ``` ### Response 200 ```json { "success": true, "message": "Job cancelled successfully", "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "status": "cancelled" } ``` ## AI actions An AI action is post-processing run on a finished transcript. There are five. | Action | Description | | --- | --- | | `summarize` | A concise summary of the transcript | | `chapters` | Timestamped chapters | | `keywords` | The key topics and keywords | | `translate` | The transcript in another language. Needs `language` in the request body | | `quiz` | Quiz questions from the content | Each action costs credits, estimated and deducted before it runs and refunded if it fails. Over an API key the actions need the Pro or Max plan. ## POST /v1/jobs/{job_id}/actions/{action_name} Run one AI action on a completed job. `action_name` is one of the five actions above. The job has to be `completed` and have a transcript, or the request is answered 400 with `JOB_NOT_COMPLETED` or `NO_TRANSCRIPT`. ### Request body Optional, and only `translate` needs it. | Field | Type | Required | Description | | --- | --- | --- | --- | | `language` | string | for `translate` | Target language as an ISO 639-1 code, such as `es` or `fr`. Omitting it on `translate` is answered 400 with `LANGUAGE_REQUIRED` | ### Request example ```bash curl -X POST https://yt2txt.com/v1/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890/actions/summarize \ -H "X-API-Key: yttr_your_key" ``` And a translation: ```bash curl -X POST https://yt2txt.com/v1/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890/actions/translate \ -H "X-API-Key: yttr_your_key" \ -H "Content-Type: application/json" \ -d '{"language": "es"}' ``` ### Response 200 ```json { "action": "summarize", "result": "This video covers...", "language": null, "tokens_used": 1840, "cost_usd": 0.0031 } ``` ## GET /v1/account The balance of the account the credential belongs to: which plan it is on, how much of the period is left, how much of today is left, and what is in the credit balance. Ask this before spending, rather than discovering a limit from a refusal. The period and the daily counter are brought up to date first, so a client that has not called since last month is told this month's figures. ### Request example ```bash curl https://yt2txt.com/v1/account \ -H "X-API-Key: yttr_your_key" ``` ### Response 200 ```json { "plan": "pro", "minutes_remaining_this_period": "14250.00", "minutes_remaining_today": "287.50", "credits_balance": "120.00" } ``` The minute figures are decimal strings rather than numbers, so no precision is lost in JSON. `minutes_remaining_this_period` is null on an unlimited plan, which is not the same as zero: treat null as "no period limit", not as "nothing left". ## POST /auth/register Create an account. Answered 201. ### Request example ```bash curl -X POST https://yt2txt.com/auth/register \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "your_secure_password"}' ``` `password` is at least 8 characters. ### Response 201 ```json { "id": "c0ffee00-1234-5678-9abc-def012345678", "email": "user@example.com", "created_at": "2026-11-05T12:00:00Z", "is_email_verified": false } ``` When email is configured on the server, an account has to verify its address before transcribing; until then requests are answered 403 with `EMAIL_NOT_VERIFIED`. ## POST /auth/login Exchange email and password for a bearer token. ### Request example ```bash curl -X POST https://yt2txt.com/auth/login \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "your_secure_password"}' ``` ### Response 200 ```json { "access_token": "eyJhbGciOiJIUzI1NiIs...", "token_type": "bearer", "expires_in": 86400 } ``` `expires_in` is the token's lifetime in seconds, and is the server's setting rather than a constant: read it rather than assuming a number. ## POST /keys Create an API key. Needs a bearer token — an API key cannot mint another. Answered 201, and this is the only time the full key is returned. ### Request example ```bash curl -X POST https://yt2txt.com/keys \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{"name": "my-integration"}' ``` ### Response 201 ```json { "id": "b0b0b0b0-1111-2222-3333-444444444444", "key": "yttr_abcdef0123456789abcdef0123456789", "prefix": "yttr_abcdef", "name": "my-integration", "created_at": "2026-11-05T12:00:00Z" } ``` ## GET /keys List your API keys. Only the prefix is returned; the key itself is stored hashed and cannot be read back. ### Request example ```bash curl https://yt2txt.com/keys \ -H "Authorization: Bearer " ``` ### Response 200 ```json { "keys": [ { "id": "b0b0b0b0-1111-2222-3333-444444444444", "prefix": "yttr_abcdef", "name": "my-integration", "created_at": "2026-11-05T12:00:00Z", "last_used_at": "2026-11-05T13:45:00Z" } ] } ``` ## DELETE /keys/{key_id} Revoke an API key. This cannot be undone. An unknown key id is answered 404 with `KEY_NOT_FOUND`. ### Request example ```bash curl -X DELETE https://yt2txt.com/keys/b0b0b0b0-1111-2222-3333-444444444444 \ -H "Authorization: Bearer " ``` ### Response 200 ```json { "message": "API key revoked" } ``` ## Error format Every error from the API carries the same body: an `error` object, under `detail`, with a stable `code` and a human-readable `message`. Branch on `detail.error.code`, never on the message — the message is translated and may be reworded. ```json { "detail": { "error": { "code": "DAILY_LIMIT_EXCEEDED", "message": "Daily transcription limit reached. Resets at midnight UTC." } } } ``` The one exception is a request that fails validation, in its body, query string or path: FastAPI answers 422 with its own `detail` array naming the offending fields. ## HTTP status codes | Status | Meaning | | --- | --- | | 200 | Success | | 201 | Created — a new account or API key | | 202 | Accepted — an async transcription job was started | | 400 | The request, or the video, cannot be processed | | 401 | No credential, or one that cannot be used | | 402 | Out of minutes and credits — add credits or change plan | | 403 | The credential is valid but not allowed to do this | | 404 | No such job or key, for this account | | 422 | The request failed validation (body, query or path) | | 429 | Rate limit or daily minute limit | | 500 | Something failed on our side | | 502 | An upstream AI provider failed | ## Error codes The `code` inside the `error` object. These are stable; branch on them. | Code | Status | Meaning | | --- | --- | --- | | `MISSING_TOKEN` | 401 | No `Authorization` and no `X-API-Key` header was sent | | `INVALID_TOKEN` | 401 | A credential was sent and could not be used — expired, revoked or malformed | | `USER_BANNED` | 403 | The account is suspended | | `EMAIL_NOT_VERIFIED` | 403 | The account has not verified its email address | | `PRO_REQUIRED` | 403 | An AI action was run with an API key on a plan below Pro | | `QUOTA_EXCEEDED` | 402 | No subscription minutes and no credits left | | `INSUFFICIENT_CREDITS` | 402 | Not enough credits to pay for this AI action | | `DAILY_LIMIT_EXCEEDED` | 429 | Today's minutes are spent; they reset at midnight UTC | | `VIDEO_OVER_DAILY_LIMIT` | 429 | The video is longer than the plan's whole daily allowance, so waiting will not help | | `RATE_LIMITED` | 429 | Too many requests this hour. `Retry-After` says how long to wait | | `VIDEO_TOO_LONG` | 400 | The video is longer than we transcribe in one go | | `UNSUPPORTED_LANGUAGE` | 400 | The video's spoken language is not one we transcribe yet | | `LIVE_STREAM` | 400 | A live stream cannot be transcribed while it is running | | `INVALID_JOB_ID` | 400 | The job id in the path is not a valid identifier | | `INVALID_ACTION` | 400 | The action name is not one of the five | | `JOB_NOT_COMPLETED` | 400 | An AI action was asked for on a job that has not finished | | `NO_TRANSCRIPT` | 400 | The job completed with no transcript to act on | | `LANGUAGE_REQUIRED` | 400 | `translate` was asked for with no `language` in the body | | `CANNOT_CANCEL` | 400 | The job is not in a state that can be cancelled | | `JOB_NOT_FOUND` | 404 | No job with that id belongs to this account | | `KEY_NOT_FOUND` | 404 | No API key with that id belongs to this account | | `PROCESSING_FAILED` | 500 | A synchronous job failed with nothing more specific recorded | | `CANCEL_FAILED` | 500 | The cancellation was rolled back; the job is still running and can be cancelled again | | `AI_ACTION_FAILED` | 502 | The AI provider failed. The credits are refunded | ## Job failure codes A failed job carries one of these in `error_code`, with a sentence in `error_message`. These describe a job, not a request, so they arrive through `GET /v1/jobs/{job_id}` — or, for a synchronous transcription, in the error body of the 500. | Code | Meaning | | --- | --- | | `TIMEOUT` | The job took too long and was stopped. Trying again often works | | `BOT_DETECTION` | YouTube asked us to prove we are not a robot. Waiting a few minutes usually works | | `VIDEO_UNAVAILABLE` | The video could not be opened — private, removed, or restricted in our region | | `INVALID_VIDEO` | The video's details could not be read. YouTube may still be processing it | | `VIDEO_TOO_LONG` | Longer than we transcribe in one go | | `UNSUPPORTED_LANGUAGE` | The spoken language is not one we transcribe yet | | `LIVE_STREAM` | A live stream, still running | | `QUOTA_EXCEEDED` | Not enough minutes left | | `DAILY_LIMIT_EXCEEDED` | Today's allowance is spent | | `VIDEO_OVER_DAILY_LIMIT` | Longer than the plan's whole daily allowance | | `TRANSCRIPTION_FAILED` | The transcription itself failed | | `PROCESSING_ERROR` | The job failed while being processed | | `INTERNAL_ERROR` | Something failed on our side | | `CANCELLED` | The job was cancelled, and its minutes refunded | | `UNKNOWN` | The job failed with nothing recorded about why | ## Recommended flow 1. `POST /auth/login` for a bearer token, then `POST /keys` once for an API key. Store the key; it is not shown again. 2. `GET /v1/account` to check the balance before a batch. 3. `POST /v1/transcribe` with `"async": true`. Keep the `job_id`. 4. Poll `GET /v1/jobs/{job_id}` until `status` is `completed` or `failed`. Use `estimate.estimated_remaining_seconds` to pace the polling, and `estimate.overdue` to decide when to give up. 5. Optionally `POST /v1/jobs/{job_id}/actions/{action_name}` for a summary, chapters, keywords, a quiz or a translation. 6. `POST /v1/jobs/{job_id}/cancel` to stop a job and get its minutes back. ## MCP There is a second way in, for an AI agent rather than for code somebody wrote: the Model Context Protocol server at https://yt2txt.com/mcp. Each of its tools is one call to a `/v1` route documented above, carrying the caller's API key, so an agent can do exactly what that key can do over REST, pays exactly what it would pay there, and needs the same Pro or Max plan. ### Connecting Streamable HTTP, stateless, with plain JSON responses rather than event streams. Two consequences worth knowing before writing a client: - **Every request is a POST.** `GET /mcp` is answered 405 with an `Allow: POST` header, because the only thing a GET could do here is open a stream nothing will ever write to. - **There is no session to keep.** Send `Accept: application/json, text/event-stream` and the usual `initialize` handshake; nothing is held between requests, so a restart on our side cannot invalidate your session. The key goes in the same header the REST API reads, and `Authorization: Bearer ` is accepted too, for clients that only offer that field. Either way the key is forwarded to `/v1` as an API key, so the plan gate, the rate limit and the billing are the ones documented above. No credential is ever read from a cookie. ### Client configuration The configuration file form, as an MCP client reads it. This is Claude Code's `.mcp.json`; most clients take the same three fields under a different file name. ```json { "mcpServers": { "yt2txt": { "type": "http", "url": "https://yt2txt.com/mcp", "headers": { "X-API-Key": "yttr_your_key" } } } } ``` Or in one command: ```bash claude mcp add --transport http yt2txt https://yt2txt.com/mcp \ --header "X-API-Key: yttr_your_key" ``` ### Tools | Tool | Arguments | What it does | | --- | --- | --- | | `transcribe` | `url`, optional `language` | Start transcribing a YouTube video and return its `job_id`. Returns immediately; the video's minutes are charged when the job starts work. | | `get_job` | `id` | Report a job's status, its video title and duration, and the delivery estimate. | | `get_transcript` | `id`, optional `format` and `offset` | Read a completed job's transcript, at most 50,000 characters per call. `format` is `text` or `segments`. | | `run_action` | `id`, `action`, optional `target_language` | Run an AI action on a completed transcript. Refused below Pro with `PRO_REQUIRED`. | | `get_balance` | none | The plan and the minutes and credits left, as `GET /v1/account` reports them. | `get_transcript` pages: `next_offset` is the offset of the first character it did not return, or null once the end has been reached. Calling again with it continues exactly where the last call stopped, with nothing skipped and nothing repeated. ### Errors A refused call comes back as an MCP tool error carrying one line, chosen from the API's error code: what happened, and what would change the answer. The API's own message is never passed through - it is written for a browser, in the request's language, and sometimes carries detail that is not the model's business. A request with no credential reaches `/v1` and is refused there, so it reads as `MISSING_TOKEN` rather than as a transport failure. ### The flow 1. `transcribe` with the video URL. Keep the `job_id`. 2. `get_job` until `status` is `completed` or `failed`. 3. `get_transcript`, then again with the previous `next_offset` until it is null. 4. Optionally `run_action` for a summary, chapters, keywords, a quiz or a translation. ## Contact - Support: https://github.com/AInvirion/support/issues/new/choose - Website: https://yt2txt.com - Parent company: https://ainvirion.com