# API 文档 调用标准验证、会话凭证、JS 反混淆 API 及配置 MCP 所需的全部说明。 https://astify.dev/zh/docs ## 概览 Astify 是一套按能力抽象的 REST API。通过 HTTPS 向 `https://api.astify.dev` 发送 JSON,支持 `Authorization: Bearer ` 或 `x-api-key` 鉴权,并从响应头实时获取本次费用与余额。 目前提供三个核心端点:`/v1/token` 获取标准验证 Token,`/v1/clearance` 获取绑定代理的会话凭证,`/v1/deobfuscate` 还原混淆后的 JavaScript 代码。 - POST /v1/token: 标准验证 (/v1/token) - POST /v1/clearance: 会话凭证 (/v1/clearance) - POST /v1/deobfuscate: JS 反混淆 (/v1/deobfuscate) ## 鉴权 在控制台创建 API Key,并在请求头通过 `Authorization: Bearer ` 或 `x-api-key: ` 发送。请仅在服务端使用和保存密钥。 ``` Authorization: Bearer $ASTIFY_API_KEY x-api-key: $ASTIFY_API_KEY ``` ## 标准验证 (/v1/token) POST https://api.astify.dev/v1/token 返回单次有效的标准验证 Token(`POST /v1/token`,兼容别名 `POST /v1/turnstile`)。支持系统默认网络出口(10 积分 / $5.00 每千次)与自带代理(9 积分 / $4.50 每千次)。 ### 参数 - sitekey (string, 必填): Turnstile 组件的 sitekey(例如 `0x4AAAAAAABS7vwvV6VFfMcD`)。 - url (string, 必填): 加载验证组件的完整页面 URL。 - proxy (string, 可选): 可选自定义代理(`http://user:pass@host:port`、`socks5://...`)。传入代理按较低档 9 积分计费($4.50/千次)。 - action (string, 可选): 目标站点配置的可选 `action` 参数。 - cData (string, 可选): 目标站点配置的可选 `cData` 参数。 ### 请求 cURL ``` curl -X POST https://api.astify.dev/v1/token \ -H "Authorization: Bearer $ASTIFY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "sitekey": "0x4AAAAAAABS7vwvV6VFfMcD", "url": "https://example.com/login" }' ``` Python ``` import os import requests API_KEY = os.environ["ASTIFY_API_KEY"] resp = requests.post( "https://api.astify.dev/v1/token", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "sitekey": "0x4AAAAAAABS7vwvV6VFfMcD", "url": "https://example.com/login", }, timeout=180, ) resp.raise_for_status() data = resp.json() print("credits used:", resp.headers.get("X-Astify-Cost")) print("token:", data["token"][:32] + "...") ``` Node.js ``` const apiKey = process.env.ASTIFY_API_KEY; const res = await fetch("https://api.astify.dev/v1/token", { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, body: JSON.stringify({ sitekey: "0x4AAAAAAABS7vwvV6VFfMcD", url: "https://example.com/login", }), }); const data = await res.json(); console.log("credits used:", res.headers.get("x-astify-cost")); console.log("token:", data.token); ``` Go ``` package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" "os" "time" ) func main() { payload, _ := json.Marshal(map[string]any{ "sitekey": "0x4AAAAAAABS7vwvV6VFfMcD", "url": "https://example.com/login", }) req, _ := http.NewRequest("POST", "https://api.astify.dev/v1/token", bytes.NewReader(payload)) req.Header.Set("Authorization", "Bearer "+os.Getenv("ASTIFY_API_KEY")) req.Header.Set("Content-Type", "application/json") client := &http.Client{Timeout: 180 * time.Second} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println("credits:", resp.Header.Get("X-Astify-Cost")) fmt.Println(string(body)) } ``` ### 响应 ```json { "success": true, "ok": true, "token": "0.aB3dEf9gHiJkLmNoPqRsTuVwXyZ…(1024 chars)", "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", "proxyMode": "managed", "requiresIpConsistency": false, "tookMs": 3420 } ``` ### 返回字段 - success (boolean): 成功拿到 Token 时为 `true`。`false` 不扣积分。 - token (string): 单次有效的验证 Token(约 5 分钟内有效)。 - userAgent (string): 本次验证使用的 User-Agent。 - proxyMode ("own" | "managed"): 传入 `proxy` 为 `own`,使用系统默认出口为 `managed`。 - requiresIpConsistency (boolean): `/v1/token` 恒为 `false`。 - tookMs (number): 端到端耗时(毫秒)。 ## 会话凭证 (/v1/clearance) POST https://api.astify.dev/v1/clearance 返回 `cf_clearance` 会话 Cookie 与绑定的 `userAgent`(`POST /v1/clearance`)。强制校验传入自定义 `proxy` 以保证请求指纹、出口 IP 与 UA 一致,固定 10 积分($5.00 每千次)。 ### 参数 - url (string, 必填): 需要获取 `cf_clearance` 的受保护页面 URL。 - proxy (string, 必填): 必填自定义代理(`http://user:pass@host:port`、`socks5://...`),用于保证后续请求指纹、出口 IP 与 UA 一致。 ### 请求 cURL ``` curl -X POST https://api.astify.dev/v1/clearance \ -H "Authorization: Bearer $ASTIFY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/", "proxy": "http://user:pass@198.51.100.7:8080" }' ``` Python ``` import os import requests API_KEY = os.environ["ASTIFY_API_KEY"] resp = requests.post( "https://api.astify.dev/v1/clearance", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "url": "https://example.com/", "proxy": "http://user:pass@198.51.100.7:8080", }, timeout=180, ) resp.raise_for_status() data = resp.json() print("credits used:", resp.headers.get("X-Astify-Cost")) # Reuse the EXACT same proxy and returned userAgent with cf_clearance: proxy = "http://user:pass@198.51.100.7:8080" session = requests.Session() session.proxies = {"http": proxy, "https": proxy} session.headers["User-Agent"] = data["userAgent"] session.cookies.set("cf_clearance", data["cf_clearance"], domain="example.com") page = session.get("https://example.com/") ``` Node.js ``` const apiKey = process.env.ASTIFY_API_KEY; const res = await fetch("https://api.astify.dev/v1/clearance", { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, body: JSON.stringify({ url: "https://example.com/", proxy: "http://user:pass@198.51.100.7:8080", }), }); const data = await res.json(); console.log("credits used:", res.headers.get("x-astify-cost")); // Reuse the exact same proxy and data.userAgent on every request carrying data.cf_clearance. console.log("cf_clearance:", data.cf_clearance); ``` Go ``` package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" "os" "time" ) func main() { payload, _ := json.Marshal(map[string]any{ "url": "https://example.com/", "proxy": "http://user:pass@198.51.100.7:8080", }) req, _ := http.NewRequest("POST", "https://api.astify.dev/v1/clearance", bytes.NewReader(payload)) req.Header.Set("Authorization", "Bearer "+os.Getenv("ASTIFY_API_KEY")) req.Header.Set("Content-Type", "application/json") client := &http.Client{Timeout: 180 * time.Second} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println("credits:", resp.Header.Get("X-Astify-Cost")) fmt.Println(string(body)) } ``` ### 响应 ```json { "success": true, "ok": true, "cf_clearance": "q7Yw0mJ1c2V…xNzMxNTg1NjAw-1.2.1.1", "cookies": { "cf_clearance": "q7Yw0mJ1c2V…xNzMxNTg1NjAw-1.2.1.1" }, "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", "proxyMode": "own", "requiresIpConsistency": true, "tookMs": 5180 } ``` ### 返回字段 - success (boolean): 拿到凭证时为 `true`。`false` 不扣积分。 - cf_clearance (string): 需设置到目标域名下的 `cf_clearance` Cookie 值。 - cookies (object): 返回的完整会话 Cookie 字典(包含 `cf_clearance`)。 - userAgent (string): 与 `cf_clearance` 绑定的精确 User-Agent,后续请求必须一致。 - proxyMode ("own"): `/v1/clearance` 恒为 `own`。 - requiresIpConsistency (boolean): 恒为 `true` —— 后续请求必须复用同一代理 IP 与 `userAgent`。 - tookMs (number): 端到端耗时(毫秒)。 ### IP 与 UA 一致性 requiresIpConsistency: true 会话凭证 Cookie 严格绑定到完成验证时的出口 IP、User-Agent 与指纹。 - `/v1/clearance` 强制校验必填 `proxy` 参数 —— 未传代理会直接返回 HTTP `400`(`proxy_required`),不扣费。 - 后续每个带 `cf_clearance` 的请求都必须复用同一个静态/粘性代理,并携带响应返回的 `userAgent`。 - 避免在获取凭证与业务请求之间使用动态轮换 IP 的代理。 ## JS 反混淆 (/v1/deobfuscate) POST https://api.astify.dev/v1/deobfuscate 将混淆 JavaScript 还原为可读源码,按代码行数、复杂度系数与混淆特征动态计费,单文件最低 2,000 积分($1.00)起。 ### 参数 - code (string, 必填): JavaScript 源码,最大 30 MB。 ### 请求 cURL ``` curl -X POST https://api.astify.dev/v1/deobfuscate \ -H "Authorization: Bearer $ASTIFY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "code": "var _0x4a2b=[\"\\x6c\\x6f\\x67\"];console[_0x4a2b[0]](\"hi\");" }' ``` Python ``` import os import requests API_KEY = os.environ["ASTIFY_API_KEY"] resp = requests.post( "https://api.astify.dev/v1/deobfuscate", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "code": "var _0x4a2b=[\"\\x6c\\x6f\\x67\"];console[_0x4a2b[0]](\"hi\");", }, timeout=180, ) resp.raise_for_status() data = resp.json() print("credits used:", resp.headers.get("X-Astify-Cost")) print(data["code"]) ``` Node.js ``` const apiKey = process.env.ASTIFY_API_KEY; const res = await fetch("https://api.astify.dev/v1/deobfuscate", { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, body: JSON.stringify({ code: "var _0x4a2b=[\"\\x6c\\x6f\\x67\"];console[_0x4a2b[0]](\"hi\");", }), }); const data = await res.json(); console.log("credits used:", res.headers.get("x-astify-cost")); console.log(data.code); ``` Go ``` package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" "os" "time" ) func main() { payload, _ := json.Marshal(map[string]any{ "code": "var _0x4a2b=[\"\\x6c\\x6f\\x67\"];console[_0x4a2b[0]](\"hi\");", }) req, _ := http.NewRequest("POST", "https://api.astify.dev/v1/deobfuscate", bytes.NewReader(payload)) req.Header.Set("Authorization", "Bearer "+os.Getenv("ASTIFY_API_KEY")) req.Header.Set("Content-Type", "application/json") client := &http.Client{Timeout: 180 * time.Second} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println("credits:", resp.Header.Get("X-Astify-Cost")) fmt.Println(string(body)) } ``` ### 响应 ```json { "success": true, "code": "console.log(\"hi\");", "bytesIn": 58, "bytesOut": 19, "credits": 2000 } ``` ### 返回字段 - success (boolean): 得到可读源码时为 `true`。`false` 的响应扣 0 积分。 - code (string): 可读的源码。 - bytesIn (number): 输入字节数。 - bytesOut (number): 输出字节数。 - credits (number): 按复杂度动态扣除的积分(最低 2,000 积分)。 ## MCP(Model Context Protocol)接入 通过 `https://astify.dev/mcp` 将 Astify 接入 Claude Desktop、Cursor 或 Claude Code。支持直接使用控制台 API Key(`Authorization: Bearer `)或 OAuth 2.1 认证。 Claude Desktop (claude_desktop_config.json): ```json { "mcpServers": { "astify": { "command": "npx", "args": [ "-y", "mcp-remote", "https://astify.dev/mcp", "--header", "Authorization: Bearer " ] } } } ``` Cursor / Claude Code (Streamable HTTP): ```json { "mcpServers": { "astify": { "type": "http", "url": "https://astify.dev/mcp", "headers": { "Authorization": "Bearer " } } } } ``` ## 计费响应头 无论调用成功与否,每个响应都带有两个响应头。 - X-Astify-Cost: 本次调用扣除的积分。调用失败时为 0。 - X-Astify-Balance: 本次调用后余额里剩余的积分。 ## 错误 错误使用标准 HTTP 状态码,响应体为 JSON,包含 `success: false` 和一个 `error` 对象。失败的调用不会扣费。 - 400: 请求体不是合法 JSON、缺少必填字段,或 `/v1/clearance` 未传 `proxy`(`proxy_required`)。 - 401: API Key 缺失或无效。 - 402: 积分不足。在控制台通过加密货币充值后重试。 - 422: 请求参数格式校验失败。 - 424: 上游求解失败。不扣费(0 积分),可以直接重试。 - 429: 同时进行的请求超出并发上限。等待 `Retry-After` 给出的秒数后重试。 ## 并发 每个账户对同时进行的请求数有上限:默认 2 个,购买并发包后更高。超出上限的请求会收到 `429`,并带有 `Retry-After` 响应头给出需要等待的秒数。 - 所有账户: 2 - 并发 10: $29 / 月 - 并发 25: $99 / 月 ## 积分 通过加密货币(NOWPayments)按量充值积分,全平台通用。无订阅制,永不过期,调用失败不收费($1 = 2,000 积分)。 - $10: 20,000 积分, $0.50 / 1,000 积分 - $50: 140,000 积分, $0.36 / 1,000 积分 - $200: 880,000 积分, $0.23 / 1,000 积分 - JavaScript 反混淆, 0–5,000 行: 2,000 credits - JavaScript 反混淆, 5,000–10,000 行: 3,000 credits - JavaScript 反混淆, 10,000+ 行: 6,000 credits https://astify.dev/zh/pricing ## 4. 可接受的使用 不得用于抢票、批量注册账户、撞库或登录金融账户。 https://astify.dev/zh/terms