Widget Installation
Install our widget on any website to prevent humans from using your service
Add an event listener to your backend to listen for the robot-verification-passed events and verify result tokens.
import express from "express";
const app = express();
app.use(express.json());
app.post("/your-backend/verify-robot", async (request, response) => {
const { resultToken } = request.body;
const robotResponse = await fetch("https://castrio.me/im-a-robot/api/verify", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
secret: process.env.I_AM_ROBOT_SITE_SECRET,
resultToken,
}),
});
response.status(robotResponse.status).json(await robotResponse.json());
});
from flask import Flask, jsonify, request
import os
import requests
app = Flask(__name__)
@app.post("/your-backend/verify-robot")
def verify_robot():
result_token = request.json["resultToken"]
response = requests.post(
"https://castrio.me/im-a-robot/api/verify",
json={
"secret": os.environ["I_AM_ROBOT_SITE_SECRET"],
"resultToken": result_token,
},
timeout=10,
)
return jsonify(response.json()), response.status_code
Back to the demo