For the complete documentation index, see llms.txt. This page is also available as Markdown.
Blocker
This guide shows how to add STOPBOT v2/Blocker to server-side applications in PHP, Node.js, Python, and Go.
The Blocker service helps identify whether a website visitor is a real user, bot, crawler, proxy, VPN, Tor exit node, suspicious hostname, or visitor matching your own allow/block rules.
Endpoint Used
GET https://api.stopbot.net/services/blocker
How It Works
Your application receives a visitor request.
The integration sends the visitor IP, user agent, and current URL to STOPBOT V2.
STOPBOT returns a decision.
Your application allows the visitor, redirects the visitor, or returns an HTTP error page.
Required Parameters
Parameter
Description
apikey
Your STOPBOT API key
ip
Visitor IP address
ua
Visitor user agent
url
Current requested URL
Security note: Keep your API key on the backend server. Do not publish it in browser-only JavaScript, mobile apps, or public repositories.
Proxy note: Only trust CF-Connecting-IP or X-Forwarded-For when your application is behind a trusted proxy such as Cloudflare or your own reverse proxy.
Decision Field
This guide uses the V2 response field:
If blockAccess is 1, the integration applies the configured block action.
Always use blockAccess as the allow/block decision field. Do not use isBot as the final access decision. isBot is a visitor classification signal, while blockAccess tells your integration whether the block action should be applied.
Common Actions
Action
Behavior
Monitor only
Send requests to STOPBOT and allow the visitor regardless of blockAccess
Redirect blocked visitors
Redirect when blockAccess is 1
Return 404 for blocked visitors
Return an HTTP 404 response when blockAccess is 1
Environment Variables
The examples use these environment variables:
Variable
Required
Description
STOPBOT_API_KEY
Yes
Your STOPBOT API key
STOPBOT_PROTECTION
No
Set to 0 for monitor-only mode. Any other value enables the block action
STOPBOT_REDIRECT_URL
No
Redirect target for blocked visitors. Leave empty to return 404
cURL Test
Use this request to test the endpoint before adding it to your application:
PHP
Create a file named:
Paste this code:
Add it to the top of your main PHP entry file:
Node.js
This example uses Express and the built-in fetch available in modern Node.js versions.
Create a file named:
Paste this code:
Call it as the first middleware in your main file:
Python
This example uses Flask and Python standard library HTTP utilities.
Create a file named:
Paste this code:
Call it near the top of your main Flask file before defining routes:
Go
This example uses the standard net/http package.
The middleware is registered once when the server starts, but it runs on every incoming visitor request. The reusable stopbotHTTPClient below is only the server-side HTTP client used to call the STOPBOT API.
Create a file named:
Paste this code:
Call it in your main.go before starting the server:
Test The Integration
Set STOPBOT_API_KEY in your server environment.
Start your application.
Open your website in a browser.
Confirm the page still loads normally.
Check your application logs for STOPBOT connection errors.
Open the STOPBOT panel and confirm visitor statistics are being recorded.
Recommended Failure Behavior
The examples above allow the visitor when the STOPBOT API request fails. This keeps your website available during temporary network or service issues.
If your security policy requires blocking on API failure, change the error branch carefully and test it in staging first.
Response Fields Used
Field
Usage
status
Confirms the API request was processed successfully
blockAccess
Main allow/block decision field
isBot
Visitor classification signal only. Do not use this field as the final allow/block decision