> ## Documentation Index
> Fetch the complete documentation index at: https://docs.twexapi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# API Overview

> TwexAPI REST reference — authentication, response format, pagination, errors, rate limits, and endpoint groups.

TwexAPI exposes a REST API at `https://api.twexapi.io` for X/Twitter reads, writes, search, followers, DMs, lists, communities, articles, and account utilities.

Use this page as the entry point before opening individual endpoint pages in the sidebar.

## Base URL

```txt theme={null}
https://api.twexapi.io
```

## Authentication

Send your API key on every request:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

Write actions (post, like, follow, DM send) also require a saved Twitter cookie or `auth_token` on the request. See [Authentication](/authentication) for examples across cURL, Python, JavaScript, and Java.

## Response format

Successful responses use a consistent envelope:

```json theme={null}
{
  "code": 200,
  "msg": "success",
  "data": {}
}
```

Errors return non-2xx HTTP status codes with a JSON body. See [Error Handling](/guides/error-handling) for status-by-status recovery guidance.

## Pagination

Many list and search endpoints return cursor fields such as `has_next_page`, `next_cursor`, or page tokens inside `data`. Pass the cursor from the previous response unchanged on the next request. Preserve cursors outside chat or workflow memory when jobs must resume after failures.

## Check balance

Inspect remaining credits before large exports:

```bash theme={null}
curl --request GET \
  --url 'https://api.twexapi.io/balance' \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

Open [Get Balance](/api-reference/balance-endpoints/get-balance) for the full schema.

## Endpoint groups

Browse generated pages under **Endpoints** in the sidebar, or jump to common groups:

| Group                                                                                    | Typical jobs                                                                                                             |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| [Search](/api-reference/search-endpoints/advanced-twitter-search)                        | Keyword search, hashtags, cashtags. Build `searchTerms` with [Advance Search TwitterXAPI](https://x-advanced-search.cc). |
| [Users](/api-reference/user-endpoints/get-twitter-user-about-by-screen-name)             | Profile lookup, batch user reads                                                                                         |
| [Followers & Following](/api-reference/followers-&-following-endpoints/get-followers-v3) | Follower and following exports                                                                                           |
| [Tweet Actions](/api-reference/tweet-actions-endpoints/create-a-tweet-or-reply)          | Post, reply, like, retweet, bookmark                                                                                     |
| [Trending](/api-reference/trending-endpoints/get-global-trending-tweets)                 | Global trending topics and tweets                                                                                        |
| [DM](/api-reference/dm-endpoints/send-dm)                                                | DM status, send, and history                                                                                             |
| [Balance](/api-reference/balance-endpoints/get-balance)                                  | Credit balance                                                                                                           |

## Agent and SDK paths

| Integration                           | When to use                                                                           |
| ------------------------------------- | ------------------------------------------------------------------------------------- |
| [MCP Server](/mcp/overview)           | AI agents that should discover routes with `explore` before calling `twexapi_request` |
| [SDKs](/sdks)                         | Typed clients with retries and pagination helpers                                     |
| [CLI](/sdks/cli)                      | Terminal scripts and JSON output                                                      |
| [Framework Guides](/guides/langchain) | LangChain, CrewAI, n8n, Prefect, and other agent hosts                                |

## Operational guides

* [Error Handling](/guides/error-handling) — HTTP status recovery, MCP errors, and write retries
* [Rate Limits](/guides/rate-limits) — throughput guidance and `429` backoff
* [Write Actions](/guides/write-actions) — cookie / `auth_token`, duplicate checks, and `403` credits
* [Authentication](/authentication) — API keys, Bearer headers, and write credentials

## What TwexAPI does not expose today

TwexAPI does not ship native **account monitors**, **event webhooks**, or **async extraction jobs** as first-class API products. Use scheduled REST calls (Prefect, n8n, cron) or no-code platform webhooks to receive agent handoffs, then continue with direct API requests.
