$npx -y skills add ReScienceLab/opc-skills --skill twitterSearch and retrieve content from Twitter/X. Get user info, tweets, replies, followers, communities, spaces, and trends via twitterapi.io. Use when user mentions Twitter, X, or tweets.
| 1 | # Twitter/X Skill |
| 2 | |
| 3 | Get user profiles, tweets, replies, followers/following, communities, spaces, and trends from Twitter/X via twitterapi.io. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | Set API key in `~/.zshrc`: |
| 8 | ```bash |
| 9 | export TWITTERAPI_API_KEY="your_api_key" |
| 10 | ``` |
| 11 | |
| 12 | **Quick Check**: |
| 13 | ```bash |
| 14 | cd <skill_directory> |
| 15 | python3 scripts/get_user_info.py elonmusk |
| 16 | ``` |
| 17 | |
| 18 | ## Commands |
| 19 | |
| 20 | All commands run from the skill directory. |
| 21 | |
| 22 | ### User Endpoints |
| 23 | ```bash |
| 24 | python3 scripts/get_user_info.py USERNAME |
| 25 | python3 scripts/get_user_about.py USERNAME |
| 26 | python3 scripts/batch_get_users.py USER_ID1,USER_ID2 |
| 27 | python3 scripts/get_user_tweets.py USERNAME --limit 20 |
| 28 | python3 scripts/get_user_mentions.py USERNAME --limit 20 |
| 29 | python3 scripts/get_followers.py USERNAME --limit 100 |
| 30 | python3 scripts/get_following.py USERNAME --limit 100 |
| 31 | python3 scripts/get_verified_followers.py USERNAME --limit 20 |
| 32 | python3 scripts/check_relationship.py USER1 USER2 |
| 33 | python3 scripts/search_users.py "query" --limit 20 |
| 34 | ``` |
| 35 | |
| 36 | ### Tweet Endpoints |
| 37 | ```bash |
| 38 | python3 scripts/get_tweet.py TWEET_ID [TWEET_ID2...] |
| 39 | python3 scripts/search_tweets.py "query" --type Latest --limit 20 |
| 40 | python3 scripts/get_tweet_replies.py TWEET_ID --limit 20 |
| 41 | python3 scripts/get_tweet_quotes.py TWEET_ID --limit 20 |
| 42 | python3 scripts/get_tweet_retweeters.py TWEET_ID --limit 50 |
| 43 | python3 scripts/get_tweet_thread.py TWEET_ID |
| 44 | python3 scripts/get_article.py TWEET_ID |
| 45 | ``` |
| 46 | |
| 47 | ### List Endpoints |
| 48 | ```bash |
| 49 | python3 scripts/get_list_followers.py LIST_ID --limit 20 |
| 50 | python3 scripts/get_list_members.py LIST_ID --limit 20 |
| 51 | ``` |
| 52 | |
| 53 | ### Community Endpoints |
| 54 | ```bash |
| 55 | python3 scripts/get_community.py COMMUNITY_ID |
| 56 | python3 scripts/get_community_members.py COMMUNITY_ID --limit 20 |
| 57 | python3 scripts/get_community_moderators.py COMMUNITY_ID |
| 58 | python3 scripts/get_community_tweets.py COMMUNITY_ID --limit 20 |
| 59 | python3 scripts/search_community_tweets.py "query" --limit 20 |
| 60 | ``` |
| 61 | |
| 62 | ### Other Endpoints |
| 63 | ```bash |
| 64 | python3 scripts/get_space.py SPACE_ID |
| 65 | python3 scripts/get_trends.py --woeid 1 # Worldwide |
| 66 | ``` |
| 67 | |
| 68 | ## Search Query Syntax |
| 69 | |
| 70 | ```bash |
| 71 | # Basic search |
| 72 | python3 scripts/search_tweets.py "AI agent" |
| 73 | |
| 74 | # From specific user |
| 75 | python3 scripts/search_tweets.py "from:elonmusk" |
| 76 | |
| 77 | # Date range |
| 78 | python3 scripts/search_tweets.py "AI since:2024-01-01 until:2024-12-31" |
| 79 | |
| 80 | # Exclude retweets |
| 81 | python3 scripts/search_tweets.py "AI -filter:retweets" |
| 82 | |
| 83 | # With media |
| 84 | python3 scripts/search_tweets.py "AI filter:media" |
| 85 | |
| 86 | # Minimum engagement |
| 87 | python3 scripts/search_tweets.py "AI min_faves:1000" |
| 88 | ``` |
| 89 | |
| 90 | ## API: twitterapi.io |
| 91 | - Base URL: https://api.twitterapi.io/twitter |
| 92 | - Auth: X-API-Key header |
| 93 | - Pricing: ~$0.15-0.18/1k requests |
| 94 | - Docs: https://docs.twitterapi.io/ |