You should have a look at our Analytics Best Practices docs which talk about how to best get results from our analytics endpoints in depth.
For example, looking at 503 errors in particular, from that page you can find this information:
On queries that result in an HTTP 503 Service Unavailable status code, you must inspect the retry-after header and retry only after the time indicated.