Welcome to the XTracker API documentation. This API enables you to retrieve and filter X (formerly Twitter) posts from accounts you follow, providing a simple way to integrate real-time social media data into your applications or custom GPTs.
The API follows RESTful principles and returns data in JSON format. All endpoints are designed to be intuitive and easy to use.
https://xtrackerapi.com/api
The API supports two authentication methods: API Key authentication and OAuth 2.0.
For simple integrations, you can use your API key. There are two ways to provide it:
Include your API key in the X-API-Key
header:
X-API-Key: your_api_key_here
Include your API key as a query parameter:
?api_key=your_api_key_here
For more secure integrations, especially for third-party applications and ChatGPT/GPT Actions, we support OAuth 2.0 authentication with Bearer tokens.
https://xtrackerapi.com/api/oauth/authorize
with appropriate parametershttps://xtrackerapi.com/api/oauth/token
https://xtrackerapi.com/api/oauth/authorize?
response_type=code
&client_id=YOUR_CLIENT_ID
&redirect_uri=YOUR_CALLBACK_URL
&scope=profile+posts:read+accounts:read
&state=RANDOM_STATE
&code_challenge=CODE_CHALLENGE
&code_challenge_method=S256
Once you have an access token, include it in the Authorization header:
Authorization: Bearer YOUR_ACCESS_TOKEN
Our API supports streamlined OAuth authentication for ChatGPT integration. This allows users to connect without leaving the ChatGPT interface.
Use our Bearer Authentication schema URL in your GPT configuration:
https://xtrackerapi.com/schema/bearer_auth_schema.json
This schema includes the necessary x-gpt-oauth
extensions to enable streamlined authentication.
Scope | Description | Endpoints |
---|---|---|
profile |
Access to basic user profile information | /api/profile |
accounts:read |
Read list of followed accounts | GET /v1/accounts |
accounts:write |
Add or remove followed accounts | POST /v1/accounts , DELETE /v1/accounts/:username |
posts:read |
Read posts from followed accounts | GET /v1/posts , GET /v1/tweets/:id |
To ensure fair usage and system stability, API requests are subject to rate limits based on your account plan:
Plan | Daily Request Limit | Reset Time |
---|---|---|
Free | 100 requests/day | Midnight UTC |
Pro | 1,000 requests/day | Midnight UTC |
Enterprise | 10,000 requests/day | Midnight UTC |
When you reach your rate limit, the API will return a 429 Too Many Requests response.
Each API response includes headers to help you track your rate limit usage:
X-RateLimit-Limit
: Your total daily request limitX-RateLimit-Remaining
: Number of requests remaining in the current periodX-RateLimit-Reset
: Timestamp when the rate limit will reset (Unix timestamp)The API uses standard HTTP status codes to indicate the success or failure of a request.
Status Code | Description |
---|---|
200 OK | The request was successful. |
400 Bad Request | The request was invalid or missing required parameters. |
401 Unauthorized | Authentication failed or API key is missing. |
403 Forbidden | The API key is valid but doesn't have permission to access the resource. |
404 Not Found | The requested resource was not found. |
429 Too Many Requests | You've exceeded your rate limit. |
500 Server Error | An error occurred on the server. |
When an error occurs, the API returns a JSON object with an error message:
{
"success": false,
"error": "Invalid API key",
"code": "auth_error"
}
The XTracker API follows the OpenAPI 3.0 specification. You can use this schema to integrate with tools like Postman, OpenAPI Generator, or Custom GPTs.
Loading schema...
Loading schema...
{
"openapi": "3.1.0",
"info": {
"title": "XTracker API",
"description": "API to retrieve and filter X (Twitter) posts from accounts you follow",
"version": "1.0.0",
"contact": {
"name": "XTracker Support",
"url": "https://xtrackerapi.com/support"
}
},
"servers": [
{
"url": "https://xtrackerapi.com",
"description": "Production API Server"
}
],
"components": {
"securitySchemes": {
"ApiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key",
"description": "API key for authentication"
},
"BearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT",
"description": "OAuth 2.0 Bearer token authentication"
}
},
"schemas": {
"Account": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "Internal account ID"
},
"username": {
"type": "string",
"description": "Twitter username"
},
"account_id": {
"type": "string",
"description": "Twitter account ID"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "When the account was added to the system"
},
"last_updated": {
"type": "string",
"format": "date-time",
"description": "When posts were last fetched"
}
}
},
"Post": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "Internal post ID"
},
"post_id": {
"type": "string",
"description": "Twitter post ID"
},
"account_id": {
"type": "integer",
"description": "Internal account ID"
},
"username": {
"type": "string",
"description": "Twitter username"
},
"content": {
"type": "string",
"description": "Post text content"
},
"posted_at": {
"type": "string",
"format": "date-time",
"description": "When the post was created"
},
"likes_count": {
"type": "integer",
"description": "Number of likes"
},
"retweets_count": {
"type": "integer",
"description": "Number of retweets"
},
"replies_count": {
"type": "integer",
"description": "Number of replies"
},
"is_retweet": {
"type": "boolean",
"description": "Whether this is a retweet"
},
"is_reply": {
"type": "boolean",
"description": "Whether this is a reply"
},
"in_reply_to_user": {
"type": "string",
"description": "Username being replied to (if is_reply is true)"
},
"in_reply_to_status": {
"type": "string",
"description": "Status ID being replied to (if is_reply is true)"
},
"is_thread": {
"type": "boolean",
"description": "Whether this post is part of a thread"
},
"thread_id": {
"type": "string",
"description": "Thread ID if post is part of a thread"
},
"quoted_post_id": {
"type": "string",
"description": "ID of quoted post, if applicable"
},
"quoted_content": {
"type": "string",
"description": "Content of quoted post, if applicable"
},
"quoted_username": {
"type": "string",
"description": "Username of author of quoted post, if applicable"
},
"hashtags": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of hashtags in the post"
},
"mentions": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of user mentions in the post"
},
"urls": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of URLs in the post"
},
"media": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"photo",
"video",
"gif"
]
},
"url": {
"type": "string"
}
}
},
"description": "Media attached to the post"
}
}
},
"Hashtag": {
"type": "object",
"properties": {
"tag": {
"type": "string",
"description": "Hashtag text (without # symbol)"
},
"count": {
"type": "integer",
"description": "Number of posts containing this hashtag"
}
}
},
"Mention": {
"type": "object",
"properties": {
"username": {
"type": "string",
"description": "Username mentioned (without @ symbol)"
},
"count": {
"type": "integer",
"description": "Number of posts containing this mention"
}
}
},
"Error": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"default": false
},
"error": {
"type": "string"
},
"code": {
"type": "string"
}
}
}
}
},
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"paths": {
"/v1/accounts": {
"get": {
"summary": "Get followed accounts",
"description": "Returns a list of X accounts followed by the authenticated user",
"operationId": "v1GetAccounts",
"parameters": [
{
"name": "limit",
"in": "query",
"description": "Maximum number of accounts to return",
"schema": {
"type": "integer",
"default": 50
}
},
{
"name": "offset",
"in": "query",
"description": "Number of accounts to skip (for pagination)",
"schema": {
"type": "integer",
"default": 0
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"default": true
},
"accounts": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Account"
}
},
"count": {
"type": "integer"
},
"total": {
"type": "integer"
}
}
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"summary": "Follow a new Twitter account",
"description": "Follow a new Twitter account and add it to the database if it doesn't exist",
"operationId": "v1AddAccount",
"requestBody": {
"description": "Account details",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"username": {
"type": "string",
"description": "Twitter username to follow (with or without @, or full URL)"
}
},
"required": [
"username"
]
}
}
}
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"default": true
},
"message": {
"type": "string"
},
"account": {
"$ref": "#/components/schemas/Account"
}
}
}
}
}
},
"400": {
"description": "Bad request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/v1/accounts/{username}": {
"delete": {
"summary": "Unfollow a Twitter account",
"description": "Remove a Twitter account from the user's followed accounts",
"operationId": "v1UnfollowAccount",
"parameters": [
{
"name": "username",
"in": "path",
"required": true,
"description": "Twitter username to unfollow",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"default": true
},
"message": {
"type": "string"
}
}
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Account not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/v1/posts": {
"get": {
"summary": "Get posts with smart fetching",
"description": "Unified endpoint to get posts with smart fetching and comprehensive filtering",
"operationId": "v1GetPosts",
"parameters": [
{
"name": "account_id",
"in": "query",
"description": "Filter posts by specific account ID",
"schema": {
"type": "integer"
}
},
{
"name": "username",
"in": "query",
"description": "Filter posts by Twitter username",
"schema": {
"type": "string"
}
},
{
"name": "time_range",
"in": "query",
"description": "Filter posts by time range",
"schema": {
"type": "string",
"enum": [
"day",
"week",
"month",
"year"
],
"default": "week"
}
},
{
"name": "start_date",
"in": "query",
"description": "Filter posts posted after this date (ISO format: YYYY-MM-DD)",
"schema": {
"type": "string",
"format": "date"
}
},
{
"name": "end_date",
"in": "query",
"description": "Filter posts posted before this date (ISO format: YYYY-MM-DD)",
"schema": {
"type": "string",
"format": "date"
}
},
{
"name": "keywords",
"in": "query",
"description": "Filter posts containing these keywords (space-separated)",
"schema": {
"type": "string"
}
},
{
"name": "hashtag",
"in": "query",
"description": "Filter posts with specific hashtag(s) (comma-separated, without # symbol)",
"schema": {
"type": "string"
}
},
{
"name": "mention",
"in": "query",
"description": "Filter posts mentioning specific username(s) (comma-separated, without @ symbol)",
"schema": {
"type": "string"
}
},
{
"name": "is_thread",
"in": "query",
"description": "Filter thread starter posts only (true) or all posts (false)",
"schema": {
"type": "boolean",
"default": false
}
},
{
"name": "thread_id",
"in": "query",
"description": "Get all posts in a specific thread",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "Maximum number of posts to return",
"schema": {
"type": "integer",
"default": 50,
"maximum": 100
}
},
{
"name": "offset",
"in": "query",
"description": "Number of posts to skip (for pagination)",
"schema": {
"type": "integer",
"default": 0
}
},
{
"name": "view",
"in": "query",
"description": "Response format: 'full' includes all post details, 'simple' returns minimal fields",
"schema": {
"type": "string",
"enum": [
"full",
"simple"
],
"default": "full"
}
},
{
"name": "include_threads",
"in": "query",
"description": "Include thread information if post is part of a thread",
"schema": {
"type": "boolean",
"default": false
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"default": true
},
"posts": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Post"
}
},
"count": {
"type": "integer"
},
"total": {
"type": "integer"
},
"processing": {
"type": "object",
"description": "Processing details (only included if verbose=true)"
}
}
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Account not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/v1/gpt/post/{post_id}": {
"get": {
"summary": "Get formatted post details for ChatGPT",
"description": "Get post details in a markdown format optimized for ChatGPT, with proper formatting and structure",
"operationId": "v1GetPostForGpt",
"parameters": [
{
"name": "post_id",
"in": "path",
"required": true,
"description": "Post ID to retrieve",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"default": true
},
"post": {
"type": "string",
"description": "Markdown-formatted post content"
}
}
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Post not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/v1/gpt/posts": {
"get": {
"summary": "Get formatted posts for ChatGPT",
"description": "Get multiple posts in a markdown format optimized for ChatGPT, with proper formatting and structure",
"operationId": "v1GetPostsForGpt",
"parameters": [
{
"name": "username",
"in": "query",
"description": "Filter posts by Twitter username",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "Maximum number of posts to return",
"schema": {
"type": "integer",
"default": 5,
"maximum": 20
}
},
{
"name": "keywords",
"in": "query",
"description": "Filter posts containing these keywords (space-separated)",
"schema": {
"type": "string"
}
},
{
"name": "time_range",
"in": "query",
"description": "Filter posts by time range",
"schema": {
"type": "string",
"enum": [
"day",
"week",
"month"
],
"default": "week"
}
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"default": true
},
"posts": {
"type": "string",
"description": "Markdown-formatted post content"
},
"count": {
"type": "integer"
}
}
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
}
}
The XTracker API offers a streamlined set of endpoints:
Our streamlined, user-friendly API with unified endpoints that follow the principle of "do what I mean" - you request what you need, and the system handles all the complexity behind the scenes.
Key benefits:
Returns a list of all X accounts that you are following.
Follow a new X account. If the account doesn't exist in the database, it will be created.
{
"username": "elonmusk" // X username (without the @ symbol)
}
Unfollow an X account. The account will remain in the database for other users who follow it.
This endpoint retrieves posts with comprehensive filtering options from all your followed accounts with detailed raw data access.
Parameter | Type | Description |
---|---|---|
account | string | Optional username to filter by (if not provided, returns posts from all followed accounts) |
time_range | string | Time range to fetch: 'day', 'week', 'month', 'year' (default: 'week') |
keywords | string | Text to search for in post content |
hashtag | string | Filter posts by hashtag (without the # symbol) |
mention | string | Filter posts by mentioned username |
min_likes | integer | Minimum number of likes |
min_retweets | integer | Minimum number of retweets |
min_replies | integer | Minimum number of replies |
is_thread | boolean | Set to 'true' to filter for thread starters only |
thread_id | string | Filter by specific thread ID |
limit | integer | Maximum number of posts to return (default: 50, max: 100) |
offset | integer | Number of posts to skip for pagination (default: 0) |
sort | string | Sort by 'recency' or 'popularity' (default: 'recency') |
view | string | Response format: 'full', 'simple', or 'thread' (default: 'full') |
verbose | boolean | Include processing details in response (default: false) |
{
"success": true,
"posts": [...],
"count": 25,
"total": 156,
"limit": 50,
"offset": 0,
"cost_data": {
"endpoints_used": ["user_timeline", "search"],
"request_count": 3,
"estimated_cost": 0.006,
"data_volume": 156
},
"processing": null // Processing steps when verbose=true
}
This specialized endpoint provides posts formatted specifically for AI and GPT integration, with output options in both JSON and markdown formats.
This endpoint supports both GET and POST methods:
Parameter | Type | Description |
---|---|---|
account | string | Filter by username (returns all accounts if not specified) |
query | string | General text search across post content |
keywords | string | Space-separated keywords to search for |
hashtags | string | Comma-separated hashtags (without # symbol) |
mentions | string | Comma-separated mentions (without @ symbol) |
time_range | string | Predefined range: "day", "week", "month", "year" (default: "week") |
start_date | string | ISO format date for custom start time |
end_date | string | ISO format date for custom end time |
format | string | Response format: "json" (default) or "markdown" |
limit | integer | Maximum posts to return (default: 25, max: 100) |
sort | string | Sort by: "recency" (default) or "engagement" |
{
"success": true,
"posts": [
{
"id": "1234567890123456789",
"account": "elonmusk",
"content": "Just announced a new AI product that will change the way we interact with technology. #AI #Innovation",
"posted_at": "2025-01-15T12:34:56Z",
"engagement": {
"likes": 4582,
"retweets": 891,
"replies": 327,
"views": 982451
},
"is_thread": true,
"thread_length": 3,
"thread_summary": "Announcement of a new AI product with details about features and release timeline",
"media_count": 2,
"hashtags": ["AI", "Innovation"],
"mentions": [],
"url": "https://x.com/elonmusk/status/1234567890123456789"
},
{
"id": "9876543210987654321",
"account": "sama",
"content": "Our latest research shows significant progress in multimodal understanding. Check out the paper: example.com/paper",
"posted_at": "2025-01-14T09:12:45Z",
"engagement": {
"likes": 3214,
"retweets": 567,
"replies": 231,
"views": 754129
},
"is_thread": false,
"thread_length": 0,
"thread_summary": null,
"media_count": 0,
"hashtags": [],
"mentions": [],
"url": "https://x.com/sama/status/9876543210987654321"
}
],
"count": 2,
"total": 245,
"metadata": {
"query": "AI technology",
"time_range": "week",
"accounts": ["elonmusk", "sama", "OpenAI"]
}
}
# AI-Related Posts from Your Followed Accounts
## Post by @elonmusk
**Posted on January 15, 2025 at 12:34 UTC**
Just announced a new AI product that will change the way we interact with technology. #AI #Innovation
馃搳 **Engagement**: 4,582 likes 路 891 retweets 路 327 replies 路 982K views
馃У **Thread with 3 posts**:
1. Announcement of the product
2. Details about key features
3. Information about release timeline
---
## Post by @sama
**Posted on January 14, 2025 at 09:12 UTC**
Our latest research shows significant progress in multimodal understanding. Check out the paper: example.com/paper
馃搳 **Engagement**: 3,214 likes 路 567 retweets 路 231 replies 路 754K views
---
**Query**: AI technology
**Time Range**: Past week
**Total Posts Found**: 245
Retrieve detailed information about a specific post including engagement metrics and reply count.
Parameter | Type | Description |
---|---|---|
post_id | string | The X post ID to retrieve |
{
"success": true,
"post": {
"id": 12345,
"post_id": "1234567890123456789",
"account_id": 42,
"username": "elonmusk",
"content": "This is an example post with #hashtags and @mentions",
"posted_at": "2025-01-15T12:34:56Z",
"likes_count": 4582,
"retweets_count": 891,
"replies_count": 327,
"is_retweet": false,
"is_thread_starter": false,
"thread_id": null,
"quoted_post_id": null,
"hashtags": ["hashtags"],
"mentions": ["mentions"],
"media": [],
"url": "https://x.com/elonmusk/status/1234567890123456789"
}
}