Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
X/Twitter messaging management via API. Read tweets, post tweets, reply, send DMs, search, and view analytics. Use when the user wants to interact with X/Twitter: (1) posting or scheduling tweets, (2) reading timeline/mentions/DMs, (3) replying to tweets, (4) searching tweets/users/hashtags, (5) checking engagement analytics. Requires Twitter API credentials (API key, API secret, access token, access secret) or Bearer token.
10installs
Sourceljt-520/openclaw-backup
Added on
NPX Install
npx skill4agent add ljt-520/openclaw-backup twitterTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Twitter/X API Skill
Interact with X (Twitter) via API v2 for reading, posting, replying, DMs, search, and analytics.
Setup
Credentials
Store credentials in environment variables or :
~/.config/twitter/credentials.jsonbash
export TWITTER_API_KEY="your-api-key"
export TWITTER_API_SECRET="your-api-secret"
export TWITTER_ACCESS_TOKEN="your-access-token"
export TWITTER_ACCESS_SECRET="your-access-secret"
export TWITTER_BEARER_TOKEN="your-bearer-token" # For read-only operationsOr create credentials file:
bash
mkdir -p ~/.config/twitter
cat > ~/.config/twitter/credentials.json << 'EOF'
{
"api_key": "your-api-key",
"api_secret": "your-api-secret",
"access_token": "your-access-token",
"access_secret": "your-access-secret",
"bearer_token": "your-bearer-token"
}
EOF
chmod 600 ~/.config/twitter/credentials.jsonInstall Dependencies
bash
pip install tweepyQuick Reference
| Task | Command |
|---|---|
| Post tweet | |
| Post with image | |
| Reply | |
| Thread | |
| Get timeline | |
| Get mentions | |
| Get DMs | |
| Send DM | |
| Search | |
| User info | |
| Tweet info | |
| Analytics | |
Scripts
tweet.py
Main script for all Twitter operations. Run with for details:
--helpbash
{baseDir}/scripts/tweet.py --help
{baseDir}/scripts/tweet.py post --helpCommon Workflows
Post a simple tweet:
bash
{baseDir}/scripts/tweet.py post "Hello, world!"Post with image:
bash
{baseDir}/scripts/tweet.py post "Check this out!" --media photo.png
{baseDir}/scripts/tweet.py post "Multiple images" --media img1.png --media img2.pngReply to a tweet:
bash
{baseDir}/scripts/tweet.py reply 1234567890 "Great point!"Post a thread:
bash
{baseDir}/scripts/tweet.py thread \
"First tweet in thread" \
"Second tweet" \
"Third tweet"Read your mentions:
bash
{baseDir}/scripts/tweet.py mentions --count 50Search for tweets:
bash
{baseDir}/scripts/tweet.py search "openclaw agent" --count 20
{baseDir}/scripts/tweet.py search "#AI lang:en" --count 20Get user info:
bash
{baseDir}/scripts/tweet.py user elonmuskSend a DM:
bash
{baseDir}/scripts/tweet.py dm username "Hello from OpenClaw!"View tweet analytics:
bash
{baseDir}/scripts/tweet.py analytics 1234567890API Tiers & Limits
| Tier | Cost | Read | Write | Search |
|---|---|---|---|---|
| Free | $0 | Limited | - | - |
| Basic | $100/mo | 10k/mo | 1.5k/mo | 50/mo |
| Pro | $5000/mo | 1M/mo | 300k/mo | 500/mo |
Free tier can only post tweets (no read access to timeline/mentions).
Basic tier required for reading mentions, timeline, and search.
Write-only operations work on free tier.
See for detailed rate limits.
{baseDir}/references/api-limits.mdError Handling
Common errors:
| Error | Cause | Solution |
|---|---|---|
| 403 Forbidden | Insufficient tier | Upgrade API tier or check endpoint access |
| 429 Too Many Requests | Rate limit hit | Wait and retry; check rate limit headers |
| 401 Unauthorized | Invalid credentials | Verify API keys and tokens |
| 404 Not Found | Tweet/user deleted | Handle gracefully, inform user |
| 422 Unprocessable | Duplicate tweet | Wait before posting same content |
Notes
- Rate limits: X API has strict rate limits. Scripts include retry logic.
- Media uploads: Images must be <5MB (PNG/JPG) or <15MB (GIF). Videos <512MB.
- Character limit: 280 characters per tweet. Threads for longer content.
- DMs: Require OAuth 1.0a user context (not Bearer token).
- Search operators: for advanced queries.
{baseDir}/references/search-operators.md
Related Files
- - Main CLI for all operations
{baseDir}/scripts/tweet.py - - Detailed rate limits by endpoint
{baseDir}/references/api-limits.md - - Twitter search syntax
{baseDir}/references/search-operators.md