API Rate Limiting: How Limits Work and How to Stay Under
API rate limiting is a cap on how many requests a client may send in a period of time, such as 60 a minute. Go over it and the API rejects the extra requests until the period resets. From the client side, staying under comes down to four things: know the number and what it applies to, read the headers that say where you stand, send every request through one pacer set a little below the limit, and wait as long as the server asks when you do get rejected.
What does an API rate limit actually count?
A rate limit counts requests from one identity over one period, and both parts decide how your client should behave. What counts as the identity, and how long the period is, varies from one API to the next. Read the API's docs for both before you size a job, because the same number means different things under different scopes.
On Perceptlayer, limits are per account and counted per minute. Every key on the account draws from the same budget, so two scripts with two keys on one account share one limit. A free account gets 1 request a second, which is 60 a minute. A paying account runs at the rate of the credits it's using, and at least 5 requests a second (300 a minute).
| Pack | Included rate (requests a second) | Highest rate you can choose at checkout |
|---|---|---|
| Free account | 1 | n/a |
| Starter, Build | 5 | Starter 25, Build 50 |
| Growth, Pro | 5 | 100 |
| Scale | 10 | 300 |
| Volume | 20 | 300 |
| Volume 10M, Volume 25M | 25 | 300 |
| Volume 50M | 50 | 300 |
If you hold credits bought at different rates, the faster ones are used first. A faster rate costs more at checkout; pricing has the details, and the rate limits docs explain how the account's rate is set.
Why does a per-minute limit punish bursts?
A per-minute limit counts how many requests arrive before the minute resets, not how evenly they arrive. If you send all 60 of a free account's requests in the first second, the 61st is rejected and so is every request after it until the reset. The work still takes a minute; you've just added rejected calls and retry logic to it.
Spacing requests evenly avoids that. At 60 a minute that's one request a second; at 300 a minute it's one every 0.2 seconds. An even pace never fills the minute early, so it never sees a rejection from its own traffic. The cost of spacing is a little latency on the first requests of a job, which almost never matters for a batch.
Bursts also hide in places you might not look. A scheduler that starts five jobs at the top of the hour, a retry storm after a network blip, or an agent that issues tool calls in a tight loop can all fill a minute in seconds. Whatever the source, the fix is the same: one pacer that every request goes through.
How do you read where you stand from the headers?
The response headers tell you the limit and your position against it, so your client doesn't have to guess. Perceptlayer sends four rate-limit headers on responses, plus Retry-After on rejections. Read them on every response and log them when something goes wrong, because they're the fastest way to see whether a slowdown is your pace or something else.
| Header | What it tells you |
|---|---|
RateLimit-Limit |
Requests allowed a minute |
RateLimit-Remaining |
Requests left this minute |
RateLimit-Reset |
Seconds until the minute resets |
RateLimit-Policy |
The policy that applies to the account |
Retry-After |
On a 429 or 503: the seconds to wait before retrying |
X-Credits-Used |
What the call cost; 0 on any error |
Two simple rules come from these. When RateLimit-Remaining reaches 0, sleep for RateLimit-Reset seconds before the next request instead of sending it and waiting for a 429. When a 429 or a 503 does arrive, wait the Retry-After seconds before you try again. For what a 429 means and a retry loop that handles every form of Retry-After, see HTTP 429 Too Many Requests.
How do you pace requests on the client side?
Put one limiter in front of every request your process sends, and give it the account's rate minus a margin. The class below hands out evenly spaced time slots: each caller takes the next slot and sleeps until it arrives. A lock makes it safe to share across threads, so four workers together still send no more than the rate you set.
import os
import threading
import time
from concurrent.futures import ThreadPoolExecutor
import requests
API = "https://api.perceptlayer.com/v1/google-search/search"
HEADERS = {"X-API-Key": os.environ["API_KEY"]}
class Pacer:
"""Lets one request through every 60/per_minute seconds, across all threads."""
def __init__(self, per_minute):
self.interval = 60.0 / per_minute
self.lock = threading.Lock()
self.next_slot = time.monotonic()
def wait(self):
with self.lock:
now = time.monotonic()
slot = max(now, self.next_slot)
self.next_slot = slot + self.interval
time.sleep(max(0.0, slot - now))
pacer = Pacer(per_minute=55) # a little under a free account's 60
def search(query):
for attempt in range(5):
pacer.wait()
resp = requests.get(API, params={"query": query, "hl": "en"}, headers=HEADERS, timeout=60)
if resp.status_code not in (429, 503):
break
time.sleep(int(resp.headers.get("Retry-After", "5")))
if resp.headers.get("RateLimit-Remaining") == "0":
time.sleep(int(resp.headers.get("RateLimit-Reset", "0")))
return query, resp.status_code, resp.headers.get("X-Credits-Used")
queries = [f"coffee roasters in {city}" for city in ["Berlin", "Lisbon", "Oslo", "Vienna"]]
with ThreadPoolExecutor(max_workers=4) as pool:
for row in pool.map(search, queries):
print(row)
The margin matters because the limit is per account, not per process. If a second script on the same account is running, both pacers together must stay under the account's rate, so split it between them: 30 a minute each on a free account, not 55 each. If the job runs inside an async program, Concurrent API Requests in Python builds the same idea with asyncio.
What does the endpoint send back?
Each paced call is an ordinary search. This is part of the recorded response from /v1/google-search/search for query=best+restaurants+in+Berlin&hl=en&safe=off, trimmed:
{
"search_information": {
"query_displayed": "best restaurants in Berlin",
"organic_results_count": 6
},
"organic_results": [
{
"position": 1,
"title": "The Best Restaurants in Berlin - Food Guide & Map",
…
},
…
],
…
}
The Google Search API page lists every parameter, and SERP API: What It Returns and What a Query Costs walks through the rest of the response.
Worked example: how long do 3,000 searches take?
A job's minimum run time is its request count divided by the rate, and no amount of concurrency beats it. Say you need to run 3,000 Google searches for a keyword study. The cost is the same at any speed: 3,000 calls × 1 credit = 3,000 credits. What changes with the account's rate is how long the job takes and how you set the pacer.
| Account rate | Per minute | Pacer setting | Minimum run time |
|---|---|---|---|
| Free account, 1 a second | 60 | 55 | 3,000 ÷ 60 = 50 minutes |
| Paying account, 5 a second | 300 | 280 | 3,000 ÷ 300 = 10 minutes |
| Scale pack, 10 a second | 600 | 560 | 3,000 ÷ 600 = 5 minutes |
The pacer settings run slightly slower than the limit, so the real run time is a little longer than the minimum: 3,000 ÷ 55 is about 55 minutes on a free account. That's the trade you want. Firing all 3,000 at once doesn't finish sooner: at most 60 succeed in a free account's minute, the rest come back as 429s, and your retries compete with your new requests for the same budget.
A free account's 100 free credits on signup cover the first 100 searches of this job, so a run of 3,000 needs purchased credits; the Starter pack's 10,000 covers it three times over. The credits docs explain how calls are debited.
What should a client do when it hits the limit anyway?
Treat a 429 as a signal to slow down, not as a failure to report. Wait the Retry-After seconds, retry the same request, and cap the attempts so a misconfigured job stops instead of looping. On Perceptlayer a 429 costs nothing: it returns rate_limited, X-Credits-Used: 0 and the error body {"error": {"code", "message", "request_id"}}.
Timeouts need more care than 429s. Requests have no idempotency key, so a request whose reply was lost to a client timeout may have succeeded on the server and been billed. Before you retry a timeout automatically, decide whether a duplicate call is acceptable for that job. For a search, it usually is; the cost is one more credit.
If 429s keep coming after you've paced the job, the pace is wrong for the account: another script shares it, a second pacer runs in another process, or the rate you assumed isn't the one the credits in use carry. RateLimit-Limit on any response shows the real number. Agents need the same treatment: cap the calls in the tool layer, because a model in a loop doesn't pace itself. The AI agents docs cover the MCP setup.
To see the headers on a real response, run a search in the playground on the Google Search API page, or get a free API key and call the endpoint with curl -i.
APIs in this post
Frequently asked questions
Is the rate limit per API key or per account?
Per account. Every key on a Perceptlayer account draws from the same per-minute budget, so creating more keys doesn't raise the limit. If several scripts or workers share an account, give them one shared pacer, or split the account's rate between their pacers so the total stays under the limit.
What rate does a free account get?
A free account gets 1 request a second, which is 60 a minute, and 100 free credits after verifying an email address. Paying accounts run at the rate of the credits they're using and at least 5 requests a second (300 a minute). The rate limits docs list each pack's rate.
Does a rate-limited request cost credits?
No. A 429 returns the code rate_limited, X-Credits-Used: 0 and a Retry-After header with the seconds to wait. Only a successful response debits credits, and errors still report X-Credits-Remaining so you can track your balance. The errors docs list every code and its status.
Can I get a higher rate limit?
Yes, by buying credits at a faster rate. Each pack includes a rate, from 5 requests a second on Starter to 50 on Volume 50M, and a faster rate can be chosen at checkout for a higher price, up to a maximum that depends on the pack, such as 25 for Starter or 300 for Scale. The pricing page has the details.
Should I retry after a timeout?
Only if a duplicate call is acceptable. Requests have no idempotency key, so a request whose reply was lost to a timeout may have succeeded and been billed. Retrying it can run the call twice. For read-only searches that usually costs one extra credit; log the request_id of errors so you can trace what happened.