AP

apollo-sdk-patterns

Provides boilerplate and patterns for integrating with the Apollo.io API, focusing on type safety and robust request handling.

Install

mkdir -p .claude/skills/apollo-sdk-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/8516" && unzip -o skill.zip -d .claude/skills/apollo-sdk-patterns && rm skill.zip

Installs to .claude/skills/apollo-sdk-patterns

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Apply production-ready Apollo.io SDK patterns.
46 charsno explicit “when” trigger
Advanced

Key capabilities

  • Generate type-safe API clients with Zod validation
  • Implement exponential backoff for API retries
  • Perform asynchronous pagination for large datasets
  • Execute bulk enrichment with rate awareness
  • Define custom error classes for API responses

How it works

This skill provides a set of production-ready patterns including Zod-validated clients, custom error handling, and retry logic to wrap the Apollo.io REST API.

Inputs & outputs

You give it
API configuration and request parameters
You get back
Type-safe API response data

When to use apollo-sdk-patterns

  • Implementing Apollo API clients
  • Refactoring existing API service calls
  • Establishing team coding standards for third-party SDKs

About this skill

Apollo SDK Patterns

Overview

Production-ready patterns for Apollo.io API integration. Apollo has no official SDK — these patterns wrap the REST API (https://api.apollo.io/api/v1/) with type safety, retry logic, pagination, and bulk operations. All requests use the x-api-key header.

Prerequisites

  • Completed apollo-install-auth setup
  • TypeScript 5+ with strict mode

Instructions

Step 1: Type-Safe Client with Zod Validation

// src/apollo/client.ts
import axios, { AxiosInstance } from 'axios';
import { z } from 'zod';

const ConfigSchema = z.object({
  apiKey: z.string().min(10, 'API key too short'),
  baseURL: z.string().url().default('https://api.apollo.io/api/v1'),
  timeout: z.number().default(30_000),
});

let instance: AxiosInstance | null = null;

export function getApolloClient(config?: Partial<z.input<typeof ConfigSchema>>): AxiosInstance {
  if (instance) return instance;

  const parsed = ConfigSchema.parse({
    apiKey: config?.apiKey ?? process.env.APOLLO_API_KEY,
    ...config,
  });

  instance = axios.create({
    baseURL: parsed.baseURL,
    timeout: parsed.timeout,
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': parsed.apiKey,
    },
  });

  return instance;
}

// Reset for testing
export function resetClient() { instance = null; }

Step 2: Custom Error Classes

// src/apollo/errors.ts
import { AxiosError } from 'axios';

export class ApolloApiError extends Error {
  constructor(
    message: string,
    public statusCode: number,
    public endpoint: string,
    public retryable: boolean,
    public requestId?: string,
  ) {
    super(message);
    this.name = 'ApolloApiError';
  }

  static fromAxios(err: AxiosError): ApolloApiError {
    const status = err.response?.status ?? 0;
    const body = err.response?.data as any;
    return new ApolloApiError(
      body?.message ?? err.message,
      status,
      err.config?.url ?? 'unknown',
      [429, 500, 502, 503, 504].includes(status),
      err.response?.headers?.['x-request-id'],
    );
  }
}

export class ApolloRateLimitError extends ApolloApiError {
  constructor(
    public retryAfterMs: number,
    endpoint: string,
  ) {
    super(`Rate limited on ${endpoint}`, 429, endpoint, true);
    this.name = 'ApolloRateLimitError';
  }
}

Step 3: Retry with Exponential Backoff

// src/apollo/retry.ts
import { ApolloApiError } from './errors';

export async function withRetry<T>(
  fn: () => Promise<T>,
  opts: { maxRetries?: number; baseMs?: number; maxMs?: number } = {},
): Promise<T> {
  const { maxRetries = 3, baseMs = 1000, maxMs = 30_000 } = opts;

  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await fn();
    } catch (err) {
      const isRetryable = err instanceof ApolloApiError && err.retryable;
      if (!isRetryable || attempt === maxRetries) throw err;

      const jitter = Math.random() * 500;
      const delay = Math.min(baseMs * 2 ** attempt + jitter, maxMs);
      await new Promise((r) => setTimeout(r, delay));
    }
  }
  throw new Error('Unreachable');
}

Step 4: Async Pagination Iterator

Apollo endpoints return pagination.total_entries and accept page/per_page. The People Search API limits to 500 pages (50,000 records).

// src/apollo/paginator.ts
import { getApolloClient } from './client';
import { withRetry } from './retry';

export async function* paginate<T>(
  endpoint: string,
  body: Record<string, unknown>,
  itemKey: string = 'people',
  perPage: number = 100,
  maxPages: number = 500,
): AsyncGenerator<T[], void, undefined> {
  const client = getApolloClient();
  let page = 1;
  let totalPages = Infinity;

  while (page <= Math.min(totalPages, maxPages)) {
    const { data } = await withRetry(() =>
      client.post(endpoint, { ...body, page, per_page: perPage }),
    );

    const items: T[] = data[itemKey] ?? [];
    totalPages = data.pagination?.total_pages ?? 1;
    if (items.length === 0) break;

    yield items;
    page++;
  }
}

// Usage:
// for await (const batch of paginate('/mixed_people/api_search', {
//   q_organization_domains_list: ['stripe.com'],
// })) {
//   await processBatch(batch);
// }

Step 5: Bulk Enrichment with Rate Awareness

Apollo's Bulk People Enrichment endpoint handles up to 10 records per call.

// src/apollo/bulk-enrich.ts
import { getApolloClient } from './client';
import { withRetry } from './retry';

interface EnrichmentDetail {
  email?: string;
  linkedin_url?: string;
  first_name?: string;
  last_name?: string;
  organization_domain?: string;
}

export async function bulkEnrichPeople(
  details: EnrichmentDetail[],
  opts: { revealPersonalEmails?: boolean; revealPhoneNumber?: boolean } = {},
): Promise<any[]> {
  const client = getApolloClient();
  const results: any[] = [];

  // Apollo bulk endpoint accepts max 10 at a time
  for (let i = 0; i < details.length; i += 10) {
    const batch = details.slice(i, i + 10);

    const { data } = await withRetry(() =>
      client.post('/people/bulk_match', {
        details: batch,
        reveal_personal_emails: opts.revealPersonalEmails ?? false,
        reveal_phone_number: opts.revealPhoneNumber ?? false,
      }),
    );

    results.push(...(data.matches ?? []));

    // Brief pause between batches to respect rate limits
    if (i + 10 < details.length) {
      await new Promise((r) => setTimeout(r, 500));
    }
  }

  return results;
}

Output

  • src/apollo/client.ts — Zod-validated singleton with x-api-key header
  • src/apollo/errors.tsApolloApiError + ApolloRateLimitError with retryable flag
  • src/apollo/retry.ts — Exponential backoff with jitter
  • src/apollo/paginator.ts — Async generator for paginated endpoints (500-page limit)
  • src/apollo/bulk-enrich.ts — Batch enrichment via /people/bulk_match (10 per call)

Error Handling

PatternWhen to Use
Singleton clientAlways — one client instance per process
Retry429 rate limits, 5xx server errors
PaginationSearch results > 100 records
Bulk enrichmentMultiple contacts need email/phone data
Custom errorsTyped catch blocks distinguishing auth vs rate limit vs server

Examples

Full Pipeline: Search, Paginate, Enrich

import { paginate } from './apollo/paginator';
import { bulkEnrichPeople } from './apollo/bulk-enrich';

async function enrichLeadsAtCompany(domain: string) {
  const allPeople: any[] = [];
  for await (const batch of paginate('/mixed_people/api_search', {
    q_organization_domains_list: [domain],
    person_seniorities: ['vp', 'director', 'c_suite'],
  })) {
    allPeople.push(...batch);
  }
  console.log(`Found ${allPeople.length} decision-makers at ${domain}`);

  // Bulk enrich only those without email
  const toEnrich = allPeople
    .filter((p) => !p.email && p.linkedin_url)
    .map((p) => ({ linkedin_url: p.linkedin_url }));

  const enriched = await bulkEnrichPeople(toEnrich);
  console.log(`Enriched ${enriched.length} contacts`);
}

Resources

Next Steps

Proceed to apollo-core-workflow-a for lead search implementation.

When not to use it

  • When using an environment without TypeScript 5+ strict mode

Prerequisites

Completed apollo-install-auth setupTypeScript 5+ with strict mode

Limitations

  • Pagination is limited to 500 pages
  • Bulk enrichment is limited to 10 records per call

How it compares

It provides a structured SDK-like wrapper for the Apollo REST API, which lacks an official SDK.

Compared to similar skills

apollo-sdk-patterns side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
apollo-sdk-patterns (this skill)025dCautionAdvanced
mcp-builder1363moReviewAdvanced
telegram-mini-app626moReviewAdvanced
stripe-integration482moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

telegram-mini-app

davila7

Expert in building Telegram Mini Apps (TWA) - web apps that run inside Telegram with native-like experience. Covers the TON ecosystem, Telegram Web App API, payments, user authentication, and building viral mini apps that monetize. Use when: telegram mini app, TWA, telegram web app, TON app, mini app.

62163

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

backend-dev-guidelines

langfuse

Comprehensive backend development guide for Langfuse's Next.js 14/tRPC/Express/TypeScript monorepo. Use when creating tRPC routers, public API endpoints, BullMQ queue processors, services, or working with tRPC procedures, Next.js API routes, Prisma database access, ClickHouse analytics queries, Redis queues, OpenTelemetry instrumentation, Zod v4 validation, env.mjs configuration, tenant isolation patterns, or async patterns. Covers layered architecture (tRPC procedures → services, queue processors → services), dual database system (PostgreSQL + ClickHouse), projectId filtering for multi-tenant isolation, traceException error handling, observability patterns, and testing strategies (Jest for web, vitest for worker).

10100

swapper-integration

shapeshift

Integrate new DEX aggregators, swappers, or bridge protocols (like Bebop, Portals, Jupiter, 0x, 1inch, etc.) into ShapeShift Web. Activates when user wants to add, integrate, or implement support for a new swapper. Guides through research, implementation, and testing following established patterns.

696

copilot-sdk

github

Build agentic applications with GitHub Copilot SDK. Use when embedding AI agents in apps, creating custom tools, implementing streaming responses, managing sessions, connecting to MCP servers, or creating custom agents. Triggers on Copilot SDK, GitHub SDK, agentic app, embed Copilot, programmable agent, MCP server, custom agent.

763

Search skills

Search the agent skills registry