Documentation
Everything needed to gate traffic with one HTTP call. Base URL:
https://api.botpanda.net
Quickstart
Create an account, copy a test key from the dashboard, and send your first request. Test keys are uncounted, so explore freely.
curl -s https://api.botpanda.net/v1/verdict \
-H "X-API-Key: sk_test_…" \
-H "Content-Type: application/json" \
-d '{"ip":"143.198.50.10","user_agent":"python-requests/2.32"}'Authentication
Every public API call needs an API key in the X-API-Key header. Keys are stored hashed — the full value is shown once at creation. Revoking a key is immediate.
sk_live_<43 chars> ← production traffic, counts against quota sk_test_<43 chars> ← integration traffic, never counted, never billed
Test vs live keys
The free tier includes 100 verdicts per day on live keys. Test keys are unlimited and free forever — the metered budget measures production traffic, not integration effort.
| key | counts toward quota | logged | use for |
|---|---|---|---|
sk_test_… | no | yes | local dev, CI, staging |
sk_live_… | yes | yes | production |
POST /v1/verdict
Return a decision for one request. This is the only endpoint that consumes quota.
Body
| field | type | required | notes |
|---|---|---|---|
ip | string | yes | Client IPv4. Pass the real peer address, not your proxy's. |
user_agent | string | no | Verbatim User-Agent header. |
headers | object | no | Any of accept, accept-language, sec-ch-ua, sec-ch-ua-mobile. |
client | object | no | Browser signals from the JS SDK: canvas hash, fonts, timezone, webdriver, PoW token. |
policy | object | no | Per-request overrides; see Policies. |
{
"ip": "203.0.113.42",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/141.0.0.0",
"headers": {
"accept": "text/html,application/xhtml+xml",
"accept-language": "en-US,en;q=0.9",
"sec-ch-ua": "\"Chromium\";v=\"141\"",
"sec-ch-ua-mobile": "?0"
},
"policy": { "block_vpn": true, "challenge_threshold": 35 }
}Response object
{
"request_id": "90a306a3fcc0cf8e",
"ip": "203.0.113.42",
"decision": "challenge",
"reason": "score >= challenge_threshold",
"score": 45,
"labels": { "tor": false, "vpn": false, "hosting": false, "crawler": "",
"crawler_verified": false, "spoofed_crawler": false, "bot": true },
"network_type": "business",
"asn": { "asn": 3320, "name": "Deutsche Telekom AG", "country": "DE" },
"signals": [
{ "code": "hdr.sec_ch_ua_headless", "weight": 40,
"detail": "sec-ch-ua advertises HeadlessChrome" }
],
"policy_applied": { "block_tor": true, "block_vpn": true, "block_hosting": true,
"allow_crawlers": true, "challenge_threshold": 35,
"block_threshold": 70 },
"ruleset_version": "2026.12.1",
"latency_ms": 0.06,
"ttl_seconds": 300,
"quota": { "plan": "free", "mode": "live", "limit": 100, "used": 7, "counted": true }
}Decision values
| decision | meaning | recommended action |
|---|---|---|
| allow | Low risk, verified crawler, or whitelisted residential/mobile. | Serve the request. |
| challenge | Score between the challenge and block thresholds. | Issue a PoW challenge (§ /v1/challenge) instead of a hard block. |
| block | Policy match or score ≥ block threshold. | Refuse with 403 and log reason. |
Honor ttl_seconds: cache the verdict per IP for that long (24 h for stable decisions, 5 min for challenges) instead of calling per request. This is what keeps your bill and your latency down.
POST /v1/challenge
Issue a proof-of-work challenge for an IP. The returned token is HMAC-signed, bound to the client /24 and expires in 5 minutes.
{
"seed": "b08cffc7c0aca22a",
"bits": 4,
"expires_at": 1767312345,
"expires_in": 300,
"token": "9f2c…c41.1767312345",
"instructions": "solve PoW: sha256(seed + ':' + nonce) must have leading zero bits"
} Solve it in the browser, then resubmit /v1/verdict with the solution in client. A valid solution subtracts 20 from the score; a forged or expired token adds 45.
let nonce = 0;
const zeros = "0".repeat(challenge.bits / 4);
while (true) {
const h = await sha256Hex(challenge.seed + ":" + nonce);
if (h.startsWith(zeros)) break;
nonce++;
}
// then: POST /v1/verdict with client.challenge_seed / nonce / token / bitsPOST /v1/feedback
Report ground truth for a decision. This is the most valuable call you can make: feedback is what tunes your rules and protects your own legitimate users.
{ "request_id": "90a306a3fcc0cf8e", "ip": "203.0.113.42",
"truth": "human", "notes": "real customer, support ticket #4412" }truth is human or bot. A human label on a blocked request queues an allowlist review and is applied to that IP/ASN within a minute.
GET /v1/health
Dataset freshness and ruleset version. Poll it from your own status page; no key required.
{ "ok": true, "ruleset_version": "2026.12.1", "tor_exits_loaded": 1287,
"asn_ranges_loaded": 540291, "crawler_signatures_loaded": 2143 }Policies
Every field is optional and overrides the tenant default for that request only.
| field | default | effect |
|---|---|---|
block_tor | true | Block IPs on the Tor bulk exit list. |
block_vpn | true | Block ASNs classified as commercial VPN. |
block_hosting | true | Block datacenter / cloud / hosting ASNs. |
allow_crawlers | true | Allow verified crawlers (rDNS + forward confirm). |
allow_residential | true | Allow residential/mobile ASNs by default, unless a high-confidence bot signal fires. |
challenge_threshold | 35 | Score at which a request becomes challenge. |
block_threshold | 70 | Score at which a request becomes block. |
Precedence is first-match: verified crawler allow → Tor → VPN → hosting → residential/mobile allow → score ≥ block → score ≥ challenge → allow. The residential allow is skipped when a high-confidence bot signal fires (crawler.spoofed, ua.tool_signature, hdr.sec_ch_ua_headless, js.webdriver, js.challenge_failed, hdr.ua_missing), so mild header gaps never block a real customer.
Reason codes
| code | weight | meaning |
|---|---|---|
ip.tor_exit | +90 | IP is a Tor exit node. |
ip.datacenter_asn | +45 | ASN is hosting / cloud / datacenter. |
ip.vpn_asn | +45 | ASN is a commercial VPN provider. |
ip.residential_or_mobile | −25 | Residential ISP or mobile carrier (trusted). |
crawler.verified | −40 | Crawler confirmed by rDNS and forward DNS. |
crawler.spoofed | +85 | Claims a crawler, verification failed. |
ua.tool_signature | +50 | UA matches curl, requests, python, Go, headless… |
hdr.sec_ch_ua_missing | +30 | Chrome UA without Client Hints. |
hdr.sec_ch_ua_headless | +40 | Client Hints advertise HeadlessChrome. |
hdr.mobile_mismatch | +25 | Mobile hint with desktop UA. |
hdr.accept_language_missing | +15 | No Accept-Language. |
hdr.accept_missing | +20 | No Accept header. |
hdr.http1_modern_browser | +12 | Modern Chrome UA over HTTP/1.1. |
js.webdriver | +55 | navigator.webdriver or headless hint. |
js.geo_mismatch | +25 | Browser locale region ≠ IP country. |
js.low_font_count | +30 | Fewer than 5 fonts exposed. |
js.challenge_solved | −20 | Valid signed proof-of-work. |
js.challenge_failed | +45 | Forged, expired or replayed challenge. |
Weights are additive from a base of 20 and clamped to 0–100. Codes and weights are versioned by ruleset_version.
Quotas & overage
Only /v1/verdict with a live key counts. Response headers carry your state:
X-Botpanda-Plan: free X-Botpanda-Mode: live X-Botpanda-Quota-Limit: 100 X-Botpanda-Quota-Remaining: 93 X-Botpanda-Quota-Reset: 51240 # seconds until 00:00 UTC X-Ruleset-Version: 2026.12.1
At the free cap you get HTTP 402 with a machine-readable upgrade body instead of a silent 403:
{
"error": "quota_exceeded",
"plan": "free", "limit": 100, "used": 100,
"upgrade": { "plan": "starter", "price_usd": 9, "volume": 100000,
"url": "/dashboard#billing" }
}Paid plans never hard-stop: requests over the included volume are billed as overage at the plan rate, and X-Botpanda-Quota-Remaining goes negative so you can alert on it.
Errors
| status | error | fix |
|---|---|---|
| 400 | invalid request body | Check ip is a valid IPv4 string. |
| 401 | invalid or revoked api key | Use a key from the dashboard; check for a trailing newline. |
| 402 | quota_exceeded | Upgrade, or switch to a test key for integration traffic. |
| 429 | rate_limited | Back off to the plan's rpm; retry after the header value. |
| 503 | degraded_fail_open | The decision is allow with this reason; add a fallback path upstream. |
Express middleware
import express from "express";
import { botpanda } from "@botpanda/express";
const app = express();
app.set("trust proxy", true);
app.use(botpanda({
apiKey: process.env.AB_KEY,
failOpen: true,
cacheTtl: 86400,
onBlock: (req, res, v) => res.status(403).json({ reason: v.reason, id: v.request_id }),
onChallenge: (req, res) => res.redirect("/verify"),
}));
app.post("/signup", (req, res) => res.json({ ok: true }));Next.js
import { NextResponse } from "next/server";
import { check } from "@botpanda/server";
export async function POST(req: Request) {
const ip = req.headers.get("x-forwarded-for")?.split(",")[0] ?? "";
const v = await check({ ip, headers: Object.fromEntries(req.headers) });
if (v.decision === "block") {
return NextResponse.json({ error: "blocked", id: v.request_id }, { status: 403 });
}
if (v.decision === "challenge") {
return NextResponse.json({ challenge: "/verify" }, { status: 202 });
}
// …create the account
}nginx
location = /_botpanda {
internal;
proxy_pass http://127.0.0.1:8099/v1/verdict;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-API-Key "sk_live_…";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Original-URI $request_uri;
}
location /checkout/ {
auth_request /_botpanda;
auth_request_set $ab_decision $upstream_http_x_botpanda_decision;
error_page 401 = @botpanda_blocked;
proxy_pass http://app;
}
location @botpanda_blocked { return 403; }Cloudflare Worker
export default {
async fetch(request, env, ctx) {
const ip = request.headers.get("CF-Connecting-IP");
const r = await fetch("https://api.botpanda.net/v1/verdict", {
method: "POST",
headers: { "X-API-Key": env.AB_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
ip,
user_agent: request.headers.get("user-agent") ?? "",
headers: { accept: request.headers.get("accept") ?? "" }
}),
cf: { cacheTtl: 86400 }
});
const v = await r.json();
if (v.decision === "block") return new Response("blocked", { status: 403 });
return fetch(request);
}
};Fail-open & outages
A protection API that takes your checkout offline is worse than the bots. Default behavior:
- Timeout budget: 150 ms. After that, serve the request.
- On 5xx or network failure, return
allowwithreason: "degraded_fail_open". - Cache the last good verdict per IP for
ttl_seconds; survive short outages entirely. - Fail-closed only if you explicitly set it, and only on routes where a wrong allow costs more than downtime (e.g. promo redemption).
Handling false positives
- Log
request_idwith every block. Support can look up the exact decision. - Send
/v1/feedbackwithtruth: "human"— the IP/ASN is allowlisted for you within a minute. - Prefer
challengeoverblockon login and checkout: a false positive costs one interaction instead of a sale. - Residential and mobile ASNs pass by default. Only a high-confidence bot signal overrides them — header gaps alone never do.
Known limits
- IPv4 only in the current dataset build.
- VPN detection is ASN-based: commercial VPNs leasing residential ranges are invisible to network layer checks.
- Residential proxies pass L1 by design. Catch them with the JS SDK layer, per-ASN velocity and account-level analysis.
- PoW tokens bind IP/24 + expiry, not the browser fingerprint — a 5-minute replay window exists inside one /24.
- Crawler verification needs outbound DNS from the API host; without it, verification falls back to published ranges.