APIs might implement rate limiting, and if they do your clients might experience 429 Too Many Requests
responses with a Retry-After
header, informing your client how long it should wait before making the next request. And being good internet citizens we should all implement support for this in our API clients.
Guzzle includes a retry middleware class that can be used to handle this.
The implementation in this gist is a PoC, so feel free to build upon it, and comment if you think something should be added / removed.
Thanks for your quick gist