Documentation
Welcome to the TweetX402 API reference. This protocol allows AI agents to interact with X (Twitter) natively using micropayments on the Base network.
Base URL
https://x402.tweetx402.com
Authentication
To perform write actions (Tweet, Like, DM, etc.), you must provide your own X/Twitter authentication cookies. This creates a "Bring Your Own Auth" model where your agent acts on your behalf.
Login to X.com
Log in to the account you want your agent to control.
Export JSON
Open Cookie-Editor, click "Export", and select "Export as JSON". Save this array and pass it in the `cookies` field for any POST request.
Get Profile
Retrieve public profile information including bio, follower counts, and avatar.
Path Parameters
| Name | Type | Description |
|---|---|---|
| username | string | The Twitter handle (without @) |
Get Tweet
Get full metadata for a single tweet, including text, media, and engagement metrics.
Search Tweets
Query Parameters
| Name | Type | Description |
|---|---|---|
| q | string | Search query. Supports standard operators (e.g. from:user, #tag) |
| mode | enum | 'Top', 'Latest', 'Photos', or 'Videos' (Default: Latest) |
User Timeline
Get recent tweets from a specific user's timeline.
Path Parameters
| Name | Type | Description |
|---|---|---|
| username | string | The Twitter handle (without @) |
Query Parameters
| Name | Type | Description |
|---|---|---|
| limit | number | Max tweets to return (default 20) |
Get Trends
Get current trending topics and hashtags.
Send Tweet
Requirement: All write actions require an X Premium (Blue Verified) account.
Body Parameters
| Name | Type | Description |
|---|---|---|
| cookies | array | Authenticated JSON cookies array |
| text | string | Tweet content (max 280 chars) |
Tweet with Media
Body Parameters
| Name | Type | Description |
|---|---|---|
| media | array | Array of objects containing `data` (base64) and `mediaType` (mime) |
Tweet Long (Note)
Send a long tweet (Twitter Note) exceeding 280 characters.
Body Parameters
| Name | Type | Description |
|---|---|---|
| text | string | Long text content |
Like & Retweet
Body Parameters
| Name | Type | Description |
|---|---|---|
| cookies | array | Authenticated JSON cookies array |
| tweetId | string | ID of the tweet to like or retweet |
Replies & Quotes
Also supports /api/action/quote for quote tweeting.
Body Parameters
| Name | Type | Description |
|---|---|---|
| tweetId | string | ID of the tweet to reply to or quote |
| text | string | Content of your reply or quote |
Follow/Unfollow
Body Parameters
| Name | Type | Description |
|---|---|---|
| username | string | Target username (without @) |
Get Retweeters
Path Parameters
| Name | Type | Description |
|---|---|---|
| tweetId | string | ID of the tweet to inspect |
Direct Messages
List all DM conversations.
Body Parameters
| Name | Type | Description |
|---|---|---|
| cookies | array | Authenticated JSON cookies array |
Body Parameters
| Name | Type | Description |
|---|---|---|
| conversationId | string | Target conversation ID |
| text | string | Message content |
Use POST /api/action/dm/conversations to list available conversations.
Grok AI Chat
Direct API access to xAI's Grok model securely tunneled through your X Premium account.
Create a NEW conversation with Grok.