← Changelog
NewApps

One visitor can't use up an app's calls

Records API calls are now counted per caller as well as per environment: 20 a second with bursts of 300 for each signed-in user, customer, or signed-out visitor's IP. A scraper or a script in a loop gets 429s on its own while everyone else carries on, where before it could take the environment's whole allowance and run up its bill.

The caller is the user or customer the call is made for (api.asRole with a userId, a Shopify session), or the visitor's IP as the app's records route passes it. For anything else, api.asCaller(key) names one: an API customer's id, a device. A caller turned away shows in Logs as Rate limited, once a minute, and doesn't count as a production failure.

For limits of the app's own there is api.rateLimit(key, { limit, windowSeconds }), which counts a call and answers whether it is within the limit: five contact messages an hour per IP, ten exports a day per user. It works in pages, routes and actions, and in the test harness. The app's own code calling with its environment token is unaffected.

The SDK calls are in @inferencebureau/apps-sdk 0.16.8. Apps built on Inference Bureau have them already.

More in Limits per caller.