# Mastodon 主页或对象详情 API (mastodon.profile)

- Canonical page: [https://everyinfra.com/mastodon-api/profile](https://everyinfra.com/mastodon-api/profile?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "mastodon", "action": "profile", "params": {...}}
- Price: $0.001389 per call ($1.39 per 1,000 requests); failed calls and empty results are not charged
- Returns: single object
- Mode: sync; add "mode": "async" for slow tasks

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| username | not declared | yes | not declared | Mastodon 账号名或 user@instance 形式的完整账号，开头 @ 可省略。仅传短用户名且未指定 instance 时默认 mastodon.social；不同实例的同名账号不是同一人。 |
| instance | not declared | no | not declared | Mastodon 实例域名，不带协议或路径。timeline 默认 fosstodon.org，其他入口默认 mastodon.social；显式 instance 优先于 username 中的实例，因此二者应保持一致。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| username | 用户名（@handle）。 |
| display_name | 显示名，可能与 username 不同。 |
| handle | 完整账号标识，形如 @user@instance。Mastodon 是联邦制，同名用户可存在于不同实例，只有 handle 全局唯一。 |
| instance | 所属实例域名。 |
| url | 该记录在原平台上的可访问链接。 |
| 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": "mastodon",
  "action": "profile",
  "params": {
    "username": "Mastodon@mastodon.social"
  }
}'
```

```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": "mastodon",
        "action": "profile",
        "params": {
            "username": "Mastodon@mastodon.social",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-09-26T08:56:04Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "mastodon",
  "action": "profile",
  "results": {
    "username": "•••",
    "display_name": "•••",
    "handle": "@Mastodon@mastodon.social",
    "instance": "mastodon.social",
    "url": "https://mastodon.social/@•••",
    "platform": "mastodon"
  },
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## Also

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