Code and HTTP: Rate-Limited API Caller Template
Build a Spojit workflow that loops through a list of items, calls a third-party REST API for each one, and paces the requests with a short delay so you stay under the API's rate limit.
What It Builds
This template uses a Manual trigger that takes a list of items to process. A Loop node iterates the list one item at a time, a Connector node on the http connector calls the external API for each item with http-post (or http-get), and a Connector node on the code connector runs a small execute-javascript delay between iterations. The result is bulk API calls that drip out at a steady pace instead of bursting all at once and getting throttled with 429 responses.
The Prompt
Paste this into Miraxa and it builds the workflow, connecting the tools for you:
Build a workflow with a Manual trigger that accepts a list of items. Add a Loop node that iterates the list one item at a time. Inside the loop, add a Connector node on the http connector that sends an http-post request to https://api.example.com/v1/items for the current item, then add a Connector node on the code connector that runs a short execute-javascript delay of 250 milliseconds before the next iteration so the calls stay under the API rate limit.
Connectors Used
- http - calls the external REST API for each item with
http-post,http-get, or anotherhttp-*tool, passing your API key in theAuthorizationheader. Started by a Manual trigger. - code - runs an
execute-javascriptstep that waits a fixed number of milliseconds between iterations, so requests are spaced out evenly.
Customize It
Change the API URL and HTTP method in the prompt to match your target system, and swap 250 milliseconds for a delay that fits your provider's published limit (for example a higher value if you are allowed only a few requests per second). You can also point the Loop at a field from the trigger body such as {{ input.items }}, and reference the current item inside the request with {{ item }}. Set the loop iteration variable name in the Loop node's properties panel if you want a clearer label than item.
Tips
- Keep the Connector node on the http connector in Direct mode. The call is predictable and per-item, so Direct mode runs it deterministically with no AI credits.
- If the API returns a
429with aRetry-Afterheader, read that header in theexecute-javascriptstep and wait that long instead of a fixed delay, so the workflow backs off only when it needs to. - Process a small slice of your list first (a handful of items) to confirm the pacing and the request body before running the full batch.
Related
- How to Connect to Any REST API Using HTTP Requests walks through the http connector in full.
- How to Use Loop Nodes covers ForEach iteration over a list.
- How to Use Code Runner to Extend AI Workflows with Custom Logic shows more of what the code connector can do.