X/Twitter Data API
Pricing
from $0.10 / 1,000 results
You can access the X/Twitter Data API programmatically from your own applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in API & Integrations in Apify Console.
{ "openapi": "3.0.1", "info": { "version": "1.25", "x-build-id": "aDhWxhpMgcdAk9MRH" }, "servers": [ { "url": "https://api.apify.com/v2" } ], "paths": { "/acts/nourishing_fort~x-twitter-api/run-sync-get-dataset-items": { "post": { "operationId": "run-sync-get-dataset-items-nourishing_fort-x-twitter-api", "x-openai-isConsequential": false, "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.", "tags": [ "Run Actor" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/inputSchema" } } } }, "parameters": [ { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Enter your Apify token here" } ], "responses": { "200": { "description": "OK" } } } }, "/acts/nourishing_fort~x-twitter-api/runs": { "post": { "operationId": "runs-sync-nourishing_fort-x-twitter-api", "x-openai-isConsequential": false, "summary": "Executes an Actor and returns information about the initiated run in response.", "tags": [ "Run Actor" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/inputSchema" } } } }, "parameters": [ { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Enter your Apify token here" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/runsResponseSchema" } } } } } } }, "/acts/nourishing_fort~x-twitter-api/run-sync": { "post": { "operationId": "run-sync-nourishing_fort-x-twitter-api", "x-openai-isConsequential": false, "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.", "tags": [ "Run Actor" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/inputSchema" } } } }, "parameters": [ { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Enter your Apify token here" } ], "responses": { "200": { "description": "OK" } } } } }, "components": { "schemas": { "inputSchema": { "type": "object", "properties": { "profileUrls": { "title": "Profile URLs", "minLength": 1, "type": "string", "description": "Paste full X/Twitter profile URLs, one per line. Example: https://x.com/NASA, https://twitter.com/elonmusk. ⚠️ One of the 6 target fields must be non-empty." }, "handles": { "title": "Usernames (@handles)", "minLength": 1, "type": "string", "description": "Comma- or newline-separated @handles. The @ symbol is optional. Example: NASA, elonmusk, SpoxCHN_MaoNing. ⚠️ One of the 6 target fields must be non-empty." }, "userIds": { "title": "User IDs", "minLength": 1, "type": "string", "description": "Numeric X/Twitter user IDs (rest_id), comma- or newline-separated. Find one from a profile URL like x.com/user/status/ID. Example: 44196397. ⚠️ One of the 6 target fields must be non-empty." }, "searchQuery": { "title": "Search Query (users)", "minLength": 1, "type": "string", "description": "Search X/Twitter users by keyword. Returns matching user accounts. Example: AI researcher, marketing director. Note: tweet search is currently disabled by X.com. ⚠️ One of the 6 target fields must be non-empty." }, "tweetUrls": { "title": "Tweet URLs", "minLength": 1, "type": "string", "description": "Paste full tweet URLs, one per line. Example: https://x.com/user/status/2090877991228264814. ⚠️ One of the 6 target fields must be non-empty." }, "tweetIds": { "title": "Tweet IDs", "minLength": 1, "type": "string", "description": "Numeric tweet IDs, comma- or newline-separated. Find from tweet URL: x.com/user/status/ID. Example: 2090877991228264814. ⚠️ One of the 6 target fields must be non-empty." }, "getProfile": { "title": "Extract user profile info", "type": "boolean", "description": "Bio, followers, following, verified status, profile image, account age. Always enabled.", "default": true }, "getRecentTweets": { "title": "Include recent tweets", "type": "boolean", "description": "Pull the user's latest 20 tweets with text, media URLs, likes, retweets, replies, views.", "default": true }, "recentTweetCount": { "title": "Recent tweet count", "minimum": 1, "maximum": 200, "type": "integer", "description": "How many of the user's most recent tweets to pull (default 20, max 200). Requires getRecentTweets.", "default": 20 }, "getRecentMedia": { "title": "Include recent media", "type": "boolean", "description": "Pull the user's latest image and video posts as separate items.", "default": false }, "recentMediaCount": { "title": "Recent media count", "minimum": 1, "maximum": 50, "type": "integer", "description": "How many recent media posts to pull (default 5, max 50). Requires getRecentMedia.", "default": 5 }, "getFollowers": { "title": "Extract followers list", "type": "boolean", "description": "Pull the list of accounts following the target user. Requires auth cookie (auth_token + ct0).", "default": false }, "getFollowing": { "title": "Extract following list", "type": "boolean", "description": "Pull the list of accounts the target user follows. Requires auth cookie.", "default": false }, "followListCount": { "title": "Followers/following list size", "minimum": 1, "maximum": 5000, "type": "integer", "description": "How many accounts to pull from the followers or following list (default 100, max 5000).", "default": 100 }, "includeBlueVerifiedFollowers": { "title": "Blue verified followers only", "type": "boolean", "description": "Restrict the followers list to blue-checkmark subscribers. Requires getFollowers + auth cookie.", "default": false }, "getRetweeters": { "title": "Extract retweeters of a tweet", "type": "boolean", "description": "Pull the list of accounts who retweeted a specific tweet. Provide a tweet URL or ID. Requires auth cookie.", "default": false }, "includeTweetsForFollowers": { "title": "Also pull latest tweet for each follower", "type": "boolean", "description": "For each follower, also pull their most recent tweet. Adds context to lead lists. Increases cost.", "default": false }, "auth_token": { "title": "Auth Token (optional, advanced)", "type": "string", "description": "X.com auth_token cookie value. Required only for followers, following, retweeters, and bookmarks endpoints. Public profiles and tweets work without it." }, "ct0": { "title": "CT0 Cookie (optional, advanced)", "type": "string", "description": "X.com ct0 (csrf) cookie value. Required together with auth_token for authenticated endpoints." }, "proxyUrl": { "title": "Custom Proxy URL (optional)", "type": "string", "description": "HTTP/SOCKS5 proxy URL if you need a specific exit IP. Leave empty for default rotation." } } }, "runsResponseSchema": { "type": "object", "properties": { "data": { "type": "object", "properties": { "id": { "type": "string" }, "actId": { "type": "string" }, "userId": { "type": "string" }, "startedAt": { "type": "string", "format": "date-time", "example": "2025-01-08T00:00:00.000Z" }, "finishedAt": { "type": "string", "format": "date-time", "example": "2025-01-08T00:00:00.000Z" }, "status": { "type": "string", "example": "READY" }, "meta": { "type": "object", "properties": { "origin": { "type": "string", "example": "API" }, "userAgent": { "type": "string" } } }, "stats": { "type": "object", "properties": { "inputBodyLen": { "type": "integer", "example": 2000 }, "rebootCount": { "type": "integer", "example": 0 }, "restartCount": { "type": "integer", "example": 0 }, "resurrectCount": { "type": "integer", "example": 0 }, "computeUnits": { "type": "integer", "example": 0 } } }, "options": { "type": "object", "properties": { "build": { "type": "string", "example": "latest" }, "timeoutSecs": { "type": "integer", "example": 300 }, "memoryMbytes": { "type": "integer", "example": 1024 }, "diskMbytes": { "type": "integer", "example": 2048 } } }, "buildId": { "type": "string" }, "defaultKeyValueStoreId": { "type": "string" }, "defaultDatasetId": { "type": "string" }, "defaultRequestQueueId": { "type": "string" }, "buildNumber": { "type": "string", "example": "1.0.0" }, "containerUrl": { "type": "string" }, "usage": { "type": "object", "properties": { "ACTOR_COMPUTE_UNITS": { "type": "integer", "example": 0 }, "DATASET_READS": { "type": "integer", "example": 0 }, "DATASET_WRITES": { "type": "integer", "example": 0 }, "KEY_VALUE_STORE_READS": { "type": "integer", "example": 0 }, "KEY_VALUE_STORE_WRITES": { "type": "integer", "example": 1 }, "KEY_VALUE_STORE_LISTS": { "type": "integer", "example": 0 }, "REQUEST_QUEUE_READS": { "type": "integer", "example": 0 }, "REQUEST_QUEUE_WRITES": { "type": "integer", "example": 0 }, "DATA_TRANSFER_INTERNAL_GBYTES": { "type": "integer", "example": 0 }, "DATA_TRANSFER_EXTERNAL_GBYTES": { "type": "integer", "example": 0 }, "PROXY_RESIDENTIAL_TRANSFER_GBYTES": { "type": "integer", "example": 0 }, "PROXY_SERPS": { "type": "integer", "example": 0 } } }, "usageTotalUsd": { "type": "number", "example": 0.00005 }, "usageUsd": { "type": "object", "properties": { "ACTOR_COMPUTE_UNITS": { "type": "integer", "example": 0 }, "DATASET_READS": { "type": "integer", "example": 0 }, "DATASET_WRITES": { "type": "integer", "example": 0 }, "KEY_VALUE_STORE_READS": { "type": "integer", "example": 0 }, "KEY_VALUE_STORE_WRITES": { "type": "number", "example": 0.00005 }, "KEY_VALUE_STORE_LISTS": { "type": "integer", "example": 0 }, "REQUEST_QUEUE_READS": { "type": "integer", "example": 0 }, "REQUEST_QUEUE_WRITES": { "type": "integer", "example": 0 }, "DATA_TRANSFER_INTERNAL_GBYTES": { "type": "integer", "example": 0 }, "DATA_TRANSFER_EXTERNAL_GBYTES": { "type": "integer", "example": 0 }, "PROXY_RESIDENTIAL_TRANSFER_GBYTES": { "type": "integer", "example": 0 }, "PROXY_SERPS": { "type": "integer", "example": 0 } } } } } } } } }}OpenAPI is a standard for designing and describing RESTful APIs, allowing developers to define API structure, endpoints, and data formats in a machine-readable way. It simplifies API development, integration, and documentation.
OpenAPI is effective when used with AI agents and GPTs by standardizing how these systems interact with various APIs, for reliable integrations and efficient communication.
By defining machine-readable API specifications, OpenAPI allows AI models like GPTs to understand and use varied data sources, improving accuracy. This accelerates development, reduces errors, and provides context-aware responses, making OpenAPI a core component for AI applications.
You can download the OpenAPI definitions for X/Twitter Data API from the options below:
If you’d like to learn more about how OpenAPI powers GPTs, read our blog post.
You can also check out our other API clients: