# X (Twitter) 是否关注 API (twitter.check_follow)

- Canonical page: https://everyinfra.com/twitter-api/check_follow
- Endpoint: POST /api/v1/social with {"platform": "twitter", "action": "check_follow", "params": {...}}
- Price: $0.000806 per call ($0.81 per 1,000 requests); failed and empty results are not charged
- Returns: single object
- Mode: sync; add "mode": "async" for slow tasks

是否关注按 `username` 和 `target_username` 判断前者有没有关注后者，只返回一个对象：两个账号名原样带回，再加一个布尔值 `is_following`。它回答「A 有没有关注 B」，适合核对合作账号之间的关注关系、确认活动要求的关注动作有没有完成，或者在整理名单前先排除没有关注关系的账号。

方向不能对调：`username` 是关注者，`target_username` 是被关注的一方，两个都必填，都可以带 @。这个方向和 X 官方的 Get Following 一致，官方也是从关注者一侧列出关注关系。

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=twitter&action=check_follow

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| username | not declared | yes | not declared | 要查的账号（关注者一方），X 用户短名，可带 @。 |
| target_username | not declared | yes | not declared | 被关注的账号，X 用户短名，可带 @；查 username 有没有关注它。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| username | 用户名（@handle）。 |
| target_username | 被查是否被关注的账号（check_follow 原样带回）。 |
| is_following | username 是否关注了 target_username（check_follow）。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## Example

```bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "twitter",
  "action": "check_follow",
  "params": {
    "username": "nasa",
    "target_username": "NASAHubble"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "twitter",
        "action": "check_follow",
        "params": {
            "username": "nasa",
            "target_username": "NASAHubble",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "twitter",
  "action": "check_follow",
  "results": {
    "username": …,
    "target_username": …,
    "is_following": …,
    "platform": …
  },
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 查 A 有没有关注 B，两个参数怎么填？

`username` 填 A，也就是可能在关注的那一方，`target_username` 填 B，也就是被关注的账号，都可以带 @。返回里的 `is_following` 为真，表示 A 关注了 B；两个账号名也会原样带回，方便对应到你的名单。`username` 和 `target_username` 都填 X 用户短名，不用写主页链接。

### 怎么判断两个账号是不是互相关注？

调两次，第二次把两个参数对调，两次的 `is_following` 都为真才是互相关注。只调一次只能说明一个方向：A 关注了 B，不能推出 B 也关注了 A。

### 什么时候用这一页，什么时候用关注列表？

只想确认一对账号的关系，用这一页，一次调用只返回一个对象。想看一个账号关注了哪些人，用关注列表，它一次返回一批账号，不回答某一对账号的关系。查有没有转推某条帖子，则是另一页，要传帖子 ID。

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=twitter
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
