LogoAIDIR Docs

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

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

Table of Contents