Portable skill and helper scripts for working with X (Twitter) through twitterapi.io.
This repository packages a reusable skill plus terminal helpers for reading tweets, X Articles, downloading tweet videos, and calling other documented twitterapi.io endpoints without relying on direct x.com rendering.
It is designed for people who want:
- a portable skill install in
~/.codex/skills/twitterapi-x-reader; - simple terminal commands like
xread,xapi, andxmedia; - a stable path for research, summarization, and structured extraction from X.
This project is not affiliated with X Corp., Twitter, or twitterapi.io.
Maintainer: nicshik.
SKILL.mdfor agent environments that support skill-style workflowsagents/openai.yamlfor UI metadatareferences/with quickstart, human-readable notes, and research examplesscripts/with Python helpersbin/xread,bin/xapi, andbin/xmediaterminal wrappersinstall_portable.shfor install and update
- Python 3.10 or newer
zsh,rsync, andinstallforinstall_portable.sh- a
twitterapi.ioAPI key
From the repository root:
chmod +x ./install_portable.sh
./install_portable.shThen create your local key file if it does not already exist:
mkdir -p ~/.codex/skills/twitterapi-x-reader
printf '%s\n' 'TWITTERAPI_IO_KEY=your_key_here' > ~/.codex/skills/twitterapi-x-reader/.env.localIf your shell does not already include ~/.local/bin in PATH, add it.
If you only need the xread, xapi, and xmedia console scripts, install the package directly:
python -m pip install "git+https://github.com/nicshik/tweet-api-skill.git"The package install does not install the Codex skill files. Use TWITTERAPI_IO_KEY or --api-key for authentication.
Fetch a tweet or article:
xread "https://x.com/ZenithTON/status/2046570503801119055"Force article mode:
xread "2046570503801119055" --mode articleDownload the best MP4 video from a tweet:
xmedia "https://x.com/Yoda4ever/status/2049680135658336270?s=20" --output-dir ./downloadsxmedia prints JSON with the saved file path, byte count, source media URL, bitrate, and media key. Downloads are limited to HTTPS URLs under video.twimg.com.
Call any documented endpoint:
xapi --method GET --path /oapi/my/info --query-json '{}'xapi accepts official API paths by default. Full URLs are only accepted for https://api.twitterapi.io so the API key is not sent to arbitrary hosts.
Mutating HTTP methods are blocked unless you pass --allow-mutation:
xapi --method POST --path /twitter/post/create --body-json '{"text":"draft"}' --allow-mutationFor an installed skill, video export is initiated with the global wrapper:
xmedia "<tweet-url-or-id>" --output-dir ./downloadsThe direct skill-script equivalent is:
python3 ~/.codex/skills/twitterapi-x-reader/scripts/twitterapi_media.py "<tweet-url-or-id>" --output-dir ./downloadsThe command writes one or more .mp4 files and prints JSON like:
{
"kind": "media_download",
"tweet_id": "2049680135658336270",
"files": [
{
"path": "/absolute/path/to/2049680135658336270-media-1-2176000.mp4",
"bytes": 5744965,
"bitrate": 2176000,
"media_key": "13_2049617901142118400",
"url": "https://video.twimg.com/..."
}
],
"source": "twitterapi.io"
}Useful flags:
--output-dir ./downloadssets the destination directory.--firstdownloads only the first video media item.--filename name.mp4sets the output name when exactly one file is selected.--overwritereplaces an existing file.
Read a tweet or X Article and then analyze it:
xread "https://x.com/ZenithTON/status/2046570503801119055"Look up the author profile:
xapi --method GET --path /twitter/user/info --query-json '{"userName":"ZenithTON"}'Pull the author's recent tweets:
xapi --method GET --path /twitter/user/last_tweets --query-json '{"userName":"ZenithTON","includeReplies":false}'Inspect replies:
xapi --method GET --path /twitter/tweet/replies/v2 --query-json '{"tweetId":"2046570503801119055","queryType":"Latest"}'Inspect quote tweets:
xapi --method GET --path /twitter/tweet/quotes --query-json '{"tweetId":"2046570503801119055","includeReplies":false}'Search accounts by topic:
xapi --method GET --path /twitter/user/search --query-json '{"query":"TON AI"}'Search tweets by topic:
xapi --method GET --path /twitter/tweet/advanced_search --query-json '{"query":"\"AI agents\" Telegram TON","queryType":"Top"}'Download tweet video media for later processing:
xmedia "https://x.com/Yoda4ever/status/2049680135658336270?s=20" --output-dir ./downloads --overwriteIf a tweet has several video media items, xmedia downloads all of them by default. Use --first to download only the first item, or --filename custom-name.mp4 when exactly one item is selected.
For more detailed examples, see:
references/research_examples.mdreferences/capabilities.mdreferences/api_quickstart.mdreferences/endpoint_catalog.md
This repository does not store API keys.
The expected local key file is:
~/.codex/skills/twitterapi-x-reader/.env.local
Example:
TWITTERAPI_IO_KEY=your_key_here
The scripts also accept --api-key, but environment variables or .env.local are preferred because command-line arguments can be recorded in shell history.
Run the no-network tests:
python -m unittest discover -s testsCheck local documentation links:
python scripts/check_links.pyVerify the package entry points locally:
python -m pip install .
xapi --help
xread --help
xmedia --helpValidate the skill metadata with the Skill Creator validator when available:
python /path/to/skill-creator/scripts/quick_validate.py .Use GitHub Issues for questions, bugs, and feature requests.
Report security vulnerabilities privately through SECURITY.md. Do not open public issues with API keys, .env.local, private account data, or exploit details.
After pulling new changes from this repository, refresh the portable install with:
./install_portable.shThis updates the installed skill and global wrappers while preserving the local .env.local file.
Older local installs under ~/.codex/skills/twitterapi_x_reader are detected during installation. The installer copies the legacy .env.local into the new hyphen-case skill directory when needed, and the xread/xapi/xmedia wrappers still check the legacy path for compatibility.
- The default posture is read-only.
- Mutating API endpoints should only be used intentionally.
- Media downloads write local files and are limited to
video.twimg.com. certifiis supported when available, but the scripts can also fall back to the system certificate store.- See
SECURITY.mdbefore publishing logs, examples, or bug reports.
MIT