Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Optimize Apollo.io API performance. Use when improving API response times, reducing latency, or optimizing bulk operations. Trigger with phrases like "apollo performance", "optimize apollo", "apollo slow", "apollo latency", "speed up apollo".
.claude/skills/jeremylongshore-apollo-performance-tuning/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 47% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 31% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 88% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 21% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 52% | 0% |
Optimize Apollo.io API performance through response caching, connection pooling, bulk operations, parallel fetching, and result slimming. Key insight: search is free but slow (~500ms), enrichment costs credits — cache aggressively and batch enrichment calls.
Reuse TCP connections to avoid TLS handshake overhead on every request.
typescript// src/apollo/optimized-client.ts import axios from 'axios'; import https from 'https'; const httpsAgent = new https.Agent({ keepAlive: true, maxSockets: 10, maxFreeSockets: 5, timeout: 30_000, }); export const optimizedClient = axios.create({ baseURL: 'https://api.apollo.io/api/v1', headers: { 'Content-Type': 'application/json', 'x-api-key': process.env.APOLLO_API_KEY! }, httpsAgent, timeout: 15_000, });
typescript// src/apollo/cache.ts import { LRUCache } from 'lru-cache'; // Different TTLs based on data volatility const CACHE_TTLS: Record<string, number> = { '/organizations/enrich': 24 * 60 * 60 * 1000, // 24h — company data rarely changes '/people/match': 4 * 60 * 60 * 1000, // 4h — contact data changes occasionally '/mixed_people/api_search': 15 * 60 * 1000, // 15min — search results are dynamic '/mixed_companies/search': 30 * 60 * 1000, // 30min — company search '/contact_stages': 60 * 60 * 1000, // 1h — stages rarely change }; const cache = new LRUCache<string, { data: any; at: number }>({ max: 5000, maxSize: 50 * 1024 * 1024, sizeCalculation: (v) => JSON.stringify(v).length, }); function cacheKey(endpoint: string, params: any): string { return `${endpoint}:${JSON.stringify(params)}`; } export async function cachedRequest<T>( endpoint: string, requestFn: () => Promise<T>, params: any, ): Promise<T> { const key = cacheKey(endpoint, params); const ttl = CACHE_TTLS[endpoint] ?? 15 * 60 * 1000; const cached = cache.get(key); if (cached && Date.now() - cached.at < ttl) return cached.data; const data = await requestFn(); cache.set(key, { data, at: Date.now() }); return data; } export function getCacheStats() { return { entries: cache.size, sizeBytes: cache.calculatedSize }; }
Apollo's bulk enrichment endpoint handles 10 records per call vs 1. Massive performance gain.
typescript// src/apollo/bulk-ops.ts import { optimizedClient } from './optimized-client'; import PQueue from 'p-queue'; const queue = new PQueue({ concurrency: 3, intervalCap: 2, interval: 1000 }); // Enrich 100 people: 100 individual calls = 100 requests @ 500ms = 50s // Batch of 10: 10 bulk calls @ 600ms = 6s (8x faster, same credits) export async function batchEnrich( details: Array<{ email?: string; linkedin_url?: string; first_name?: string; last_name?: string; organization_domain?: string }>, ): Promise<any[]> { const results: any[] = []; for (let i = 0; i < details.length; i += 10) { const batch = details.slice(i, i + 10); const result = await queue.add(async () => { const { data } = await optimizedClient.post('/people/bulk_match', { details: batch, reveal_personal_emails: false, reveal_phone_number: false, }); return data.matches ?? []; }); results.push(...(result ?? [])); } return results; }
typescriptexport async function parallelSearch( domains: string[], concurrency: number = 5, ): Promise<Map<string, any[]>> { const searchQueue = new PQueue({ concurrency }); const results = new Map<string, any[]>(); await searchQueue.addAll( domains.map((domain) => async () => { const data = await cachedRequest( '/mixed_people/api_search', () => optimizedClient.post('/mixed_people/api_search', { q_organization_domains_list: [domain], person_seniorities: ['vp', 'director', 'c_suite'], per_page: 25, }).then((r) => r.data), { domain }, ); results.set(domain, data.people ?? []); }), ); return results; }
Apollo returns large person objects (~2KB each). Extract only needed fields to reduce memory.
typescriptinterface SlimPerson { id: string; name: string; title: string; email?: string; company: string; seniority: string; } function slimPerson(raw: any): SlimPerson { return { id: raw.id, name: raw.name, title: raw.title, email: raw.email, company: raw.organization?.name ?? '', seniority: raw.seniority ?? '', }; } // Use immediately after API call to free memory const { data } = await optimizedClient.post('/mixed_people/api_search', { ... }); const slim = data.people.map(slimPerson); // ~200 bytes each instead of ~2KB
typescriptasync function benchmark() { const endpoints = [ { name: 'People Search', fn: () => optimizedClient.post('/mixed_people/api_search', { q_organization_domains_list: ['apollo.io'], per_page: 1 }) }, { name: 'Org Enrich', fn: () => optimizedClient.get('/organizations/enrich', { params: { domain: 'apollo.io' } }) }, { name: 'Auth Health', fn: () => optimizedClient.get('/auth/health') }, ]; for (const ep of endpoints) { const times: number[] = []; for (let i = 0; i < 5; i++) { const start = Date.now(); try { await ep.fn(); } catch {} times.push(Date.now() - start); } const avg = Math.round(times.reduce((a, b) => a + b) / times.length); const p95 = times.sort((a, b) => a - b)[Math.floor(times.length * 0.95)]; console.log(`${ep.name}: avg=${avg}ms, p95=${p95}ms`); } }
keepAlive and configurable maxSockets/people/bulk_match (10x fewer requests)p-queue concurrency control| Issue | Resolution | |-------|------------| | High latency | Enable connection pooling, check for stale cache | | Cache misses | Increase TTL for stable data (org enrichment) | | Rate limits with parallelism | Reduce p-queue concurrency | | Memory growth | Lower LRU max entries, slim response payloads |
Proceed to apollo-cost-tuning for cost optimization.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 25,970 | 15,109 | -42% | 1 | 1 | 0% | 6,213 | 5,807 | -7% | 0 | 0 | — |
case-02 | fail→pass | 16,527 | 14,218 | -14% | 1 | 1 | 0% | 3,693 | 5,413 | +47% | 0 | 0 | — |
case-03 | fail→fail | 16,129 | 15,023 | -7% | 1 | 1 | 0% | 3,684 | 5,653 | +53% | 0 | 0 | — |
case-04 | fail→pass | 13,984 | 6,808 | -51% | 1 | 1 | 0% | 2,577 | 3,366 | +31% | 0 | 0 | — |
case-05 | fail→pass | 6,782 | 1,821 | -73% | 1 | 1 | 0% | 1,335 | 2,515 | +88% | 0 | 0 | — |
case-06 | fail→pass | 11,204 | 2,618 | -77% | 1 | 1 | 0% | 2,159 | 2,610 | +21% | 0 | 0 | — |
case-07 | fail→pass | 9,715 | 2,591 | -73% | 1 | 1 | 0% | 1,710 | 2,591 | +52% | 0 | 0 | — |
case-08 | fail→pass | 12,686 | 2,545 | -80% | 1 | 1 | 0% | 2,080 | 2,583 | +24% | 0 | 0 | — |
case-09 | fail→pass | 9,455 | 3,193 | -66% | 1 | 1 | 0% | 1,504 | 2,679 | +78% | 0 | 0 | — |
case-10 | fail→pass | 11,195 | 2,108 | -81% | 1 | 1 | 0% | 1,906 | 2,581 | +35% | 0 | 0 | — |
case-11 | pass→pass | 14,391 | 14,020 | -3% | 1 | 1 | 0% | 2,698 | 4,698 | +74% | 0 | 0 | — |
case-12 | pass→fail | 9,096 | 1,734 | -81% | 1 | 1 | 0% | 1,562 | 2,434 | +56% | 0 | 0 | — |
case-13 | pass→pass | 4,968 | 2,106 | -58% | 1 | 1 | 0% | 886 | 2,477 | +180% | 0 | 0 | — |
case-23 | fail→fail | 19,687 | 14,782 | -25% | 1 | 1 | 0% | 4,053 | 4,570 | +13% | 0 | 0 | — |
case-14 | pass→pass | 8,944 | 4,295 | -52% | 1 | 1 | 0% | 1,710 | 3,016 | +76% | 0 | 0 | — |
case-15 | fail→pass | 24,311 | 9,331 | -62% | 1 | 1 | 0% | 1,104 | 3,877 | +251% | 0 | 0 | — |
case-16 | fail→pass | 11,863 | 4,614 | -61% | 1 | 1 | 0% | 1,982 | 2,875 | +45% | 0 | 0 | — |
case-17 | fail→pass | 10,583 | 2,710 | -74% | 1 | 1 | 0% | 1,759 | 2,586 | +47% | 0 | 0 | — |
case-18 | fail→pass | 12,912 | 9,880 | -23% | 1 | 1 | 0% | 2,199 | 3,983 | +81% | 0 | 0 | — |
case-19 | fail→pass | 9,866 | 5,595 | -43% | 1 | 1 | 0% | 1,943 | 3,094 | +59% | 0 | 0 | — |
case-20 | fail→pass | 15,780 | 4,117 | -74% | 1 | 1 | 0% | 2,755 | 2,895 | +5% | 0 | 0 | — |
case-21 | pass→pass | 14,981 | 17,193 | +15% | 1 | 1 | 0% | 2,477 | 5,538 | +124% | 0 | 0 | — |
case-22 | fail→pass | 12,588 | 14,999 | +19% | 1 | 1 | 0% | 2,271 | 4,971 | +119% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 22 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +61 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.