> ## Documentation Index
> Fetch the complete documentation index at: https://getanyapi.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# X / Twitter User Tweets and Replies

> Sell twitter.user_tweets on AnyAPI: the request your endpoint receives, the response it must return, and what the live trial grades.

Get up to the requested limit of tweets and replies authored by an X (Twitter) account, with engagement, views, language, and cursor pagination where available.

This page is the seller-facing summary of one catalog API, `twitter.user_tweets`. The transport rules that apply to every API a seller serves - signed requests, the response envelope, timeouts, and body limits - are on [the operator endpoint contract](https://getanyapi.com/docs/sell/operator-endpoint-contract.md).

## The price you compete with

AnyAPI publishes this API from **\$0.45 per 1,000 requests**. That is the price a buyer sees today, so it is the price your endpoint has to come in under to win traffic.

## The request your endpoint receives

| Field | Type | Required | What it means |
| - | - | - | - |
| `cursor` | string | no | Opaque pagination cursor from a previous response's nextCursor. Omit for the first page. |
| `handle` | string | yes | Twitter/X handle without the leading @. |
| `limit` | integer | no | Page size to ask for (1-100, default 20). Some sources honor it; others always return their whole native page of about 20 authored tweets and replies. A page is never trimmed after the call, so follow nextCursor and pass it back as cursor to continue exactly where this response ended. Default `20`. |
| `requireFields` | array | no | Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `isPinned`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A named field can still be absent on a post that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge. On a paginated walk it applies to the first page only; later pages stay with the source that page chose, at the price it was quoted. |
| `requireSinglePage` | boolean | no | Require a lane that can return the requested limit in one response. |

> **Full input JSON Schema**
>
> ```json theme={"dark"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "$id": "https://getanyapi.com/schemas/twitter.user_tweets.input.json",
>   "example": {
>     "handle": "levelsio",
>     "limit": 20
>   },
>   "title": "Twitter user tweets input",
>   "type": "object",
>   "additionalProperties": false,
>   "x-aliases": {
>     "username": "handle"
>   },
>   "required": [
>     "handle"
>   ],
>   "properties": {
>     "requireFields": {
>       "type": "array",
>       "uniqueItems": true,
>       "items": {
>         "type": "string",
>         "enum": [
>           "isPinned"
>         ]
>       },
>       "description": "Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `isPinned`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A named field can still be absent on a post that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge. On a paginated walk it applies to the first page only; later pages stay with the source that page chose, at the price it was quoted."
>     },
>     "handle": {
>       "type": "string",
>       "description": "Twitter/X handle without the leading @."
>     },
>     "limit": {
>       "type": "integer",
>       "minimum": 1,
>       "maximum": 100,
>       "default": 20,
>       "description": "Page size to ask for (1-100, default 20). Some sources honor it; others always return their whole native page of about 20 authored tweets and replies. A page is never trimmed after the call, so follow nextCursor and pass it back as cursor to continue exactly where this response ended."
>     },
>     "cursor": {
>       "type": "string",
>       "description": "Opaque pagination cursor from a previous response's nextCursor. Omit for the first page."
>     },
>     "requireSinglePage": {
>       "type": "boolean",
>       "description": "Require a lane that can return the requested limit in one response."
>     }
>   }
> }
> ```

## The response your endpoint must return

| Field | Type | Always present | What it means |
| - | - | - | - |
| `data` | null or object | yes | |
| `data.nextCursor` | string or null | no | Opaque cursor for the next page when the selected lane supports pagination, otherwise null. |
| `data.tweets` | array | yes | |
| `data.tweets[].authorHandle` | string | no | Handle of the account that posted. |
| `data.tweets[].authorId` | string | no | Numeric X user id of the account that posted, as a string. |
| `data.tweets[].authorImage` | string | no | Avatar image URL of the account that posted. |
| `data.tweets[].authorName` | string | no | Display name of the account that posted. |
| `data.tweets[].bookmarks` | integer | yes | |
| `data.tweets[].conversationId` | string | no | Id of the conversation the post belongs to, as a string. |
| `data.tweets[].createdUtc` | number | yes | UTC epoch timestamp in seconds (Unix time). Multiply by 1000 for a JS Date in milliseconds. |
| `data.tweets[].id` | string | yes | |
| `data.tweets[].isPinned` | boolean or null | yes | Whether X marks the post as pinned on the profile, or null when the serving source does not publish it. |
| `data.tweets[].isReply` | boolean | no | |
| `data.tweets[].lang` | string | no | |
| `data.tweets[].likes` | integer | yes | |
| `data.tweets[].media` | array | no | Photo, video, and GIF attachments on the post. Empty when the post has none. |
| `data.tweets[].media[].height` | integer | no | |
| `data.tweets[].media[].type` | string | yes | One of photo, video, or gif. |
| `data.tweets[].media[].url` | string | yes | Image URL. For a video or GIF this is the poster/thumbnail frame. X media URLs on pbs.twimg.com are publicly fetchable without authentication; append ?name=orig for the full-resolution original. |
| `data.tweets[].media[].videoUrl` | string | no | Playable video file URL. Present only for video and gif items. |
| `data.tweets[].media[].width` | integer | no | |
| `data.tweets[].quotes` | integer | no | |
| `data.tweets[].replies` | integer | yes | |
| `data.tweets[].retweets` | integer | yes | |
| `data.tweets[].source` | string | no | Client the post was sent from, e.g. "Twitter Web App". |
| `data.tweets[].text` | string | yes | |
| `data.tweets[].url` | string | yes | |
| `data.tweets[].views` | integer | yes | |
| `found` | boolean | yes | |

Extra fields are kept, missing declared fields fail.

> **Full output JSON Schema**
>
> ```json theme={"dark"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "$id": "https://getanyapi.com/schemas/twitter.user_tweets.output.json",
>   "title": "Twitter user tweets output",
>   "type": "object",
>   "additionalProperties": false,
>   "required": [
>     "found",
>     "data"
>   ],
>   "properties": {
>     "found": {
>       "type": "boolean"
>     },
>     "data": {
>       "oneOf": [
>         {
>           "type": "null"
>         },
>         {
>           "type": "object",
>           "additionalProperties": false,
>           "required": [
>             "tweets"
>           ],
>           "properties": {
>             "tweets": {
>               "x-anyapi-must-populate": true,
>               "type": "array",
>               "items": {
>                 "type": "object",
>                 "required": [
>                   "id",
>                   "url",
>                   "text",
>                   "createdUtc",
>                   "likes",
>                   "retweets",
>                   "replies",
>                   "views",
>                   "bookmarks",
>                   "isPinned"
>                 ],
>                 "properties": {
>                   "id": {
>                     "x-anyapi-must-populate": true,
>                     "type": "string"
>                   },
>                   "url": {
>                     "x-anyapi-must-populate": true,
>                     "type": "string"
>                   },
>                   "text": {
>                     "x-anyapi-must-populate": true,
>                     "type": "string"
>                   },
>                   "createdUtc": {
>                     "x-anyapi-must-populate": true,
>                     "type": "number",
>                     "description": "UTC epoch timestamp in seconds (Unix time). Multiply by 1000 for a JS Date in milliseconds."
>                   },
>                   "lang": {
>                     "type": "string"
>                   },
>                   "likes": {
>                     "type": "integer"
>                   },
>                   "retweets": {
>                     "type": "integer"
>                   },
>                   "replies": {
>                     "type": "integer"
>                   },
>                   "quotes": {
>                     "type": "integer"
>                   },
>                   "views": {
>                     "type": "integer"
>                   },
>                   "bookmarks": {
>                     "type": "integer"
>                   },
>                   "isReply": {
>                     "type": "boolean"
>                   },
>                   "isPinned": {
>                     "type": [
>                       "boolean",
>                       "null"
>                     ],
>                     "description": "Whether X marks the post as pinned on the profile, or null when the serving source does not publish it."
>                   },
>                   "media": {
>                     "type": "array",
>                     "description": "Photo, video, and GIF attachments on the post. Empty when the post has none.",
>                     "items": {
>                       "type": "object",
>                       "required": [
>                         "type",
>                         "url"
>                       ],
>                       "properties": {
>                         "type": {
>                           "type": "string",
>                           "description": "One of photo, video, or gif."
>                         },
>                         "url": {
>                           "type": "string",
>                           "format": "uri",
>                           "description": "Image URL. For a video or GIF this is the poster/thumbnail frame. X media URLs on pbs.twimg.com are publicly fetchable without authentication; append ?name=orig for the full-resolution original."
>                         },
>                         "videoUrl": {
>                           "type": "string",
>                           "format": "uri",
>                           "description": "Playable video file URL. Present only for video and gif items."
>                         },
>                         "width": {
>                           "type": "integer"
>                         },
>                         "height": {
>                           "type": "integer"
>                         }
>                       }
>                     }
>                   },
>                   "conversationId": {
>                     "type": "string",
>                     "description": "Id of the conversation the post belongs to, as a string."
>                   },
>                   "source": {
>                     "type": "string",
>                     "description": "Client the post was sent from, e.g. \"Twitter Web App\"."
>                   },
>                   "authorId": {
>                     "type": "string",
>                     "description": "Numeric X user id of the account that posted, as a string."
>                   },
>                   "authorName": {
>                     "type": "string",
>                     "description": "Display name of the account that posted."
>                   },
>                   "authorHandle": {
>                     "type": "string",
>                     "description": "Handle of the account that posted."
>                   },
>                   "authorImage": {
>                     "type": "string",
>                     "description": "Avatar image URL of the account that posted."
>                   }
>                 }
>               }
>             },
>             "nextCursor": {
>               "type": [
>                 "string",
>                 "null"
>               ],
>               "description": "Opaque cursor for the next page when the selected lane supports pagination, otherwise null."
>             }
>           }
>         }
>       ]
>     }
>   }
> }
> ```

## Fields that must never come back empty

* `createdUtc`
* `id`
* `text`
* `tweets`
* `url`

The repository marks these fields as ones every source must be able to fill. An empty value is only correct when the entity itself genuinely has nothing there.

## Not found, and how it differs from empty

When the entity does not exist, answer 2xx with the not-found shape:

```json theme={"dark"}
{
  "found": false,
  "data": null
}
```

An empty list is not a not-found: when the entity exists and has nothing to return, answer 2xx with `found: true` and an empty `tweets` array.

This output schema declares no `reason` field, so `found: false` is the whole not-found answer.

## Example request

```json theme={"dark"}
{
  "handle": "levelsio",
  "limit": 20
}
```

The compatibility checks fire the schema's example at your endpoint. After that, your answers are graded against what the currently serving source returned for the same real customer inputs.

## Behavior

* This timeline is the posts and the replies the account authored, so a reply it wrote belongs in the results and isReply marks it.
* Reposts are not part of this timeline: return only what the account wrote itself. twitter.user\_posts is the API that carries reposts.
* isPinned has three states: true or false when the serving source publishes it, and null when it does not. Never answer false to mean unknown.
* found false covers only a handle that cannot be resolved or an account whose posts are not available; an account with nothing to return is found true with an empty tweets array.
* limit is a per-page maximum of 1 to 100 and most sources return about 20, so a caller walks further with nextCursor rather than asking for one large page.
* nextCursor is null when the page just served is the last one available.

## Next

* [The operator endpoint contract](https://getanyapi.com/docs/sell/operator-endpoint-contract.md) for signing, budgets, and the live trial.
* [Every API open to sellers](https://getanyapi.com/docs/sell/apis/index.md).
* Want to sell an API that is not on that list? Email [support@getanyapi.com](mailto:support@getanyapi.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.