brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl rate limits how many requests it starts per second

Curl
~/tips/tip-curl-rate-requests

curl --rate 2/s -O 'https://example.com/archive/page[1-20].html'

Space out a series of requests so an API or small server is not hit all at once.

Where --limit-rate caps bandwidth, --rate caps how often curl starts a new transfer. For a list of URLs that is often what a server cares about.

Give it a number per time unit: s, m, h or d.

curl --rate 2/s -O 'https://example.com/archive/page[1-20].html'
curl --rate 10/m -K urls.txt

The first line fetches twenty pages, but never starts more than two in one second. The second spreads a config file full of URLs over time, ten per minute. When a transfer finishes early, curl waits before it starts the next one, so you do not need a sleep in a shell loop.

I think this is the polite default for scraping your own archive or walking through a paginated API with a strict rate limit. It needs curl 7.84 or newer.

The limit only works within one curl command. Two scripts each running --rate 2/s still make four requests per second together. It also has no effect when you combine it with -Z for parallel transfers, so pick one of the two. A single URL is not slowed down at all.

Further reading: curl man page

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link