Understanding API rate limits and best practices
Show Header Details
X-RateLimit-Limit: 60 X-RateLimit-Remaining: 45 X-RateLimit-Reset: 1704624000
X-RateLimit-Limit
X-RateLimit-Remaining
X-RateLimit-Reset
{ "success": false, "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Too many requests", "details": "Please wait before making more requests" } }
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function makeRequest(retries = 3) { for (let i = 0; i < retries; i++) { try { return await apiRequest(); } catch (error) { if (error.code !== 'RATE_LIMIT_EXCEEDED') throw error; await sleep(Math.pow(2, i) * 1000); } } }
// Instead of multiple single uploads const files = ['doc1.pdf', 'doc2.pdf', 'doc3.pdf']; const formData = new FormData(); files.forEach(file => formData.append('files', file)); // Single batch upload await api.upload(formData);