# Relationships with many accounts

`GET https://api.twittrapi.com/user/friendships/batch`

Whether one account follows up to 50 others, and the other way round, in one request.

HTML page: https://www.twittrapi.com/docs/reference/user-friendships-batch

## Parameters

| Name | In | Type | Required | Default | Description |
| --- | --- | --- | --- | --- | --- |
| `source_screen_name` | query | string | yes |  | The account to compare with the others, with or without @. |
| `target_screen_names` | query | string (comma-separated) | yes |  | Handles separated by commas, with or without @. At most 50. Duplicates are dropped. |

## Notes

- Billed one call per target handle (duplicates count once).
- No simple format: with format=simple the response is the same as without it.

## Response

Built by the API: {"source_screen_name": "...", "relationships": [{"target_screen_name": "...", "relationship": {...}}], "errors": [...]}. relationship is the same object /user/friendships/show returns (source and target with following and followed_by). relationships keeps the order of target_screen_names. A handle that could not be looked up is listed in errors: [{"username": "...", "error": "upstream_error", "message": "..."}]; errors is left out when there are none.

## Errors

| Status | When |
| --- | --- |
| 400 | source_screen_name or target_screen_names is missing, or there are more than 50 targets. |
| 422 | A handle is not 1 to 15 letters, digits or underscores. |

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/friendships/batch?source_screen_name=jack&target_screen_names=XDevelopers,TwitterDev' \
  --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/friendships/batch",
    headers={"X-API-KEY": "YOUR_API_KEY"},
    params={
        "source_screen_name": "jack",
        "target_screen_names": "XDevelopers,TwitterDev",
    },
    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/friendships/batch",
  query: {
    source_screen_name: "jack",
    target_screen_names: "XDevelopers,TwitterDev",
  },
});
```

RapidAPI:

```bash
curl 'https://twitter-aio.p.rapidapi.com/user/friendships/batch?source_screen_name=jack&target_screen_names=XDevelopers,TwitterDev' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: twitter-aio.p.rapidapi.com'
```
