Blocker v2
This guide shows how to add STOPBOT v2/Blocker v2 to server-side applications in PHP, Node.js, Python, and Go.
Blocker v2 is designed for advanced traffic filtering. It supports multiple configurations, request parameter checks, header checks, advertising bot detection, search engine handling, and configurable page responses.
Endpoint Used
GET https://api.stopbot.net/services/blockerv2How It Works
Your application receives a visitor request.
The integration sends the visitor IP, user agent, current URL, request parameters, request headers, and
confnameto STOPBOT v2.STOPBOT returns a flat decision response.
Your application applies
pageResponseTypeandpageResponseContentswhenblockAccessis1.
Required Parameters
apikey
Your STOPBOT API key
confname
Blocker v2 configuration name from the STOPBOT panel
ip
Visitor IP address
ua
Visitor user agent
url
Current requested URL
params
JSON object of request parameters
headers
JSON object of request headers
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-IPorX-Forwarded-Forwhen your application is behind a trusted proxy such as Cloudflare or your own reverse proxy.
Decision Fields
This guide uses these v2 response fields:
If status is success and blockAccess is 1, the integration applies the configured page response.
Always use blockAccess as the allow/block decision field. Do not use isBot as the final access decision. isBot only describes visitor classification, while blockAccess describes whether your configured page response must be applied.
For example, a normal human visitor can still be blocked by your configuration:
Page Response Types
None
Stay on the current page
RedirectURL
Redirect the visitor to pageResponseContents
HTTPStatusCode
Return the HTTP status code from pageResponseContents
Environment Variables
The examples use these environment variables:
STOPBOT_API_KEY
Yes
Your STOPBOT API key
STOPBOT_BLOCKERV2_CONFNAME
Yes
Blocker v2 configuration name from the STOPBOT panel
STOPBOT_PROTECTION
No
Set to 0 for monitor-only mode. Any other value enables the page response action
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 stopbotV2HTTPClient 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_KEYin your server environment.Set
STOPBOT_BLOCKERV2_CONFNAMEto a configuration name that exists in your STOPBOT panel.Start your application.
Open your website in a browser.
Confirm the page response behavior matches your Blocker V2 configuration.
Check visitor logs in the STOPBOT panel.
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
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
detectActivity
Optional reason field for logs or debugging
pageResponseType
Page response action type
pageResponseContents
Page response value
V1 Difference
Legacy V1 Blocker V2 examples use:
V2 uses flat fields:
Last updated