Only request the fields you need to reduce payload size and improve performance:
Copy
Ask AI
// ❌ Bad: Fetching all fields when you only need a fewconst response = await fetch("/v5/contacts?limit=100");// ✅ Good: Select specific fieldsconst response = await fetch("/v5/contacts?select[]=id&select[]=email&select[]=firstName&limit=100");
When possible, group operations to reduce API calls:
Copy
Ask AI
// ❌ Bad: Individual requests for each contactfor (const email of emails) { await createContact({ email });}// ✅ Good: Process in batchesasync function processBatch(contacts) { // Use bulk endpoints when available // Or process with controlled concurrency const batchSize = 50; for (let i = 0; i < contacts.length; i += batchSize) { const batch = contacts.slice(i, i + batchSize); await Promise.all(batch.map((contact) => createContact(contact))); }}