Use when building applications that interact with X (formerly Twitter) data and functionality.
Reach for this skill when agents need to search posts, manage user accounts, publish content, stream real-time data, manage direct messages, or analyze trends using the X API v2 endpoints.
Similar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Claude CodeNot declared
CursorNot declared
CodexNot declared
GitHub CopilotNot declared
WindsurfNot declared
Gemini CLINot declared
ClineNot declared
OpenCodeNot declared
Skill metadata
Parsed from SKILL.md frontmatter.
Version1.0
More metadata
mintlify-proj
x
version
1.0
Package contents
Files included with this skill beyond the listing page.
skill mdSKILL.md11,211 B
History
First seen on skills.sh
First recorded snapshot · 190 installs
SKILL.md
X API Skill
Product summary
The X API provides programmatic access to X's public conversation through modern REST endpoints. Agents use it to search posts, retrieve user data, publish content, manage lists and direct messages, stream real-time posts, and access trends. The API uses pay-per-usage pricing with no subscriptions. Key endpoints live at https://api.x.com/2/. Authentication requires a developer account, project, and app created in the Developer Console. Official SDKs exist for Python (xdk) and TypeScript (@xdevplatform/xdk). See the primary docs site for comprehensive reference.
When to use
Reach for this skill when:
Searching posts: Find posts by keyword, hashtag, user, date, or language using recent search (7 days) or full-archive search (back to 2006)
Retrieving user data: Look up user profiles, followers, following lists, or verify user information
Publishing content: Create posts, replies, quotes, or posts with media, polls, or thread management
Streaming real-time data: Set up filtered stream rules to receive posts matching specific criteria as they're published
Managing user relationships: Follow, unfollow, block, or mute users; manage lists and bookmarks
Accessing direct messages: Send, retrieve, or delete DMs
Analyzing trends: Get trending topics by location or personalized trends
Compliance: Track post edits, deletions, and user account changes via compliance streams
Troubleshooting API errors: Handle 401 (auth), 403 (access), 429 (rate limit), or 404 (not found) responses
Quick reference
Authentication methods
Method
Use case
Credentials
Bearer Token (OAuth 2.0 App-Only)
Read-only public data
App-only access token from Developer Console
OAuth 1.0a User Context
User-specific actions (post, like, follow)
API key, API secret, access token, access token secret
OAuth 2.0 Authorization Code
Third-party user authorization
Client ID, client secret, redirect URI
Core endpoints
Resource
Endpoint
Method
Purpose
Posts
/2/tweets/search/recent
GET
Search last 7 days
Posts
/2/tweets/search/all
GET
Full-archive search (Enterprise)
Posts
/2/tweets
POST
Create a post
Posts
/2/tweets/:id
GET
Get post by ID
Users
/2/users/by/username/:username
GET
Look up user by handle
Users
/2/users/:id
GET
Look up user by ID
Stream
/2/tweets/search/stream
GET
Connect to filtered stream
Stream Rules
/2/tweets/search/stream/rules
POST/GET
Add/retrieve stream rules
Direct Messages
/2/dmconversations/with/:participantid/messages
POST
Send DM
Lists
/2/lists
POST
Create a list
Trends
/2/trends/by/woeid/:id
GET
Get trends by location
Field and expansion parameters
Request additional data with fields and expansions:
# Request specific fields
?tweet.fields=created_at,public_metrics,lang
?user.fields=created_at,description,public_metrics
# Include related objects
?expansions=author_id,attachments.media_keys
?media.fields=url,preview_image_url,alt_text
Authenticate: Use OAuth 1.0a User Context (requires user's access tokens)
Prepare payload: Build JSON with text, optional reply, media, poll, or quotetweetid
Upload media (if needed): Use /2/media/upload endpoint first, get media IDs
POST to /2/tweets: Send request with Authorization header
Parse response: Extract post ID and edit history from response
Verify: Check response status; handle 201 (success) or error codes
Typical task: Set up filtered stream
Define rules: Create filter rules using operators (e.g., from:xdevelopers has:images)
Add rules: POST to /2/tweets/search/stream/rules with rule value
Connect to stream: GET /2/tweets/search/stream with Authorization header
Handle streaming: Read JSON objects line-by-line as posts arrive
Implement reconnection: Detect disconnects; use exponential backoff to reconnect
Process posts: Parse each post object; extract fields based on request parameters
Common gotchas
Missing fields in response: By default, endpoints return only id, text, and edithistorytweet_ids. Always request additional fields explicitly with tweet.fields, user.fields, etc.
Expansions without fields: Using expansions=author_id includes the author object, but you must also request user.fields to get author details beyond ID.
Bearer Token vs. User Token: Bearer Token (app-only) cannot post, like, or follow. Use OAuth 1.0a User Context for user actions.
Rate limit window resets: Limits reset at the Unix timestamp in x-rate-limit-reset, not after a fixed delay. Calculate wait time as resettime - currenttime.
Query length limits: Recent search allows 512 characters; full-archive allows 1024. Queries exceeding this fail silently or return truncated results.
Filtered stream rules are persistent: Rules added to a stream remain until explicitly deleted. Reconnecting does not clear rules.
Streaming disconnects are normal: Implement automatic reconnection with exponential backoff (start 1 minute, double each retry).
Deleted/protected posts return 404: Posts deleted by user or withheld in regions return 404. Handle gracefully.
Retweets and replies in search: By default, search includes retweets and replies. Use -is:retweet -is:reply to exclude them.
Pagination tokens expire: next_token is valid for a limited time. Store and use immediately; don't cache for later.
Verification checklist
Before submitting work with the X API:
Authentication: Verified correct token/credentials are in use; Bearer Token for read-only, OAuth 1.0a for user actions
Fields requested: Added tweet.fields, user.fields, etc. for all data needed; not relying on defaults
Expansions included: If requesting related objects (author, media), included both expansions and corresponding fields parameters
Query syntax: Tested search query with operators; confirmed it returns expected posts
Rate limits: Checked x-rate-limit-remaining header; implemented backoff for 429 errors