Everyone is trying to block AI scrapers. I decided to tax them. I built Tollgate, a Node.js middleware that forces AI Agents to pay $1.00 USD to access premium data. The Stack:
Node.js & Express
JWT for authentication
CoinDesk API for data
Render for hosting const axios = require('axios');
// ๐ด PASTE YOUR RENDER URL HERE (No slash at the end)
const BASE_URL = "https://tollgate-live-1.onrender.com";
async function verifyTheGold() {
console.log(๐ฏ Target: ${"https://tollgate-live-1.onrender.com"});
try {
// STEP 1: Pay $1.00
console.log("1. ๐ธ Sending $1.00 Premium Payment...");
const payResponse = await axios.post(`${BASE_URL}/pay`, {
agent_id: "Big-Spender-Bot",
amount: 1.00 // <--- UPDATED PRICE
});
const token = payResponse.data.access_token;
console.log(" โ
Payment Accepted! Token received.");
// STEP 2: Get Data
console.log("2. ๐ Accessing Premium Vault...");
const goldResponse = await axios.get(`${BASE_URL}/premium-data`, {
headers: { 'Authorization': token }
});
// STEP 3: Result
console.log("\n ๐ SUCCESS! DATA RECEIVED:");
console.log(" ========================================");
console.log(" ITEM: " + goldResponse.data.item);
console.log(" PRICE: " + goldResponse.data.price);
console.log(" ========================================");
} catch (error) {
console.error("\nโ FAILED.");
if (error.response) {
console.error(" Server Message:", error.response.data);
} else {
console.error(" Error:", error.message);
}
}
}
verifyTheGold(); Live Demo: You can try hitting the API here: https://tollgate-live-1.onrender.com
Let me know what you think of this architecture!
Tags: #javascript, #showdev, #ai, #node.
Top comments (0)