Using CF purge cache api

Hey,

I have recently used an API script to purge cache on 16 sites on CF e.g

curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache" \
 -H "X-Auth-Email: USER" \
 -H "X-Auth-Key: KEY " \
 -H "Content-Type: application/json" \
 --data '{"purge_everything":true}'

it worked okay for a couple of months up until got these error messages:
“message”:“Rate limited. Please wait and consider throttling your request speed”

I did found something related to rate limit on Cloudflare firewall tab but I didn’t have any rules applied
I tried setting a wait function so it will be 10 seconds each request but it looks like these messages appear random for each zone

Does anyone have an idea where I can throttle my request speed?

Thanks!

How often do you make these calls?

twice in 2 weeks perhaps maybe more…

Alright, so the only issue is when you run your script and it iterates over these 16 domains, right?

I’d increase the waiting time between requests to thirty seconds and try that. It will be trial and error.

its already set to 40 seconds each request but I will try to increase and see if anything changes…

Thanks!

Maybe set a minute or two. Just wait a bit before you run all the tests. You could also open a support ticket and clarify what interval best to use.

limit seems to be 1200 API requests every 5 minutes per CF user https://support.cloudflare.com/hc/en-us/articles/200171456-How-many-API-calls-can-I-make-

maybe you have other API calls besides those purges within same CF user which is adding up to hit the limit ?

1 Like

I concur, there must be something else running in parallel. Sending 16 API requests (even in two second intervals) is no issue at all, just tested that.

@qbemedia, check for any other API calls. Assuming this 4/second average limit is accurate, there must be something that is using the API heavily. Check your audit log too.