> ## 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.

# CLI

> Use the TwexAPI CLI for tweet search, follower exports, DMs, X Articles, and terminal X API automation.

Use the CLI when you want deterministic terminal commands, JSON output, dry-run previews, and saved credential profiles for TwexAPI REST workflows without writing application code.

| CLI task       | Command                       | Save          |
| -------------- | ----------------------------- | ------------- |
| Search tweets  | `x-api-scraper search tweets` | cursor        |
| Read profile   | `x-api-scraper about`         | `screen_name` |
| List followers | `x-api-scraper followers`     | cursor        |

## Install

```bash theme={null}
npm install -g @twexapi-dev/x-api-scraper-cli
x-api-scraper --help
```

Requires Node.js 18 or newer.

Source: [twexapi-dev/x-api-scraper-cli](https://github.com/twexapi-dev/x-api-scraper-cli)

## Authenticate

Get your API key from the [TwexAPI dashboard](https://twexapi.io/dashboard).

```bash theme={null}
export X_API_SCRAPER_KEY="YOUR_API_KEY"

x-api-scraper auth apps add --name prod --api-key "YOUR_API_KEY"
x-api-scraper auth apps use prod
x-api-scraper --app prod about elonmusk
```

For write actions, save a profile with a Twitter cookie or `auth_token`:

```bash theme={null}
x-api-scraper auth profiles add --name founder --cookie "ct0=...; auth_token=..."
x-api-scraper auth profiles use founder
```

## Basic example

```bash theme={null}
# Lookup users
x-api-scraper --app prod users elonmusk sama

# Search tweets
x-api-scraper --app prod search tweets "founder" "ai" --sort Latest

# List followers (v3)
x-api-scraper --app prod followers elonmusk

# Global trending tweets
x-api-scraper --app prod trending tweets --country "United States" --topic "Sports" --count 50
```

## Workflow: post a tweet with dry-run

Preview write actions before sending:

```bash theme={null}
x-api-scraper --app prod --profile founder --dry-run tweet create --text "hello from cli"
x-api-scraper --app prod --profile founder tweet create --text "hello from cli"
x-api-scraper --app prod --profile founder tweet create --text "hello with image" --media-url "https://example.com/a.jpg"
```

Local file upload is not supported. Use a public `--media-url`.

## Workflow: send a DM

```bash theme={null}
x-api-scraper --app prod --profile founder --dry-run dm send elonmusk --text "hello from cli"
x-api-scraper --app prod --profile founder dm send elonmusk --text "hello from cli"
x-api-scraper --app prod --profile founder dm send elonmusk --text "see this" --media-url "https://example.com/a.jpg"
```

## Workflow: publish Markdown as an X Article

```bash theme={null}
x-api-scraper --app prod --profile founder --dry-run article publish-md ./article.md --title "Launch Notes"
x-api-scraper --app prod --profile founder article publish-md ./article.md --title "Launch Notes" --cover-image "https://example.com/cover.jpg" --visibility Public
```

## Raw API requests

Call any TwexAPI path directly:

```bash theme={null}
x-api-scraper --app prod /twitter/elonmusk/about
x-api-scraper --app prod -X POST -d '["elonmusk","sama"]' /twitter/users
```

## Use as a skill

Install from a GitHub skill installer:

```bash theme={null}
npx skills add twexapi-dev/x-api-scraper-cli
```

Or install from ClawHub:

```bash theme={null}
npx clawhub@latest install x-api-scraper-cli
```

## Security notes

* The CLI reads `X_API_SCRAPER_KEY`, `X_API_SCRAPER_BASE_URL`, and `X_API_SCRAPER_CONFIG_DIR` from the environment.
* Saved app configs and profiles are stored as plain JSON in `~/.x-api-scraper/config.json` by default.
* Use `--dry-run` before any write action in agent workflows.

## References

* [SDKs overview](/sdks)
* [Authentication](/authentication)
* [MCP Server](/mcp/overview)
* [Agent MCP Handoff](/mcp/agent-handoff)
* [Advanced Twitter Search](/api-reference/search-endpoints/advanced-twitter-search)
* [Source Repository](https://github.com/twexapi-dev/x-api-scraper-cli)
