# Spotify 关键词搜索 API (spotify.search)

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

Spotify 关键词搜索按 `keyword` 搜歌曲、艺人、专辑或歌单，`content_type` 取 `tracks`、`artists`、`albums` 或 `playlists`，每次选一种。每行带名称 `name`、参与艺人 `artists`、链接 `url` 和封面 `image_url`。它回答「这个名字在 Spotify 上对应哪些歌、艺人、专辑和歌单」，适合先找到对象，再拿链接去读详情。

`monthly_listener_count` 是衡量艺人热度的核心指标；`owner_name` 只在歌单结果里有，是歌单创建者；`rank` 是排行榜名次。搜播客节目和单集用播客接口，它的 `content_type` 取值不同。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | search 的音乐检索词，类型由 content_type 选择；podcast 默认搜索播客节目，不是单集详情查询。 |
| content_type | enum: albums / artists / playlists / tracks | no | not declared | search 使用 tracks、artists、albums、playlists；podcast 仅使用 podcasts_shows（节目）或 podcast_episodes_individual_episodes（单集）。不可跨 action 混用。 |
| limit | integer (1–100) | no | 20 | 这次调用最多返回的条数，整数，1–100；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| type | 记录类型，取值随能力而定（如 video / image / text）。 |
| name | 名称。用于账号/商品/商家类能力，指该对象本身的名字。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| artists | 参与艺人列表。 |
| album_name | 专辑名称。 |
| owner_name | 歌单创建者（歌单类结果用）。 |
| publisher | 发行方（播客用）。 |
| image_url | 图片链接。多图能力可能返回 image_urls 数组。 |
| duration_ms | 时长，**单位毫秒**（不是秒，除以 1000 才是秒）。 |
| play_count | 播放次数。 |
| follower_count | 粉丝数。null 表示不公开，不等于 0。 |
| monthly_listener_count | 月听众数。这是 Spotify 上衡量艺人热度的核心指标。 |
| track_count | 曲目总数。 |
| episode_count | 剧集数量（播客用）。 |
| release_date | 发行日期。 |
| is_explicit | 是否含限制级内容。 |
| preview_url | 30 秒试听片段链接，可能为 null。 |
| rank | 排行榜名次。 |
| 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": "spotify",
  "action": "search",
  "params": {
    "keyword": "arctic monkeys"
  }
}'
```

```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": "spotify",
        "action": "search",
        "params": {
            "keyword": "arctic monkeys",
        },
    },
    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; the list keeps the first 2 of 20. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "spotify",
  "action": "search",
  "results": [
    {
      "id": "5XeFesFbtLpXzIVDNQP22n",
      "url": "https://open.spotify.com/track/5XeFesFbtLpXzIVDNQP22n",
      "type": "track",
      "name": "I Wanna Be Yours",
      "artists": [
        "Arctic Monkeys"
      ],
      "album_name": "AM",
      "image_url": "https://i.scdn.co/image/ab67616d0000b2734ae1c4c5c45aabe565499163",
      "duration_ms": 183956,
      "is_explicit": false,
      "platform": "spotify"
    },
    {
      "id": "5FVd6KXrgO9B3JPmC8OPst",
      "url": "https://open.spotify.com/track/5FVd6KXrgO9B3JPmC8OPst",
      "type": "track",
      "name": "Do I Wanna Know?",
      "artists": [
        "Arctic Monkeys"
      ],
      "album_name": "AM",
      "image_url": "https://i.scdn.co/image/ab67616d0000b2734ae1c4c5c45aabe565499163",
      "duration_ms": 272394,
      "is_explicit": false,
      "platform": "spotify"
    }
  ],
  "count": 20,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 怎么衡量艺人热度？

把 `content_type` 设成 `artists`，看 `monthly_listener_count`，它是月听众数，Spotify 上衡量艺人热度的核心指标。`follower_count` 是粉丝数，null 表示不公开，不等于 0。

### 搜到专辑或歌曲后怎么读详情？

把行里的 `url` 交给专辑接口，读曲目列表、唱片公司和版权信息。歌曲行的 `album_name` 可以用来把歌归到专辑下，`track_count` 是专辑的曲目总数。

### `preview_url` 为 null 怎么办？

`preview_url` 是 30 秒试听片段的链接，可能为 null，用之前先判断。需要识别限制级内容时看 `is_explicit`，它标出结果是否含限制级内容。

## Also

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