Paywall Any API Endpoint With Two Prices: Sats or Compute
You built an API. It works. Then the scrapers show up. Not paying customers. Bots hammering your endpoint a thousand times a minute, running up your compute bill, and giving you nothing back. The usual fix is API keys, a signup flow, a Stripe integration, a dashboard, and a support inbox for people who lost their key. That is a lot of plumbing to answer one question: did this caller give up…
Pay-to-Compute API Endpoint: Two Pricing Options for Protection Against Scrapers
API creators often face the challenge of unwanted scraping and bot traffic, leading to high compute costs and no return for their services. Traditional solutions involve setting up API keys, a signup flow, and a support system. However, this approach requires significant effort and can be cumbersome for users.
A simpler alternative is to implement a pay-to-compute model, where every API request incurs a cost. Callers can either pay a small amount in satoshis (sats) via a Lightning invoice or solve a compute-intensive proof-of-work puzzle. This model eliminates the need for accounts, keys, or dashboards, as the payment itself serves as authorization.
The gate.powforge.dev server demonstrates this two-price idea. Callers can choose either path to access the gated response. The compute path requires solving a SHA-256 partial collision, with difficulty adjustable based on server resources. The solution cost for the caller is the electricity consumed and the time spent solving the puzzle. The sats path involves settling a Lightning invoice for a fixed amount (10 sats, which amounts to a tenth of a cent).
Both payment methods grant the same access to the gated response, ensuring that no free-riding occurs. The server-side verification process is straightforward and requires minimal resources. It simply checks the provided proof-of-work solution against the predefined difficulty.
The pay-to-compute API offers a straightforward solution to protect against scrapers and bots without the need for complex authentication systems. The server-side verification is minimal, while the cost of compute or sats falls on the caller, making it an effective and lightweight protective measure for API providers.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.