# 闲鱼 Xianyu 关键词搜索 API (xianyu.search)

- Canonical page: https://everyinfra.com/xianyu-api/search
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "xianyu", "action": "search", "params": {...}}
- Price: $0.005556 per call ($5.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 20, max 50 per call
- Mode: sync; add "mode": "async" for slow tasks

闲鱼关键词搜索按 `keyword` 检索闲鱼上的二手商品，返回标题、价格、卖家填写的原价、所在城市（部分商品只到省份）、想要人数、商品标签、是否包邮、是否拍卖和发布时间，以及卖家昵称和信用等级。它回答「这件东西二手卖多少、好不好出手」，适合做二手行情和残值估算、回收定价和闲置商品监测。

卖家标题里常见的中文词或型号词更容易命中。`want_count` 是点过「我想要」的人数，能反映需求热度，卡片上没显示时为 null，不等于 0；拍卖商品的 `price` 是当前出价，估价时最好剔除。`original_price` 由卖家自己填写，只能参考。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | 闲鱼站内搜索词，1–100 个字符；卖家标题里常见的中文词或型号词更容易命中。 |
| limit | integer (1–50) | no | 20 | 这次调用最多返回的条数，整数，1–50；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| item_id | 闲鱼商品数字 ID（字符串）；可直接放进 item_detail 的 urls。 |
| url | 该记录在原平台上的可访问链接。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| price | 价格数值，不含货币符号；币种见 currency。 |
| original_price | 卖家填写的原价（元）；没填时为 null。 |
| currency | 价格币种代码（如 CNY、USD）。price 存在但 currency 为 null 时不要假定币种。 |
| city | 商品所在地，按闲鱼页面显示到城市，部分商品只显示到省份；更细的位置见 district、lat、lng、poi_name。 |
| image_url | 图片链接。多图能力可能返回 image_urls 数组。 |
| want_count | 想要人数，即点过「我想要」的用户数。搜索结果取自商品卡片上的「N人想要」，卡片没显示时为 null；null 不等于 0。 |
| tags | 商品卡片上的全部标签，按页面原文返回，如「全新」「包邮」、品牌、降价提示，以及卖家信用、实名认证、多久前来过、来闲鱼几年这类卖家标签；想要人数单独放在 want_count。无标签时为空数组。 |
| category_id | 闲鱼类目 ID（字符串）。 |
| free_shipping | 是否包邮。 |
| is_auction | 是否为拍卖商品；拍卖商品的 price 是当前出价。 |
| has_video | 商品是否带视频。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| seller_id | 卖家数字 ID（字符串）。 |
| seller_name | 卖家昵称。闲鱼对未登录访问会部分打码（如「南***鱼」），按页面显示原样返回。 |
| seller_avatar_url | 卖家头像链接。 |
| seller_credit_label | 搜索卡片上显示的卖家信用等级原文，如「极好」。 |
| 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": "xianyu",
  "action": "search",
  "params": {
    "keyword": "iPhone 15"
  }
}'
```

```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": "xianyu",
        "action": "search",
        "params": {
            "keyword": "iPhone 15",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-09-29T22:32:50Z. `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": "xianyu",
  "action": "search",
  "results": [
    {
      "item_id": "1089122948858",
      "url": "https://www.goofish.com/item?id=1089122948858",
      "title": "滋滋【福利疯抢】iPhone 15 盲盒随机打包手机、平板、电脑，九九新几乎全新，不指定、不挑选，完美主义者请勿下单，要求较多的急单的勿扰勿拍！ ✅ 评论区随心许愿，快递随机取件发货✅ 1人1单，邮费自理，请自觉下单✅ 客服回复不及时还请谅解！商品有在就都可以下单购买 宝宝",
      "price": 1.13,
      "currency": "CNY",
      "city": "重庆",
      "image_url": "https://img.alicdn.com/bao/uploaded/i1/2222991832241/O1CN01RndZ4wTqacI2Qw7p_!!4611686018427385009-0-xy_item.jpg",
      "want_count": 2,
      "tags": [
        "13小时前发布",
        "freeShippingIcon"
      ],
      "category_id": "50023914",
      "free_shipping": true,
      "is_auction": false,
      "has_video": false,
      "posted_at": "2026-09-29T09:02:03+00:00",
      "seller_name": "•••",
      "platform": "xianyu"
    },
    {
      "item_id": "1073624434319",
      "url": "https://www.goofish.com/item?id=1073624434319",
      "title": "出苹果15 iPhone15 国行256g 因为换手机了，太多了手机用不过来 随缘出，机况如图，电池77%这样 自己看哈",
      "price": 500,
      "currency": "CNY",
      "city": "上海",
      "image_url": "https://img.alicdn.com/bao/uploaded/i2/2222827391527/O1CN011onH6VJOZXL1jFqC_!!4611686018427382311-0-xy_item.jpg",
      "want_count": 270,
      "tags": [
        "Apple/苹果",
        "256GB",
        "无任何维修"
      ],
      "category_id": "50025386",
      "free_shipping": true,
      "is_auction": false,
      "has_video": false,
      "posted_at": "2026-08-12T13:09:19+00:00",
      "seller_name": "•••",
      "platform": "xianyu"
    }
  ],
  "count": 20,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 怎么判断一件闲置好不好卖？

看 `want_count`，它是点过「我想要」的人数，来自商品卡片上的「N人想要」，卡片没显示时为 null，不等于 0。结合 `posted_at` 看，发布不久想要人数就多的商品更抢手。

### 估二手价时要注意什么？

先剔除 `is_auction` 为真的拍卖商品，它们的 `price` 是当前出价；`original_price` 是卖家自己填的原价，可能不准。按型号和成色关键词分组后再看价格分布，结果更可靠。

### 卖家信息能拿到什么？

能拿到卖家 ID、头像、信用等级原文，以及卡片上的卖家标签；昵称会按闲鱼页面原样部分打码。想看某件商品的详情，可以把 `item_id` 交给闲鱼的商品详情能力。

## Also

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