# Similar accounts

`GET https://api.twittrapi.com/user/{userId}/similar`

Accounts X recommends as similar to a user ("Similar to …").

HTML page: https://www.twittrapi.com/docs/reference/user-userid-similar

## Parameters

| Name | In | Type | Required | Default | Description |
| --- | --- | --- | --- | --- | --- |
| `userId` | path | string | yes |  | Numeric user ID (digits only, up to 30). To pass a handle instead, use -1 here and set username. |
| `username` | query | string | no |  | Handle, with or without @. When set, it is used instead of userId: the API looks up the ID first, which makes the call a little slower. Still one billed call. |

This endpoint also accepts `format=simple` (or the header `X-Response-Format: simple`) for compact, flat JSON with a fixed schema. Same price.

## Notes

- One page of usually 10 to 20 accounts, no cursor. Accounts without enough activity can get none.

## Response

Raw JSON of X's ConnectTabTimeline query for the user. The similar accounts are the module whose entryId starts with similartomodule; the other modules (the user itself, general suggestions) do not depend on the user. The simple format returns only the similar accounts.

With `format=simple`: Collection of User objects: only the similar accounts, without cursors (hasNextPage false).

## Errors

| Status | When |
| --- | --- |
| 422 | userId is not numeric, or the username lookup failed. |
| 400 | userId is -1 and username is missing, or the username contains characters X blocks. |
| 404 | The user could not be found. |

Shared errors (401 missing key, 402 no balance, 429 rate limit, 5xx) are listed on https://www.twittrapi.com/docs/helpful-infos/error-handling. Calls that fail with 400, 407, 408, 409 or a 5xx error are refunded.

## Example request

curl:

```bash
curl 'https://api.twittrapi.com/user/11348282/similar' \
  --header 'X-API-KEY: YOUR_API_KEY'
```

Python:

```python
import httpx

# No SDK method for this endpoint yet, so this is a plain HTTP call.
resp = httpx.get(
    "https://api.twittrapi.com/user/11348282/similar",
    headers={"X-API-KEY": "YOUR_API_KEY"},
    timeout=60,
)
data = resp.json()
```

Node.js:

```js
import { TwittrAPI } from "twittrapi";

const client = new TwittrAPI({ apiKey: process.env.TWITTRAPI_API_KEY });
// No wrapper method for this endpoint yet; client.get() sends the same authenticated GET.
const data = await client.get({
  path: "/user/11348282/similar",
});
```

RapidAPI:

```bash
curl 'https://twitter-aio.p.rapidapi.com/user/11348282/similar' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: twitter-aio.p.rapidapi.com'
```

## Example response

Shortened: arrays keep their first items and long strings are cut.

Raw (default):

```json
{
  "data": {
    "connect_tab_timeline": {
      "timeline": {
        "instructions": [
          {
            "type": "TimelineClearCache"
          },
          {
            "direction": "TopAndBottom",
            "type": "TimelineTerminateTimeline"
          },
          {
            "entries": [
              {
                "content": {
                  "__typename": "TimelineTimelineModule",
                  "clientEventInfo": {
                    "component": "people_connect_module",
                    "element": "module"
                  },
                  "displayType": "Vertical",
                  "entryType": "TimelineTimelineModule",
                  "header": {
                    "displayType": "Classic",
                    "text": "Follow"
                  },
                  "items": [
                    {
                      "entryId": "singleusermodule-0-user-11348282",
                      "item": {
                        "clientEventInfo": {
                          "component": "people_connect_module",
                          "details": {
                            "timelinesDetails": {
                              "…": "…"
                            }
                          },
                          "element": "SingleUserModule"
                        },
                        "itemContent": {
                          "__typename": "TimelineUser",
                          "itemType": "TimelineUser",
                          "userDisplayType": "User",
                          "user_results": {
                            "result": {
                              "…": "…"
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "entryId": "singleusermodule-0",
                "sortIndex": "2127344547863199744"
              },
              "… 2 more"
            ],
            "type": "TimelineAddEntries"
          }
        ]
      }
    }
  }
}
```

Simple (`format=simple`):

```json
{
  "data": [
    {
      "id": "19402238",
      "username": "ScienceNews",
      "name": "Science News",
      "description": "Covering the latest news in all fields of science. Publisher @society4science. See also @SN_Explores.",
      "location": "Washington, DC",
      "url": "https://www.sciencenews.org",
      "createdAt": "2009-01-23T16:56:32Z",
      "avatarUrl": "https://pbs.twimg.com/profile_images/1877466471686684672/8PJsUiB_.jpg",
      "bannerUrl": "https://pbs.twimg.com/profile_banners/19402238/1403559093",
      "verified": true,
      "verifiedType": null,
      "protected": false,
      "counts": {
        "followers": 5346759,
        "following": 512,
        "tweets": 83345,
        "likes": 529,
        "media": 11306,
        "listed": 0
      },
      "pinnedTweetIds": [
        "1565445141741142017"
      ],
      "isAutomated": false
    },
    "… 2 more"
  ],
  "nextCursor": null,
  "previousCursor": null,
  "hasNextPage": false
}
```
