# SDKs

> Typed clients for TypeScript and Python.

Both clients are generated from the API's OpenAPI document, so they carry every endpoint, parameter and
response type, and they update with the API. They are thin: one HTTP call per method, no retries or state,
the same `credits_charged` and `balance_remaining` fields as the raw API.

## TypeScript [#typescript]

```bash
npm install xdataapi
```

```ts
import { xdataapi } from 'xdataapi';

const api = xdataapi({ apiKey: process.env.XDATAAPI_KEY! });

const { data: profile } = await api.getUser({ path: { handle: 'x' } });
console.log(profile?.data?.followers, profile?.credits_charged);

const { data: page } = await api.searchTweets({ query: { q: 'from:x since:2026-09-01', count: 20 } });
for (const t of page?.data ?? []) console.log(t.id, t.text);
```

Every call returns `{ data, error, response }`. Node 18+, Bun, Deno, browsers, edge runtimes.

## Python [#python]

```bash
pip install xdataapi
```

```python
from xdataapi import AuthenticatedClient
from xdataapi.api.users import get_user
from xdataapi.api.tweets import search_tweets

client = AuthenticatedClient(base_url="https://api.xdataapi.io", token=KEY, prefix="", auth_header_name="x-api-key")

profile = get_user.sync(client=client, handle="x")
print(profile.data.followers, profile.credits_charged)

page = search_tweets.sync(client=client, q="from:x since:2026-09-01", count=20)
for t in page.data:
    print(t.id, t.text)
```

Every operation has `sync`, `sync_detailed`, `asyncio` and `asyncio_detailed` forms.

## Methods [#methods]

| Method                                | Endpoint                             |
| ------------------------------------- | ------------------------------------ |
| `getMe` / `get_me`                    | `GET /v1/me`                         |
| `getUser` / `get_user`                | `GET /v1/users/{handle}`             |
| `getUsers` / `get_users`              | `POST /v1/users/batch`               |
| `getUserTweets` / `get_user_tweets`   | `GET /v1/users/{user}/tweets`        |
| `getFollowers` / `get_followers`      | `GET /v1/users/{user}/followers`     |
| `getFollowerIds` / `get_follower_ids` | `GET /v1/users/{user}/followers/ids` |
| `getFollowing` / `get_following`      | `GET /v1/users/{user}/following`     |
| `searchTweets` / `search_tweets`      | `GET /v1/tweets/search`              |
| `getTweet` / `get_tweet`              | `GET /v1/tweets/{id}`                |
| `getTweets` / `get_tweets`            | `POST /v1/tweets/batch`              |
| `getThread` / `get_thread`            | `GET /v1/tweets/{id}/thread`         |
| `getReplies` / `get_replies`          | `GET /v1/tweets/{id}/replies`        |
| `getQuotes` / `get_quotes`            | `GET /v1/tweets/{id}/quotes`         |
| `getRetweeters` / `get_retweeters`    | `GET /v1/tweets/{id}/retweeters`     |
| `listPacks`, `createCheckout`         | billing                              |

Other languages: the [OpenAPI document](https://api.xdataapi.io/openapi.yaml) works with any generator, and
the [MCP server](/docs/mcp) covers agents without code.
