# DuckDuckGo 搜索 关键词搜索 API (duckduckgo.search)

- Canonical page: https://everyinfra.com/duckduckgo-api/search
- Endpoint: POST /api/v1/social with {"platform": "duckduckgo", "action": "search", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed and empty results are not charged
- Returns: list, default 20, max 50 per call
- 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=duckduckgo&action=search

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | DuckDuckGo 搜索词，最多 500 字；只收普通词，带英文双引号的精确短语和 site: 这类搜索指令会在扣费前被拒。 |
| country | not declared | no | not declared | 按哪个地区搜，两位国家代码（如 us、gb、de、jp），换成 DuckDuckGo 的地区设置；DuckDuckGo 不分地区的国家和不填时不限地区。 |
| language | not declared | no | not declared | 地区的语言版本，两位语言代码（如 加拿大的 en、fr），只在 country 有多个语言版本时生效，默认第一个。 |
| page | integer | no | not declared | 第几页，从 1 开始，每页 limit 条，最多 20 页。 |
| time_window | not declared | no | not declared | 只要这段时间内的网页：day、week、month、year；不填不限。 |
| limit | integer (1–50) | no | 20 | 这次调用最多返回的条数，整数，1–50；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| rank | 该结果在这次搜索结果里的名次，从 1 开始。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| url | 该记录在原平台上的可访问链接。 |
| displayed_url | 结果下方显示的网址（搜索引擎的显示写法，常省掉 https://），要打开用 url。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| favicon_url | 结果网站的小图标链接（经 DuckDuckGo 图标服务）。 |
| 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": "duckduckgo",
  "action": "search",
  "params": {
    "keyword": "python asyncio tutorial"
  }
}'
```

```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": "duckduckgo",
        "action": "search",
        "params": {
            "keyword": "python asyncio tutorial",
        },
    },
    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": "duckduckgo",
  "action": "search",
  "results": [
    {
      "rank": …,
      "title": …,
      "url": …,
      "displayed_url": …,
      "text": …,
      "favicon_url": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## Also

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