When to Use Batch Processing
Batch processing is ideal when you need to process hundreds or thousands of records. It reduces API calls and improves efficiency.
Batch processing is ideal when you need to process hundreds or thousands of records. It reduces API calls and improves efficiency.
Different endpoints have different optimal chunk sizes. Generally, 100-500 items per batch provides the best balance of throughput and reliability.
class="text-pink-400">const CHUNK_SIZE = class="text-amber-400">100;
class="text-pink-400">async class="text-pink-400">function processBatch(items: string[]) {
class="text-pink-400">const chunks = [];
class="text-pink-400">for (class="text-pink-400">let i = class="text-amber-400">0; i < items.length; i += CHUNK_SIZE) {
chunks.push(items.slice(i, i + CHUNK_SIZE));
}
class="text-pink-400">return Promise.all(
chunks.map(chunk =>
fetch(class="text-emerald-class="text-amber-400">400">'/api/batch/verify', {
method: class="text-emerald-class="text-amber-400">400">'POST',
body: JSON.stringify({ items: chunk })
})
)
);
}Batch responses include success and failure arrays. Implement retry logic for failed items while storing successful results.
For very large batches, use webhook notifications to track progress without polling.
Explore our API documentation to start building with Olympus.