LogoAidir Docs
LogoAidir Docs
Homepage

Getting Started

Twitter API Overview

Tools

Twitter API Claude Code SKILL

API Reference

X (Twitter)

User Tweets

API for getting Twitter user tweet list

User Tweets

Get the list of tweets from a specific Twitter user.

Request

URL: /api/twitter/user-tweets

Method: GET or POST

Request Parameters:

ParameterTypeRequiredDescription
restIdstringYesUser's unique ID identifier
cursorstringNoPagination cursor for next page

Response

A successful response will return a list of user tweets in reverse chronological order, including tweet content, creation time, like count, retweet count, and other detailed information.

Examples

Request Example

# GET request
curl --request GET \
  --url 'https://www.aidir.fun/api/twitter/user-tweets?restId=44196397' \
  --header 'X-API-Key: <api-key>'

# POST request
curl --request POST \
  --url 'https://www.aidir.fun/api/twitter/user-tweets' \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '{
    "restId": "44196397"
  }'

Response Example

{
  "data": {
    "user": {
      "result": {
        "id": "44196397",
        "rest_id": "44196397",
        "name": "Elon Musk",
        "screen_name": "elonmusk"
      }
    },
    "timeline": {
      "instructions": [
        {
          "entries": [
            {
              "content": {
                "tweet": {
                  "id": "1512345678901234567",
                  "text": "This is a tweet example",
                  "created_at": "2023-04-15T14:34:12.000Z",
                  "favorite_count": 12345,
                  "retweet_count": 6789,
                  "reply_count": 1234,
                  "quote_count": 567,
                  "has_media": true,
                  "media": [
                    {
                      "type": "photo",
                      "url": "https://pbs.twimg.com/media/sample.jpg"
                    }
                  ]
                }
              }
            }
          ]
        }
      ]
    }
  }
}

Error Responses

Status CodeDescription
400Request parameter error, e.g., missing required restId parameter
401Authentication failed, API key invalid or missing
404User does not exist or has no tweets
500Internal server error

Getting the User's restId

To use this API, you need to know the user's restId. You can obtain it through the following methods:

  1. Use the User Profile API to query the user's basic information, which includes the restId
  2. On the Twitter web version, the user's profile URL usually contains their numeric ID, such as https://twitter.com/i/user/44196397

Pagination Instructions

In the response of the first request (e.g., https://www.aidir.fun/api/twitter/user-tweets?restId=44196397), you can find the cursor-bottom- entry at the end of the data:

{
  "entryId": "cursor-bottom-2000585960391180262",
  "sortIndex": "2000585960391180262",
  "content": {
    "entryType": "TimelineTimelineCursor",
    "__typename": "TimelineTimelineCursor",
    "value": "DAAHCgABG8OCVNe__-YLAAIAAAATMjAwMDQ0ODY2ODcwMTQzMDEwNggAAwAAAAIAAA",
    "cursorType": "Bottom"
  }
}

Get the value of content.value (which is the cursor), and add it as the cursor parameter to the request URL to get the next page of data:

https://www.aidir.fun/api/twitter/user-tweets?restId=44196397&cursor=DAAHCgABG8OCVNe__-YLAAIAAAATMjAwMDQ0ODY2ODcwMTQzMDEwNggAAwAAAAIAAA

Table of Contents

User Tweets
Request
Response
Examples
Request Example
Response Example
Error Responses
Getting the User's restId
Pagination Instructions