---
title: "Request"
description: "向公开网站发送你自己的 HTTP 请求（方法、请求头、请求体），原样取回网站的状态、响应头和响应体。"
---

> Every apinoa docs page as markdown: https://apinoa.com/llms.txt (all in one file: https://apinoa.com/llms-full.txt; this API family in one file: https://apinoa.com/docs/web/llms.txt)

```http
POST /v1/unlocker/request
```

参数以 JSON 请求体发送（`Content-Type: application/json`）。`headers` 是请求头名称到值的 JSON 对象，`body` 是字符串。
`x-api-key` 请求头是你的 apinoa 密钥；请求体中的 `headers` 才是网站收到的请求头。

## 请求

用你自己的令牌以 JSON `POST` 调用一个 API：

```bash tab="cURL"
curl -X POST "https://gateway.apinoa.com/v1/unlocker/request" \
  -H "x-api-key: $APINOA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://httpbin.org/anything?q=shoes",
    "method": "POST",
    "headers": { "content-type": "application/json", "authorization": "Bearer YOUR_TOKEN" },
    "body": "{\"q\":\"shoes\"}"
  }'
```

```js tab="JavaScript"
const res = await fetch("https://gateway.apinoa.com/v1/unlocker/request", {
  method: "POST",
  headers: { "x-api-key": process.env.APINOA_API_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    url: "https://httpbin.org/anything?q=shoes",
    method: "POST",
    headers: { "content-type": "application/json", authorization: "Bearer YOUR_TOKEN" },
    body: JSON.stringify({ q: "shoes" }),
  }),
});
const { success, data, error } = await res.json();
```

```python tab="Python"
import json
import os

import requests

res = requests.post(
    "https://gateway.apinoa.com/v1/unlocker/request",
    json={
        "url": "https://httpbin.org/anything?q=shoes",
        "method": "POST",
        "headers": {"content-type": "application/json", "authorization": "Bearer YOUR_TOKEN"},
        "body": json.dumps({"q": "shoes"}, separators=(",", ":")),
    },
    headers={"x-api-key": os.environ["APINOA_API_KEY"]},
)
body = res.json()
```

## 参数

| Parameter | Type | Required | Notes |
|---|---|---|---|
| `url` | string | yes | The address to request (http or https). |
| `body` | string |  |  |
| `bodyEncoding` | enum |  | `text` `base64` |
| `country` | enum |  | `US` |
| `followRedirects` | boolean |  |  |
| `headers` | object |  | Headers to send, as given. A real browser's own headers replace User-Agent, sec-ch-ua*, Accept-Encoding, Host, Connection and Content-Length. |
| `method` | enum |  | `GET` `POST` `PUT` `PATCH` `DELETE` `HEAD` |
| `profile` | enum |  | Which kind of browser to present: desktop or mobile. Absent: either. `desktop` `mobile` |

The same parameters, and every response type, are in the OpenAPI document: https://apinoa.com/openapi.json

- `body` 最大 2 MiB，`GET` 或 `HEAD` 请求不能带请求体。二进制数据请转为 base64，并设置 `bodyEncoding: "base64"`。
- `profile` 选择以哪类浏览器发送请求：`desktop` 或 `mobile`。省略时由我们选择，网站拒绝时会更换。
- 最多 50 个请求头。

## 发送的内容

你传入的请求头都会发送，但构成浏览器身份的请求头会替换为真实浏览器自己的值：与请求其余部分不一致的值，是网站拒绝请求最常见的原因。

| 请求头 | 处理方式 |
|---|---|
| `User-Agent`、`sec-ch-ua*` | 替换为浏览器自己的值 |
| `Accept-Encoding` | 替换。响应体解压后返回 |
| `Host`、`Content-Length` | 根据 `url` 和 `body` 设置 |
| `Connection`、`Keep-Alive`、`Transfer-Encoding`、`TE`、`Upgrade`、`Proxy-Authorization`、`Proxy-Connection` | 不发送 |
| 其他所有请求头（`Authorization`、`Cookie`、`Content-Type`、`Accept`、你自定义的 `X-*`） | 按你所写发送 |

默认跟随重定向；`followRedirects` 为 `false` 时直接返回 `3xx` 响应本身。重定向到其他源（协议、主机或端口不同）时，不会带上你的
`Authorization` 和 `Cookie` 请求头。`303`，以及对 `POST`、`PUT`、`PATCH`、`DELETE` 的 `301`、`302`，会像浏览器一样改用不带请求体的
`GET` 跟随。

## 响应

在 `data` 中返回 [`UnlockResult`](/docs/api-reference/web-data/response-schema#unlockresult)。 一个真实响应的完整内容：httpbin
会原样回显它收到的请求，因此 `body` 中可以看到网站收到了什么（`origin` 中的地址已替换为文档专用地址）。

```json
{
  "success": true,
  "data": {
    "status": 200,
    "url": "https://httpbin.org/anything?q=shoes",
    "headers": {
      "Access-Control-Allow-Credentials": "true",
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Expose-Headers": "Retry-After, RateLimit, RateLimit-Policy, WWW-Authenticate",
      "Content-Type": "application/json",
      "Date": "Fri, 20 Nov 2026 09:42:23 GMT",
      "X-Content-Type-Options": "nosniff"
    },
    "body": "{\n  \"args\": {\n    \"q\": \"shoes\"\n  },\n  \"headers\": {\n    \"Accept\": \"application/json\",\n    \"Accept-Encoding\": \"gzip, deflate, br, zstd\",\n    \"Accept-Language\": \"en-US,en;q=0.9\",\n    \"Authorization\": \"Bearer YOUR_TOKEN\",\n    \"Cache-Control\": \"no-cache\",\n    \"Content-Length\": \"13\",\n    \"Content-Type\": \"application/json\",\n    \"Host\": \"httpbin.org\",\n    \"Pragma\": \"no-cache\",\n    \"Priority\": \"u=1, i\",\n    \"Sec-Ch-Ua\": \"\\\"Not;A=Brand\\\";v=\\\"8\\\", \\\"Chromium\\\";v=\\\"150\\\", \\\"Google Chrome\\\";v=\\\"150\\\"\",\n    \"Sec-Ch-Ua-Mobile\": \"?0\",\n    \"Sec-Ch-Ua-Platform\": \"\\\"Windows\\\"\",\n    \"Sec-Fetch-Dest\": \"empty\",\n    \"Sec-Fetch-Mode\": \"cors\",\n    \"Sec-Fetch-Site\": \"same-origin\",\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36\"\n  },\n  \"method\": \"POST\",\n  \"origin\": \"203.0.113.7\",\n  \"url\": \"https://httpbin.org/anything?q=shoes\",\n  \"data\": \"{\\\"q\\\":\\\"shoes\\\"}\",\n  \"files\": {},\n  \"form\": {},\n  \"json\": {\n    \"q\": \"shoes\"\n  }\n}\n",
    "bodyEncoding": "text"
  }
}
```

## 错误

| 状态 | 代码 | 含义 |
|---|---|---|
| 400 | `INVALID_PARAMS` | 参数缺失、未知或超出范围：`url` 不是 http/https 地址、`GET` 或 `HEAD` 带了 `body`、`base64` 请求体不是 base64、请求体超过 2 MiB、请求头超过 50 个；或主机被拒绝（见下文）。消息中会说明原因。 |
| 400 | `UPSTREAM_TOO_LARGE` | 网站的响应大于 10 MiB。 |
| 400 | `INVALID_PARAMS` | 网站的 TLS 证书无法验证（每次请求都会检查）。消息中会给出主机名。 |
| 401 | `UNAUTHORIZED` | 缺少 `x-api-key` 请求头，或密钥已吊销或未知。 |
| 402 | `INSUFFICIENT_CREDITS` | 积分不足以支付本次调用。请在控制台选择套餐或充值。 |
| 404 | `NOT_FOUND` | 网站不存在或拒绝连接：域名无法解析，或没有服务接受连接。消息中会给出主机名。 |
| 429 | `MARKETPLACE_SATURATED` | 并发调用过多。请等待 `Retry-After` 秒后重试。 |
| 503 | `UPSTREAM_UNAVAILABLE` | 每次尝试网站都停留在机器人验证。请稍后重试。 |

全部错误代码见 [Errors](/docs/errors)。失败的调用不计费。

### 被拒绝的主机

以下主机无论在首次请求还是任何一次重定向中，都会以 `INVALID_PARAMS` 拒绝：

- **apinoa API 已覆盖的网站。** Amazon、Walmart、TikTok Shop、AliExpress、Reddit、LinkedIn、TikTok、YouTube、Threads、X、
  Instagram、Facebook、Google（搜索、Shopping、Play、Trends、Gemini）、Bing、Copilot、Naver、Daum、Yahoo 搜索、Yahoo! JAPAN、
  Yandex、Baidu、Sogou、Seznam、DuckDuckGo、Tripadvisor、App Store、ChatGPT、豆包和 Qwen，以及它们的图片和视频主机。消息中会指明应
  调用的 API，例如 `www.amazon.com is served by the amazon API — call /amazon/… instead of the unlocker`。
- **政府和军队网站**（`.gov`、`.mil`、`gov.uk`、`go.kr`、`europa.eu` 及其他国家的政府域名）。
- **私有和内部地址**（`localhost`、`10.0.0.0/8`、`192.168.0.0/16`、内部名称）。

## 价格

**价格** 响应体每开始一个 MiB 计 1 credit：1 MiB 以内的响应 1 credit，1.2 MiB 为 2 credits，最大的 10 MiB 为 10 credits。

## 说明

- **原样返回网站的响应。** 网站返回的 `404`、`500`，或普通的 `403`、`429`、`503`，都是网站的响应：连同 `status` 返回，并计费。
  机器人验证页则不同：被网站拦截的请求会自动重试，仍被拦截的返回 `UPSTREAM_UNAVAILABLE`，不计费。
- **文本或 base64。** 有效 UTF-8 的文本响应以文本形式放在 `body` 中；其他内容（图片、PDF、zip）以 base64 返回，并带
  `bodyEncoding: "base64"`。解码后与网站发送的字节完全一致。
- **不执行 JavaScript。** 响应就是网站服务器发送的内容。
- 始终校验 TLS 证书。`country` 只能为 `US`。
- 每种类型的字段见 [Response Schema](/docs/api-reference/web-data/response-schema)。
