Active bot enforcement. Server-side. Three lines of code.
Copy the code below into your server. Python, Node.js, or Vercel Edge.
Every request is checked against 172+ bot conduct scores. Bad bots get blocked automatically.
The middleware fails open — if the BCS API is unreachable, the request passes through. Your site never goes down because of us.
Requirements: pip install requests
"""BCS Pro Middleware"""
import requests
BCS_API_KEY = "YOUR_API_KEY"
BCS_URL = "https://botconduct.org/api/score"
def bcs_check(request):
try:
r = requests.post(BCS_URL, json={
"ua": request.headers.get("User-Agent", ""),
"ip": request.remote_addr,
"path": request.path,
"api_key": BCS_API_KEY
}, timeout=0.2)
return r.json()
except:
return {"action": "allow"} # fail open
# Flask usage:
# @app.before_request
# def check_bots():
# verdict = bcs_check(request)
# if verdict["action"] == "block":
# return "Access denied", 403
# if verdict["action"] == "throttle":
# return "Rate limited", 429
No dependencies required (uses native fetch).
const BCS_API_KEY = "YOUR_API_KEY";
async function bcsMiddleware(req, res, next) {
try {
const r = await fetch("https://botconduct.org/api/score", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
ua: req.headers["user-agent"] || "",
ip: req.ip,
path: req.path,
api_key: BCS_API_KEY
}),
signal: AbortSignal.timeout(200)
});
const verdict = await r.json();
if (verdict.action === "block")
return res.status(403).send("Access denied by BCS");
if (verdict.action === "throttle")
return res.status(429).send("Rate limited");
req.bcsVerdict = verdict;
next();
} catch {
next(); // fail open
}
}
module.exports = bcsMiddleware;
// Usage:
// const bcsMiddleware = require("./bcs_middleware");
// app.use(bcsMiddleware);
Save as middleware.js in your project root.
export default async function middleware(req) {
try {
const verdict = await fetch("https://botconduct.org/api/score", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
ua: req.headers.get("user-agent") || "",
ip: req.headers.get("x-forwarded-for") || "",
path: new URL(req.url).pathname,
api_key: "YOUR_API_KEY"
})
}).then(r => r.json());
if (verdict.action === "block")
return new Response("Blocked by BCS", { status: 403 });
if (verdict.action === "throttle")
return new Response("Rate limited", {
status: 429,
headers: { "Retry-After": "60" }
});
} catch {}
}
Send a JSON body with the visitor's details. Get back a verdict in <100ms.
{
"ua": "Mozilla/5.0 ... GPTBot/1.3 ...",
"ip": "74.7.241.33",
"path": "/api/products",
"api_key": "bcs-xxxxx"
}
{
"bot": true,
"bot_name": "GPTBot",
"operator": "OpenAI",
"score": 0,
"rating": "hostile",
"action": "block",
"certified": false,
"cert_level": 0
}
Free tier: 5,000 calls/month. Pro: 50,000 calls/month for $99.