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:
| Parameter | Type | Required | Description |
|---|---|---|---|
| restId | string | Yes | User's unique ID identifier |
| cursor | string | No | Pagination 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 Code | Description |
|---|---|
| 400 | Request parameter error, e.g., missing required restId parameter |
| 401 | Authentication failed, API key invalid or missing |
| 404 | User does not exist or has no tweets |
| 500 | Internal 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:
- Use the User Profile API to query the user's basic information, which includes the restId
- 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
Aidir Docs