---
name: x-tweet-fetcher
description: Fetch tweets and replies from X/Twitter without login or API keys. Use when extracting content from X/Twitter posts, fetching user timelines, or getting tweet replies. Supports single tweets via FxTwitter API (zero dependencies) and user timelines/replies via Camofox + Nitter browser automation.
---

# X Tweet Fetcher

Fetch tweets and replies from X/Twitter without login or API keys.

## Capabilities

| Mode | Content | Dependencies |
|------|---------|--------------|
| `--url` | Single tweet (text + stats + media) | None (FxTwitter API) |
| `--url` | X Articles (long-form posts) | None (FxTwitter API) |
| `--url` | Quoted tweets | None (FxTwitter API) |
| `--user` | User timeline | Camofox + Nitter |
| `--url --replies` | Tweet replies | Camofox + Nitter |

## Quick Start

### Single Tweet (Zero Dependencies)

```bash
# JSON output
python3 {baseDir}/scripts/fetch_tweet.py --url "https://x.com/user/status/123456"

# Human-readable format
python3 {baseDir}/scripts/fetch_tweet.py --url "https://x.com/user/status/123456" --text-only

# Pretty JSON
python3 {baseDir}/scripts/fetch_tweet.py --url "https://x.com/user/status/123456" --pretty
```

### User Timeline (Requires Camofox)

```bash
# Fetch latest 20 tweets (default)
python3 {baseDir}/scripts/fetch_tweet.py --user elonmusk

# Fetch 5 tweets, text format
python3 {baseDir}/scripts/fetch_tweet.py --user username --limit 5 --text-only

# JSON output, 10 tweets
python3 {baseDir}/scripts/fetch_tweet.py --user username --limit 10 --pretty
```

### Tweet Replies (Requires Camofox)

```bash
# JSON output
python3 {baseDir}/scripts/fetch_tweet.py --url "https://x.com/user/status/123456" --replies --pretty

# Text format
python3 {baseDir}/scripts/fetch_tweet.py --url "https://x.com/user/status/123456" --replies --text-only
```

## Requirements

- Python 3.7+
- For `--user` and `--replies`: [Camofox](https://github.com/openclaw/camofox) running on localhost:9377

## How It Works

| Mode | Mechanism |
|------|-----------|
| `--url` | [FxTwitter](https://github.com/FxEmbed/FxEmbed) public API — zero dependencies |
| `--user` | Camofox opens Nitter, scrapes timeline |
| `--url --replies` | Camofox opens Nitter tweet page, scrapes replies |

## Output Format

Default is JSON. Use `--text-only` for human-readable output.

### Tweet Object

```json
{
  "author": "@username",
  "author_name": "Display Name",
  "text": "Tweet content",
  "time_ago": "2h",
  "likes": 42,
  "retweets": 5,
  "replies": 3,
  "views": 1000,
  "media": ["https://pbs.twimg.com/media/..."],
  "url": "https://x.com/...",
  "is_reply": false,
  "is_quote": false,
  "quoted_tweet": null
}
```

## All Options

| Option | Description |
|--------|-------------|
| `--url URL` | Tweet URL (x.com or twitter.com) |
| `--user USERNAME` | Fetch user timeline (no @) |
| `--limit N` | Max tweets for --user (default: 20) |
| `--replies` | Fetch replies instead of single tweet |
| `--pretty` | Pretty print JSON |
| `--text-only` | Human-readable output |
| `--lang zh\|en` | Message language (default: zh) |
| `--timeout N` | Request timeout seconds (default: 30) |
| `--port N` | Camofox port (default: 9377) |
| `--nitter HOST` | Nitter instance (default: nitter.net) |

## Limitations

- `--user` and `--replies` depend on Nitter availability
- Cannot fetch deleted or private tweets
- `--url` depends on FxTwitter service availability
- Rate limits may apply for heavy usage

## Error Handling

- Returns clear error messages in chosen language (zh/en)
- Indicates when Camofox is required but not running
- Handles private/deleted tweets gracefully
