---
title: "Get User's Tweets and Replies - API Reference"
description: "Twitter timeline API: retrieve all tweets and replies posted by a Twitter/X user. Flat-rate $0.0002 per tweet, flexible rate limits, no subscriptions."
source: "https://docs.socialdata.tools/reference/get-user-tweets-replies/"
---

Returns an array of tweets from the user’s tweets and replies timeline. Typically Twitter returns ~20 results per page. You can request additional results by sending another request to the same endpoint using the `cursor` parameter.

The endpoint only works with profiles that are ‘public’ and will fail to retrieve tweets for profiles with a ‘protected’ privacy setting.

> **Tip**
> 
> This endpoint doesn’t support any filters and we can’t adjust the number of items returned in the response. To have more flexibility, you may also use the [Search endpoint](https://docs.socialdata.tools/reference/get-search-results/) with the `from:USERNAME` query to retrieve the user’s timeline. Our advanced search endpoint supports all of [Twitter’s search operators](https://docs.socialdata.tools/resources/twitter-search-operators/).

## Endpoint

To request only the user’s tweets timeline:

GET https://api.socialdata.tools/twitter/user/{user\_id}/tweets?cursor={cursor}

To request only the user’s replies timeline (this will also include their own tweets):

GET https://api.socialdata.tools/twitter/user/{user\_id}/tweets-and-replies?cursor={cursor}

### Headers

**Authorization** `string` — required

Authorization Bearer header containing your SocialData API key

Example: Bearer YOUR\_API\_KEY

### Path Parameters

**user\_id** `integer` — required

The numeric ID of the desired user.

Example: 443198458

### Query Parameters

**cursor** `string` — optional

Cursor value obtained from the next\_cursor response property. Omit this value to retrieve the first page. Always remember to urlencode the value.

Example: DAACCgACGC12FhmAJxAKAAMYLXYWGX\_Y8AgABAAAAAILAAUAAADoRW1QQzZ3QUFBZlEvZ0d...

> **Caution**
> 
> When using languages where the `user_id` value exceeds the default Integer type limit (e.g., JavaScript), you should store `user_id` as a String. Use the `id_str` property returned by the API for these values

## Code Examples

#### curl

```shellscript
curl "https://api.socialdata.tools/twitter/user/44196397/tweets" \
    -H 'Authorization: Bearer API_KEY' \
    -H 'Accept: application/json'
```

#### JavaScript

```js
const userId = '44196397';
const API_KEY = 'YOUR_API_KEY_HERE';

fetch(`https://api.socialdata.tools/twitter/user/${userId}/tweets`, {
    method: 'GET',
    headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Accept': 'application/json'
    }
})
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
```

#### Python

```python
import requests

userId = '44196397'
API_KEY = 'YOUR_API_KEY_HERE'

url = f'https://api.socialdata.tools/twitter/user/{userId}/tweets'

headers = {
    'Authorization': f'Bearer {API_KEY}',
    'Accept': 'application/json'
}

response = requests.get(url, headers=headers)

if response.status_code == 200:
    data = response.json()
    print(data)
else:
    print(f"Error: {response.status_code}")
    print(response.text)
```

#### PHP

```php
$userId = '44196397';
$API_KEY = 'YOUR_API_KEY_HERE';

$url = "https://api.socialdata.tools/twitter/user/{$userId}/tweets";

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer $API_KEY",
        "Accept: application/json"
    ]
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);

curl_close($ch);
```

## Example Responses

#### 200

```json
{
    "next_cursor": "DAACCgACGC12FhmAJxAKAAMYLXYWGX_Y8AgABAAAAAILAAUAAADoRW1QQzZ3QUFBZlEvZ0dKTjB2R3AvQUFBQUJNWUxTNkQyQmFoUXhndFRReS9Ga0NOR0MwZG9yS1hzU2NZTFFwYm0xY1I0aGd0YmhZc1drQ3FHQzBjUXNSV1lSZ1lMVml5V3BxQU9CZ3RMbUhUV2tDb0dDMVFuVW1YMEFzWUxKYURhOVpob3hndFZtaklGakNNR0MxWGdlT1dZSE1ZTFRYNFNwZUEraGd0Y2h2bEYxRkxHQzFNMi83V1VGc1lMTTZwemhZQWt4Z3RWMkJKbDNGN0dDMWFGTXBYUUY4WUxUUERuRlp3UVE9PQgABgAAAAAIAAcAAAAADAAICgABGCyWg2vWYaMAAAA",
    "tweets": [
        {
            "tweet_created_at": "2023-12-13T05:39:09.000000Z",
            "id_str": "1734810168053956719",
            "text": null,
            "full_text": "@TeslaHype Pace of Progress",
            "source": "<a href=\"http:\\/\\/twitter.com\\/download\\/iphone\" rel=\"nofollow\">Twitter for iPhone<\\/a>",
            "truncated": false,
            "in_reply_to_status_id_str": "1734777084268920960",
            "in_reply_to_user_id_str": "1311506622821400581",
            "in_reply_to_screen_name": "TeslaHype",
            "user": {
                "id_str": "44196397",
                "name": "Elon Musk",
                "screen_name": "elonmusk",
                "location": "\\ud835\\udd4f\\u00d0",
                "url": null,
                "description": "",
                "protected": false,
                "verified": false,
                "followers_count": 166213349,
                "friends_count": 506,
                "listed_count": 149586,
                "favourites_count": 37958,
                "statuses_count": 34934,
                "created_at": "2009-06-02T20:12:29.000000Z",
                "profile_banner_url": "https:\\/\\/pbs.twimg.com\\/profile_banners\\/44196397\\/1690621312",
                "profile_image_url_https": "https:\\/\\/pbs.twimg.com\\/profile_images\\/1683325380441128960\\/yRsRRjGO_normal.jpg",
                "can_dm": false
            },
            "quoted_status_id_str": null,
            "is_quote_status": false,
            "quoted_status": null,
            "retweeted_status": null,
            "quote_count": 11,
            "reply_count": 156,
            "retweet_count": 78,
            "favorite_count": 977,
            "lang": "en",
            "entities": {
                "user_mentions": [
                    {
                        "id_str": "1311506622821400581",
                        "name": "Tesla Hype",
                        "screen_name": "TeslaHype",
                        "indices": [
                            0,
                            10
                        ]
                    }
                ],
                "urls": [],
                "hashtags": [],
                "symbols": []
            },
            "views_count": 32377,
            "bookmark_count": 19
        },
        {
            "tweet_created_at": "2023-12-13T05:38:26.000000Z",
            "id_str": "1734809984674693446",
            "text": null,
            "full_text": "@anammostarac Yeah",
            "source": "<a href=\"http:\\/\\/twitter.com\\/download\\/iphone\" rel=\"nofollow\">Twitter for iPhone<\\/a>",
            "truncated": false,
            "in_reply_to_status_id_str": "1734809562258276654",
            "in_reply_to_user_id_str": "2852570664",
            "in_reply_to_screen_name": "anammostarac",
            "user": {
                "id_str": "44196397",
                "name": "Elon Musk",
                "screen_name": "elonmusk",
                "location": "\\ud835\\udd4f\\u00d0",
                "url": null,
                "description": "",
                "protected": false,
                "verified": false,
                "followers_count": 166213349,
                "friends_count": 506,
                "listed_count": 149586,
                "favourites_count": 37958,
                "statuses_count": 34934,
                "created_at": "2009-06-02T20:12:29.000000Z",
                "profile_banner_url": "https:\\/\\/pbs.twimg.com\\/profile_banners\\/44196397\\/1690621312",
                "profile_image_url_https": "https:\\/\\/pbs.twimg.com\\/profile_images\\/1683325380441128960\\/yRsRRjGO_normal.jpg",
                "can_dm": false
            },
            "quoted_status_id_str": null,
            "is_quote_status": false,
            "quoted_status": null,
            "retweeted_status": null,
            "quote_count": 4,
            "reply_count": 64,
            "retweet_count": 30,
            "favorite_count": 513,
            "lang": "en",
            "entities": {
                "user_mentions": [
                    {
                        "id_str": "2852570664",
                        "name": "Ana Mostarac",
                        "screen_name": "anammostarac",
                        "indices": [
                            0,
                            13
                        ]
                    }
                ],
                "urls": [],
                "hashtags": [],
                "symbols": []
            },
            "views_count": 25579,
            "bookmark_count": 3
        }
    ]
}
```

#### 402

```json
{
    "status": "error",
    "message": "Insufficient balance"
}
```

#### 404

```json
{
    "status": "error",
    "message": "Not found"
}
```

#### 500

```json
{
    "status": "error",
    "message": "Failed to fetch data from Twitter"
}
```

## Response Codes

-   **200 OK** - request succeeded
-   **402 Payment Required** - not enough credits to perform this request
-   **404 Not Found** - requested user not found
-   **422 Unprocessable Content** - validation failed (e.g. one of the required parameters was not provided)
-   **500 Internal Error** - API internal error, typically means that SocialData API failed to obtain the requested information and you should try again later

## Related endpoints

-   [Get user mentions](https://docs.socialdata.tools/reference/get-user-mentions/)
-   [Get user highlights](https://docs.socialdata.tools/reference/get-user-highlights/)
-   [Get user likes](https://docs.socialdata.tools/reference/get-user-likes/)

## Before you integrate

-   [Authentication](https://docs.socialdata.tools/getting-started/authentication/)
-   [Rate limits](https://docs.socialdata.tools/getting-started/rate-limits/)
-   [Errors](https://docs.socialdata.tools/getting-started/errors/)
-   [Pricing](https://docs.socialdata.tools/getting-started/pricing/)
