# API Docs: Twitter Data, REST, MCP, CLI

API Docs for TwitterViewer AI: authentication, convert, replies and credits endpoints, errors, rate limits, MCP tools and the command line.

Page: https://twitterviewer.ai/docs/api

A full reference for calling this service from code, an assistant or a terminal.

TwitterViewer AI is an independent service. It is not X's official API and is not affiliated with X Corp. It reads public posts only: it cannot post, like, follow, send messages or read private accounts.

## Overview

Base URL https://twitterviewer.ai. Endpoints live under /api/v1. All endpoints are read-only and billed in credits (1 credit = 1 post returned).

OpenAPI 3.1 specification: https://twitterviewer.ai/openapi.json

| Endpoint | Method | What it does |
| --- | --- | --- |
| /api/v1/convert | POST, GET | Renders any supported X link in the format you name, PDF included |
| /{handle}/status/{id} | GET | Domain swap form of convert: keep the post path and call this host |
| /api/v1/replies | GET | Answers left under one post |
| /api/v1/credits | GET | Current balance, never billed |
| /mcp | POST | MCP over Streamable HTTP, hosted here |

## Authentication

Create a key at https://twitterviewer.ai/account/api and send it as a Bearer token. The full key is shown once. Keys per account: Plus accounts hold up to 2, free ones none.

```
Authorization: Bearer tv_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

## Convert a link

POST or GET /api/v1/convert

| Name | Type | Description |
| --- | --- | --- |
| url | string, required | Address of a post or account on either X domain. This host works in its place. |
| scope | thread / post / conversation | `thread` (default) joins the writer's chain. `post` keeps the linked entry alone. `conversation` appends one page of answers. Account links ignore this and list new entries. |
| format | json / markdown / obsidian / text / pdf | `json` is the default. `obsidian` puts YAML frontmatter on top. `pdf` sends back a finished file. |
| stats | all / root / off | Which entries show engagement numbers: `all` (default), only the opening one with `root`, or none with `off`. |
| max | integer 1–200 | For account links, the number of recent entries wanted; 20 unless set. |
| replies | boolean | For account links, also list what the owner wrote to others. Off unless set. |
| reposts | boolean | For account links, also list what the owner shared. Off unless set. |
| paper | a4 / letter | Sheet size used by `format=pdf`; `a4` unless set. |

```bash
curl https://twitterviewer.ai/api/v1/convert \
  -H "Authorization: Bearer $TWITTERVIEWER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://x.com/username/status/1234567890123456789",
    "scope": "thread",
    "format": "markdown"
  }'
```

| Field | Type | Description |
| --- | --- | --- |
| kind | string | One of post, thread, conversation, profile. |
| title | string | Opening words of the first entry, at most 60 characters. Account results are titled "Posts by Name (@handle)". |
| sourceUrl | string | Where the material lives on X. |
| author | object | Writer details that X makes visible, such as name, handle, bio, audience size, badge and signup date. |
| markdown | string | Finished document, styled as Markdown or Obsidian. |
| text | string | Unstyled version of that document. |
| posts | array | Structured entries with id, wording, timestamp, attachments, counters and any quotation. |
| replies | array | Filled only when scope is conversation. |
| postsReturned | integer | Number of entries delivered, which equals the price in credits. |
| wordCount | integer | Length of the finished document in words. |
| credits | object | Amount taken (`charged`) and amount left (`remaining`). |

```json
{
  "kind": "thread",
  "title": "How we shipped the new release:",
  "sourceUrl": "https://x.com/username/status/1234567890123456789",
  "author": { "handle": "username", "name": "Example", "followers": 1204 },
  "postsReturned": 31,
  "wordCount": 2214,
  "markdown": "# How we shipped…\n\nThread by @username…",
  "text": "…",
  "posts": [ { "id": "1234567890123456789", "text": "…" }, … ],
  "replies": [],
  "credits": { "charged": 31, "remaining": 2969 }
}
```

With format markdown, obsidian or text and the header `Accept: text/markdown` the body is only the document (post count in the x-posts-returned header). format=pdf returns application/pdf (Plus).

## Swap the domain

Domain swap: GET /{handle}/status/{id} or /{handle} on twitterviewer.ai (replace x.com in the link) with "Authorization: Bearer <API key>" and an Accept header that does not include text/html returns Markdown; ?scope=post|thread|conversation, ?format=obsidian|text|json and ?max= work as in convert. Without a key the call returns 401 and nothing is fetched from X; browsers get the normal page.

## Read replies

GET /api/v1/replies

| Name | Type | Description |
| --- | --- | --- |
| url | string, required | Address of the post whose answers you want. |
| max | integer 1–100 | Upper limit on answers; 20 unless set. |

## Check your credits

GET /api/v1/credits (free): returns total, plan { remaining, granted, expiresAt } and purchased { remaining }.

## How credits are counted

- Price: each delivered entry takes 1 credit, and a quotation inside it takes another. Writer details come free.
- Answers are priced the same way, whether listed alone or attached to a conversation.
- Nothing is taken for an error, an empty result or a PDF that failed to render.
- An empty balance gets `402` on billable calls. Repeating a recent call within 10 minutes still hands back its earlier result.
- Short of credits on a reply call? The list is trimmed to what you can pay for.
- Other conversions are all or nothing: one that outprices your balance returns `402` and takes nothing. Account exports ask for at most as many entries as you can afford, yet quotations may still push them over.
- Credits expiring soonest go first, so plan allowances are used before the ones that last.
- Registration grants 50 lasting credits. Free accounts spend them on this website; Plus accounts may also spend leftovers through the API. Plus refills 3,000 monthly, and credit packs are not sold.
- Same account, same call, inside 10 minutes: the stored result returns at no cost. For conversions, link, scope, max, replies and reposts must match, and PDF is counted apart. For replies, post and max must match. A trimmed or preview result is fetched anew, and billed, once credits allow.
- Sending a twin while the original still runs makes it wait. Past a minute, expect `503` carrying `retryAfterSec`.
- Visitors to the website get 1 export a day at no charge. Programmatic access requires Plus and is always billed.

## Rate limits and plans

| Plan | Credits a month | Requests a minute, API keys, PDF |
| --- | --- | --- |
| Free | None monthly; 50 once, for the website | API, MCP and CLI closed |
| Plus | 3,000 | 30 a minute · 2 keys |

## Errors

Error body: { "error": { "code", "message", "retryAfterSec?", "details?" } }

| Code | Status | When |
| --- | --- | --- |
| INVALID_INPUT | 400 | Something in the request cannot be used: a bad value, a gap, or an address that is neither post nor account. |
| UNAUTHORIZED | 401 | Key absent, mistyped or removed. X is never contacted and your balance stays as it was. |
| LIMIT_REACHED | 402 | Check `details.reason`. `PLUS_REQUIRED` means no Plus plan on the account. `INSUFFICIENT_CREDITS` comes with `details.required` and `details.balance`. |
| PROTECTED | 403 | The owner locked the account, so its entries cannot be read. |
| NOT_FOUND | 404 | Nothing exists at that address, perhaps because it was removed. |
| SUSPENDED | 410 | X has suspended this account. |
| RATE_LIMITED | 429 | The per-minute quota is spent. Pause for `retryAfterSec` seconds, a value repeated in Retry-After. |
| UPSTREAM | 502 | Fetching from X broke down. The attempt is not billed, so try again shortly. |
| SERVICE_UNAVAILABLE | 503 | PDF rendering or another component is offline. With `details.reason` `IN_PROGRESS`, an identical call has not finished: wait `retryAfterSec`. No credits move. |

## MCP server

MCP server: https://twitterviewer.ai/mcp (Streamable HTTP, Plus accounts; OAuth sign-in in the browser, or send "Authorization: Bearer <API key>"; OAuth metadata at https://twitterviewer.ai/.well-known/oauth-protected-resource). Claude Code: claude mcp add --transport http twitterviewer https://twitterviewer.ai/mcp; Cursor: {"mcpServers":{"twitterviewer":{"url":"https://twitterviewer.ai/mcp"}}}; Codex: [mcp_servers.twitterviewer] url = "https://twitterviewer.ai/mcp". Read-only tools: convert_x_url, get_x_replies, get_credits. Setup for Claude Code, Claude, Cursor and Codex: https://twitterviewer.ai/twitterviewer-mcp-server

| Tool | Arguments | What it does |
| --- | --- | --- |
| convert_x_url | url, scope, format, stats, max | Accepts a link and answers in Markdown, Obsidian, text or JSON. |
| get_x_replies | url, max | Fetches answers to a single post. |
| get_credits | none | Reports what is left to spend. |

## Command-line tool

Command-line tool: `npx twitterviewer <link>` (options --scope, --format md|obsidian|json|text|pdf, --stats, -o file), `twitterviewer login`, `twitterviewer credits`; reads the TWITTERVIEWER_API_KEY environment variable and requires Plus. The CLI converts links only; replies are on REST and MCP.

| Argument | Type | Description |
| --- | --- | --- |
| <link> or @handle | string | What to read: a link, or a handle for that account's newest entries. |
| --scope | thread / post / conversation | Mirrors the REST value; `thread` unless set. |
| --format | md / obsidian / json / text / pdf | File style, `md` unless set. Pair `pdf` with `-o`. |
| --stats | all / root / off | Controls engagement numbers; `all` unless set. |
| --max | integer 1–200 | Account links: size of the list, 20 unless set. |
| --replies, --reposts | flags | Account links: widen the list to answers or shares. |
| --paper | a4 / letter | Sheet size for PDF output, `a4` unless set. |
| -o, --output | path | Saves to disk instead of printing. |

Exit codes: 0 success, 1 failure, 2 wrong arguments, 3 login, plan or balance problem.

## Agent Skill

Agent Skill: https://twitterviewer.ai/.well-known/agent-skills/twitterviewer/SKILL.md (index: https://twitterviewer.ai/.well-known/agent-skills/index.json) tells an agent what to do when it meets an X link.
