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.

first call
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.

Keys are tenant-scoped. Never ship a key to the browser; call the API from your server and pass the client IP and headers.
key format
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.

keycounts toward quotaloggeduse for
sk_test_…noyeslocal dev, CI, staging
sk_live_…yesyesproduction

POST /v1/verdict

POST/v1/verdict

Return a decision for one request. This is the only endpoint that consumes quota.

Body

fieldtyperequirednotes
ipstringyesClient IPv4. Pass the real peer address, not your proxy's.
user_agentstringnoVerbatim User-Agent header.
headersobjectnoAny of accept, accept-language, sec-ch-ua, sec-ch-ua-mobile.
clientobjectnoBrowser signals from the JS SDK: canvas hash, fonts, timezone, webdriver, PoW token.
policyobjectnoPer-request overrides; see Policies.
request
{
  "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

200 OK
{
  "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

decisionmeaningrecommended action
allowLow risk, verified crawler, or whitelisted residential/mobile.Serve the request.
challengeScore between the challenge and block thresholds.Issue a PoW challenge (§ /v1/challenge) instead of a hard block.
blockPolicy 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

POST/v1/challenge— free, not metered

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.

response
{
  "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.

solving
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 / bits
The token binds to the /24, not the single IP, because mobile carriers rotate addresses inside a CGNAT pool. That avoids breaking real users mid-session; the trade-off is a 5-minute replay window inside one /24.

POST /v1/feedback

POST/v1/feedback— free, not metered

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
{ "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

GET/v1/health

Dataset freshness and ruleset version. Poll it from your own status page; no key required.

response
{ "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.

fielddefaulteffect
block_tortrueBlock IPs on the Tor bulk exit list.
block_vpntrueBlock ASNs classified as commercial VPN.
block_hostingtrueBlock datacenter / cloud / hosting ASNs.
allow_crawlerstrueAllow verified crawlers (rDNS + forward confirm).
allow_residentialtrueAllow residential/mobile ASNs by default, unless a high-confidence bot signal fires.
challenge_threshold35Score at which a request becomes challenge.
block_threshold70Score 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

codeweightmeaning
ip.tor_exit+90IP is a Tor exit node.
ip.datacenter_asn+45ASN is hosting / cloud / datacenter.
ip.vpn_asn+45ASN is a commercial VPN provider.
ip.residential_or_mobile−25Residential ISP or mobile carrier (trusted).
crawler.verified−40Crawler confirmed by rDNS and forward DNS.
crawler.spoofed+85Claims a crawler, verification failed.
ua.tool_signature+50UA matches curl, requests, python, Go, headless…
hdr.sec_ch_ua_missing+30Chrome UA without Client Hints.
hdr.sec_ch_ua_headless+40Client Hints advertise HeadlessChrome.
hdr.mobile_mismatch+25Mobile hint with desktop UA.
hdr.accept_language_missing+15No Accept-Language.
hdr.accept_missing+20No Accept header.
hdr.http1_modern_browser+12Modern Chrome UA over HTTP/1.1.
js.webdriver+55navigator.webdriver or headless hint.
js.geo_mismatch+25Browser locale region ≠ IP country.
js.low_font_count+30Fewer than 5 fonts exposed.
js.challenge_solved−20Valid signed proof-of-work.
js.challenge_failed+45Forged, 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:

headers
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:

402 Payment Required
{
  "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

statuserrorfix
400invalid request bodyCheck ip is a valid IPv4 string.
401invalid or revoked api keyUse a key from the dashboard; check for a trailing newline.
402quota_exceededUpgrade, or switch to a test key for integration traffic.
429rate_limitedBack off to the plan's rpm; retry after the header value.
503degraded_fail_openThe decision is allow with this reason; add a fallback path upstream.

Express middleware

server.js
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

app/api/signup/route.ts
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

auth_request
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

worker.js
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:

Handling false positives

  1. Log request_id with every block. Support can look up the exact decision.
  2. Send /v1/feedback with truth: "human" — the IP/ASN is allowlisted for you within a minute.
  3. Prefer challenge over block on login and checkout: a false positive costs one interaction instead of a sale.
  4. Residential and mobile ASNs pass by default. Only a high-confidence bot signal overrides them — header gaps alone never do.

Known limits

Sell and document decisions as risk with reasons, not guarantees. Any vendor promising 100% bot detection is describing a future outage.