Agent skill
x
X (Twitter) API for tweets and profiles. Use when user mentions "X", "Twitter", "x.com", "twitter.com", shares a tweet link, "check X", or asks about social media posts.
Install this agent skill to your Project
npx add-skill https://github.com/vm0-ai/vm0-skills/tree/main/x
SKILL.md
X (Twitter) API
Use the X API v2 via direct curl calls to read tweets, search posts, view user profiles, timelines, and social graphs.
Official docs:
https://docs.x.com/x-api
When to Use
Use this skill when you need to:
- View user profiles - look up users by username or ID
- Read tweets - get tweet details by ID
- Browse timelines - get a user's tweets or mentions
- Search posts - find recent tweets matching a query
- Explore social graphs - list followers and following
Prerequisites
Verify authentication:
curl -s "https://api.x.com/2/users/me" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq .
Available Scopes
The connector grants read-only access:
tweet.read- Read tweets and timelinesusers.read- Read user profilesfollows.read- Read followers and following
How to Use
Base URL: https://api.x.com/2
1. Get Authenticated User Profile
Get the profile of the currently authenticated user:
curl -s "https://api.x.com/2/users/me?user.fields=id,name,username,description,profile_image_url,public_metrics,created_at,verified" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq .data
2. Look Up User by Username
Get a user's profile by their username:
Note: Replace
elonmuskwith the actual username you want to look up.
USERNAME="elonmusk"
curl -s "https://api.x.com/2/users/by/username/$USERNAME?user.fields=id,name,username,description,public_metrics,created_at,verified,profile_image_url" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq .data
3. Look Up User by ID
Get a user's profile by their user ID:
Note: Replace
12345with the actual user ID. You can obtain user IDs from other endpoint responses.
USER_ID="12345"
curl -s "https://api.x.com/2/users/$USER_ID?user.fields=id,name,username,description,public_metrics,created_at" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq .data
4. Look Up Multiple Users
Get profiles for multiple users at once (up to 100):
Note: Replace the IDs with actual user IDs, comma-separated.
curl -s "https://api.x.com/2/users?ids=12345,67890&user.fields=id,name,username,description,public_metrics" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq .data
5. Get a Tweet by ID
Get details of a specific tweet:
Note: Replace
1234567890with the actual tweet ID.
TWEET_ID="1234567890"
curl -s "https://api.x.com/2/tweets/$TWEET_ID?tweet.fields=created_at,public_metrics,author_id,conversation_id,lang&expansions=author_id&user.fields=name,username" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq .
6. Get Multiple Tweets
Get details for multiple tweets at once (up to 100):
Note: Replace the IDs with actual tweet IDs, comma-separated.
curl -s "https://api.x.com/2/tweets?ids=1234567890,0987654321&tweet.fields=created_at,public_metrics,author_id,text&expansions=author_id&user.fields=name,username" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq .
7. Get User's Tweets (Timeline)
Get recent tweets posted by a user:
Note: Replace
USER_IDwith the actual user ID. Use the "Look Up User by Username" endpoint first to get the ID.
USER_ID="12345"
curl -s "https://api.x.com/2/users/$USER_ID/tweets?max_results=10&tweet.fields=created_at,public_metrics,text&expansions=referenced_tweets.id" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq '.data[] | {id, text: .text[0:120], created_at, public_metrics}'
Query parameters:
max_results- 5 to 100 (default: 10)start_time/end_time- ISO 8601 datetime filtersince_id/until_id- Tweet ID boundariespagination_token- For paginating resultsexclude- Comma-separated:retweets,replies
8. Get User's Mentions
Get recent tweets that mention a user:
Note: Replace
USER_IDwith the actual user ID.
USER_ID="12345"
curl -s "https://api.x.com/2/users/$USER_ID/mentions?max_results=10&tweet.fields=created_at,public_metrics,author_id,text&expansions=author_id&user.fields=name,username" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq '.data[] | {id, text: .text[0:120], author: .author_id, created_at}'
9. Get Reverse Chronological Timeline
Get the authenticated user's home timeline (tweets from people they follow):
Note: Replace
USER_IDwith the authenticated user's ID (from "Get Authenticated User Profile").
USER_ID="12345"
curl -s "https://api.x.com/2/users/$USER_ID/timelines/reverse_chronological?max_results=10&tweet.fields=created_at,public_metrics,author_id,text&expansions=author_id&user.fields=name,username" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq '.data[] | {id, text: .text[0:120], created_at}'
10. Search Recent Tweets
Search for tweets from the past 7 days:
Note: Replace the query with your search terms. The query supports operators like
from:,to:,has:,-is:retweet, etc.
curl -s -G "https://api.x.com/2/tweets/search/recent" --data-urlencode "query=openai lang:en -is:retweet" --data-urlencode "max_results=10" --data-urlencode "tweet.fields=created_at,public_metrics,author_id,text" --data-urlencode "expansions=author_id" --data-urlencode "user.fields=name,username" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq '.data[] | {id, text: .text[0:120], created_at, public_metrics}'
Common search operators:
from:username- Tweets from a specific userto:username- Tweets replying to a user@username- Tweets mentioning a user#hashtag- Tweets with a hashtaghas:links/has:images/has:videos- Media filters-is:retweet- Exclude retweets-is:reply- Exclude replieslang:en- Filter by languageconversation_id:123- Tweets in a conversation thread
11. Get User's Followers
Get a list of users who follow a specific user:
Note: Replace
USER_IDwith the actual user ID.
USER_ID="12345"
curl -s "https://api.x.com/2/users/$USER_ID/followers?max_results=20&user.fields=id,name,username,description,public_metrics" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq '.data[] | {id, name, username, followers_count: .public_metrics.followers_count}'
12. Get User's Following
Get a list of users that a specific user follows:
Note: Replace
USER_IDwith the actual user ID.
USER_ID="12345"
curl -s "https://api.x.com/2/users/$USER_ID/following?max_results=20&user.fields=id,name,username,description,public_metrics" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq '.data[] | {id, name, username, followers_count: .public_metrics.followers_count}'
Pagination
Most list endpoints support pagination via pagination_token. Check the meta.next_token field in the response:
curl -s "https://api.x.com/2/tweets/search/recent?query=example&max_results=10" --header "Authorization: Bearer $(printenv X_TOKEN)" | jq .meta
Use the returned next_token value as pagination_token in the next request to get more results.
Common user.fields
| Field | Description |
|---|---|
id |
Unique user ID |
name |
Display name |
username |
Handle (without @) |
description |
Bio text |
created_at |
Account creation date |
public_metrics |
Followers, following, tweet, and listed counts |
profile_image_url |
Avatar URL |
verified |
Verification status |
location |
User-defined location |
url |
User-defined URL |
Common tweet.fields
| Field | Description |
|---|---|
id |
Unique tweet ID |
text |
Tweet content |
created_at |
Post timestamp |
author_id |
Author's user ID |
public_metrics |
Retweets, replies, likes, quotes, bookmarks, impressions |
conversation_id |
Thread root tweet ID |
lang |
Detected language |
referenced_tweets |
Retweet/quote/reply references |
entities |
URLs, hashtags, mentions, cashtags |
Guidelines
- Read-only access: This connector only grants read permissions; you cannot post, like, or retweet
- Rate limits: X API has strict rate limits; avoid rapid successive calls
- User IDs vs usernames: Most endpoints require numeric user IDs, not usernames. Use the username lookup endpoint first
- Fields are opt-in: The API only returns
idandtextby default; always specifytweet.fieldsanduser.fieldsfor richer data - 7-day search window: The recent search endpoint only covers the past 7 days
- Pagination: Use
max_resultsandpagination_tokenfor large result sets
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
brave-search
Brave Search API for web search. Use when user says "search web", "Brave search", or asks to "find on web" without specifying Google.
supadata
Supadata API for YouTube/web data. Use when user mentions "Supadata", "YouTube data", "channel stats", or web scraping data.
roadmap-planning
Build and prioritize product roadmaps using scoring models like RICE, ICE, and value-effort matrices. Activate when creating a product roadmap, prioritizing features, sequencing initiatives, mapping dependencies, balancing team capacity, choosing between Now/Next/Later or quarterly planning, or communicating roadmap tradeoffs to executives and stakeholders.
qdrant
Qdrant API for vector search. Use when user mentions "Qdrant", "vector database", "semantic search", or embeddings storage.
calendly
Calendly scheduling API. Use when user mentions "Calendly", "calendly.com", "schedule a meeting", "booking link", "event types", or asks about interview scheduling.
stripe
Stripe API for payments. Use when user mentions "Stripe", "payment", "subscription", "billing", "invoice", or asks about payment processing.
Didn't find tool you were looking for?