> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blitz-api.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> BlitzAPI is the B2B Data API for GTM Builders: company and people search, enrichment, verified emails, US phone numbers and job postings behind one API key.
> Its data infrastructure holds 1B+ records: 550M+ professional profiles, 65M+ companies, 65M+ verified emails, 100M+ job postings and 45M+ US phone numbers.
> Pricing: Start $99, Scale $499, Build Your Infra from $999; every endpoint on every plan; fair use policy in records per month; rate limits per endpoint. Details: https://docs.blitz-api.ai/guide/concepts/pricing
> Company and product facts: https://www.blitz-api.ai/llms.txt

# TypeScript / JavaScript SDK for Node.js

> Install blitz-api-js to call BlitzAPI from Node.js or any runtime with a global fetch: Zod-validated types, ESM and CJS builds, auto-pagination, retries.

> **Agents & LLMs**: a Markdown version of this page is available by appending `.md` to the URL, and the full documentation index is at [llms.txt](https://docs.blitz-api.ai/llms.txt).

`blitz-api-js` is the official, typed TypeScript SDK for BlitzAPI. It is `fetch`-based, Zod-validated, ships both ESM and CommonJS builds with `.d.ts` / `.d.cts` types, and uses **snake\_case** request and response fields that match the [API reference](https://docs.blitz-api.ai/api-reference/account/get-api-key-details.md) exactly. Retries, client-side rate limiting per endpoint and auto-pagination are built in.

> [card] [npm](https://www.npmjs.com/package/blitz-api-js)
>
> `blitz-api-js` on the npm registry.

> [card] [GitHub](https://github.com/api-blitz/blitz-api-js)
>
> Source, changelog, and issues.

## Install

```bash theme={null} theme={null}
npm install blitz-api-js
# or: pnpm add blitz-api-js  /  yarn add blitz-api-js
```

Requires Node.js 20+ (or any runtime with a global `fetch`). Ships both ESM and CommonJS builds.

## Quickstart

```ts theme={null} theme={null}
import { BlitzAPI } from "blitz-api-js";

// api_key defaults to the BLITZ_API_KEY environment variable.
const client = new BlitzAPI();

// Health-check the key before a batch job.
const info = await client.account.key_info();
console.log(info.valid, info.records_remaining, info.max_requests_per_seconds);

// LinkedIn profile URL -> verified work email.
const email = await client.enrichment.email({
  person_linkedin_url: "https://www.linkedin.com/in/example-person",
});
if (email.found) console.log(email.email);

// Search people. List methods are paginated; one page's items live on `.data`.
const page = await client.search.people({
  company: { industry: { include: ["Software Development"] } },
  people: { job_level: ["VP"] },
  max_results: 10,
});
for (const person of page.data) {
  console.log(person.full_name, person.headline);
}
```

CommonJS works too:

```js theme={null} theme={null}
const { BlitzAPI } = require("blitz-api-js");
```

## Authentication

Pass the key explicitly or via the `BLITZ_API_KEY` environment variable. It is sent in the `x-api-key` header on every request.

```ts theme={null} theme={null}
const explicit = new BlitzAPI({ api_key: "sk_..." }); // explicit
const fromEnv = new BlitzAPI();                        // reads BLITZ_API_KEY
```

> [!WARNING]
>
> Never expose your API key in client-side code (browsers, mobile apps). Always call BlitzAPI from your backend.

## Endpoints

All methods are grouped into seven namespaces. Each takes a single options object (snake\_case keys) and returns a typed, Zod-validated response. The seven **list** methods (`search.people`, `search.companies`, `search.employee_finder`, `jobs.search`, `jobs.company`, `company.tam_by_jobs`, `company.tam_by_people`) return a paginated `PagePromise` (see [Pagination](#pagination)); `waterfall_icp`, `changelog.list`, and the `enrichment` / `utils` / `account` methods return their response directly.

### `client.account`

```ts theme={null} theme={null}
const info = await client.account.key_info();
console.log(info.valid, info.records_remaining, info.max_requests_per_seconds);
console.log(info.allowed_apis);
```

`records_remaining` and `max_requests_per_seconds` are a number, or the string `"unlimited"` when your plan has no limit.

### `client.search`

```ts theme={null} theme={null}
// People across many companies (cursor-paginated; see Pagination below).
const people = await client.search.people({
  company: {
    industry: { include: ["IT Services and IT Consulting"] },
    employee_range: ["51-200", "201-500"],
    hq: { sales_region: { include: ["EMEA"] } },
  },
  people: {
    job_level: ["VP", "Director"],
    job_function: ["Sales & Business Development"],
    // Phrases matched against the description of the job.
    job_description: { include: ["outbound prospecting"], exclude: ["internship"] },
    // `exclude` drops the people in the listed countries.
    location: { country_code: { exclude: ["FR"] } },
    min_connections: 200,
  },
  max_results: 25,
});
for (const person of people.data) {
  console.log(person.full_name, person.headline, person.linkedin_url);
}

// Companies by ICP (cursor-paginated).
const companies = await client.search.companies({
  company: {
    keywords: { include: ["SaaS"] },
    industry: { include: ["Software Development"] },
    hq: { country_code: { include: ["FR", "DE"] } },
    employee_range: ["51-200", "201-500"],
  },
  max_results: 25,
});
for (const company of companies.data) {
  console.log(company.name, company.industry, company.employees_on_linkedin, company.revenue_range);
}

// All employees at one company (page-paginated).
const employees = await client.search.employee_finder({
  company_linkedin_url: "https://www.linkedin.com/company/openai",
  job_level: ["C-Team", "VP", "Director"],
  job_function: ["Sales & Business Development"],
  sales_region: ["NORAM"],
  max_results: 50,
});
console.log(`Page ${employees.response.page} of ${employees.response.total_pages}`);
for (const person of employees.data) {
  console.log(person.full_name, person.headline);
}

// Employees by job title and job description: both apply to the current job at the company.
// Put a job title in [brackets] to match the whole title exactly.
const sellers = await client.search.employee_finder({
  company_linkedin_url: "https://www.linkedin.com/company/openai",
  job_title: { include: ["[Head of Sales]", "Account Executive"], exclude: ["Intern"] },
  job_description: { include: ["Salesforce"] },
  max_results: 50,
});
for (const person of sellers.data) {
  const job = person.experiences[0];
  console.log(person.full_name, job?.job_title, job?.job_duration_months);
}

// Best-fit decision-makers (up to `max_results`) via a priority cascade (returned directly).
const match = await client.search.waterfall_icp({
  company_linkedin_url: "https://www.linkedin.com/company/openai",
  cascade: [
    // No `location`: both tiers search the whole world.
    { include_title: ["CTO", "VP Engineering"], include_headline_search: false },
    { include_title: ["Engineering Director", "Engineering Manager"], include_headline_search: false },
  ],
  max_results: 5,
});
for (const item of match.results) {
  console.log(`[Tier ${item.icp} | Rank #${item.ranking}]`, item.person?.full_name);
}
```

`country_code`, `continent` and `sales_region` take `include` and `exclude` lists in `people.location`, in `company.hq` and in the `location` of a waterfall tier. A plain list, such as `sales_region: ["EMEA"]`, is still accepted and is read as `include`. `search.employee_finder` takes plain lists. A country code has two letters, in any letter case, and `UK` is read as `GB`. A value of any other length returns a `422`, except `WORLD` in the codes to keep, which means every country: see **[Country Codes](https://docs.blitz-api.ai/guide/reference/normalization/geography.md#country-codes)**.

### `client.jobs`

```ts theme={null} theme={null}
// Live job postings across companies (cursor-paginated; see Pagination below).
const jobs = await client.jobs.search({
  job: {
    title: { include: ["Head of Sales"] },
    seniority: { include: ["5-10"] },
    employment_type: { include: ["FULL_TIME"] },
    work_arrangement: { include: ["Hybrid", "Remote OK"] },
    date_posted: { last_days: 30 },
  },
  company: {
    industry: { include: ["Software Development"] },
    size: { include: ["51-200", "201-500"] },
    // Mail provider of the company. Also on `company.tam_by_jobs`.
    mx: { provider: { include: ["google"] } },
  },
  max_results: 25,
});
for (const job of jobs.data) {
  console.log(job.company_name, job.title, job.location?.city);
}

// Postings at one company (cursor-paginated).
const companyJobs = await client.jobs.company({
  company_linkedin_url: "https://www.linkedin.com/company/openai",
  job: { field: { include: ["Software Engineering"] } },
  max_results: 25,
});
for (const job of companyJobs.data) {
  console.log(job.title, job.url);
}
```

### `client.company`

```ts theme={null} theme={null}
// Companies hiring for a role (deduplicated), each with its matching-posting count.
for await (const match of client.company.tam_by_jobs({
  job: { title: { include: ["Account Executive"] }, min_per_company: 3 },
  company: { industry: { include: ["Software Development"] } },
  max_results: 50,
  max_items: 200,
})) {
  console.log(match.company?.name, match.matched_jobs);
}

// Companies whose current employees match a persona (deduplicated), each with `matched_people`, its count of matching current positions.
for await (const match of client.company.tam_by_people({
  people: { job_level: ["VP", "Director"], job_function: ["Engineering"], min_per_company: 2 },
  company: { industry: { include: ["Software Development"] } },
  max_results: 50,
  max_items: 200,
})) {
  console.log(match.company?.name, match.matched_people);
}
```

### `client.enrichment`

```ts theme={null} theme={null}
// LinkedIn profile URL -> full person profile with the whole career (1 record when found).
const profile = await client.enrichment.person({ person_linkedin_url: "https://www.linkedin.com/in/example-person" });
if (profile.found && profile.person) {
  for (const job of profile.person.experiences) {
    // `job_duration_months`: the number of months in the position.
    console.log(job.job_title, job.company_name, job.job_is_current, job.job_duration_months);
  }
}

// LinkedIn profile URL -> verified work email.
const email = await client.enrichment.email({ person_linkedin_url: "https://www.linkedin.com/in/example-person" });
if (email.found) console.log(email.email);

// LinkedIn profile URL -> mobile or direct phone (US only).
const phone = await client.enrichment.phone({ person_linkedin_url: "https://www.linkedin.com/in/example-person" });
if (phone.found) console.log(phone.phone);

// Work email -> full person profile.
const byEmail = await client.enrichment.email_to_person({ email: "jane.doe@acme.com" });
if (byEmail.found) console.log(byEmail.person?.full_name);

// Phone number -> full person profile (US only).
const byPhone = await client.enrichment.phone_to_person({ phone: "+14155551234" });
if (byPhone.found) console.log(byPhone.person?.full_name);

// Company LinkedIn URL -> full company profile.
const company = await client.enrichment.company({ company_linkedin_url: "https://www.linkedin.com/company/openai" });
console.log(company.company?.name, company.company?.industry, company.company?.employees_on_linkedin);

// Website domain -> Company LinkedIn URL.
const toLinkedin = await client.enrichment.domain_to_linkedin({ domain: "openai.com" });
if (toLinkedin.found) console.log(toLinkedin.company_linkedin_url);

// Company LinkedIn URL -> email domain.
const toDomain = await client.enrichment.linkedin_to_domain({ company_linkedin_url: "https://www.linkedin.com/company/openai" });
if (toDomain.found) console.log(toDomain.email_domain);

// Company employees grouped by country.
const byCountry = await client.enrichment.company_distribution_by_country({
  company_linkedin_url: "https://www.linkedin.com/company/openai",
});
for (const row of byCountry.distribution) {
  console.log(row.country, row.count, row.percentage_ratio);
}

// Company employees grouped by department.
const byDepartment = await client.enrichment.company_distribution_by_department({
  company_linkedin_url: "https://www.linkedin.com/company/openai",
});
for (const row of byDepartment.distribution) {
  console.log(row.department, row.count, row.percentage_ratio);
}
```

### `client.utils`

```ts theme={null} theme={null}
// Current server date/time.
const now = await client.utils.current_date();
```

### `client.changelog`

```ts theme={null} theme={null}
// Public API changelog, newest first. No API key required, and not paginated.
const entries = await client.changelog.list({ days: 30, limit: 10 });
for (const entry of entries) console.log(entry.date, entry.type, entry.title);
```

## Pagination

The list methods (`search.people`, `search.companies`, `search.employee_finder`, `jobs.search`, `jobs.company`, `company.tam_by_jobs`, `company.tam_by_people`) return a `PagePromise`: `await` it for the first page, or `for await` to stream every item across all pages (each fetched on demand).

```ts theme={null} theme={null}
// Stream every match across all pages, with no cursor handling needed.
for await (const person of client.search.people({ people: { job_level: ["VP"] } })) {
  console.log(person.full_name);
}
```

See **[Pagination](https://docs.blitz-api.ai/sdks/pagination.md)** for `max_items`, `.collect()`, manual paging, page metadata, and how each result counts as a record.

## Usage & rate limit

Every metered `/v2` response carries a `fair_usage` block reporting the records the request used and what is left, so you can meter a batch job without a second `key_info()` call.

```ts theme={null} theme={null}
const email = await client.enrichment.email({ person_linkedin_url: "https://www.linkedin.com/in/example-person" });
const usage = email.fair_usage;
console.log(usage?.records_used);                      // records this request consumed
console.log(usage?.records_remaining);                 // records left: a number, or "unlimited"
console.log(usage?.next_reset_at);                     // when the record count resets
console.log(usage?.rate_limit?.remaining_this_second); // calls left this second
console.log(usage?.request_id);                        // quote this id to support

// On a paginated method the block belongs to each page's raw body.
const page = await client.search.people({ people: { job_level: ["VP"] }, max_results: 50 });
console.log(page.response.fair_usage?.records_used);
```

Only the public `changelog.list()`, which is not metered, doesn't return the block. `account.key_info()` returns it with `records_used` at `0` and no `rate_limit`, since that endpoint is not rate limited. Every field is optional, so a response predating the block still parses.

## Configuration

```ts theme={null} theme={null}
const client = new BlitzAPI({
  api_key: undefined,   // falls back to BLITZ_API_KEY
  base_url: "https://api.blitz-api.ai",
  timeout: 30,          // default per-request timeout, seconds (via AbortSignal.timeout)
  max_retries: 3,       // retries on 429 / 5xx / pre-response network errors
  rate_limit_rps: 5,    // client-side token bucket, per endpoint; null to disable
  fetch: undefined,     // custom fetch implementation (tests / runtimes)
});

// Override the timeout for a single call: pass an options object as the last argument.
await client.enrichment.email({ person_linkedin_url: "..." }, { timeout: 5 });
```

A single client instance stays under your per-endpoint request-per-second limit and retries automatically on `429`; see **[Rate limits & retries](https://docs.blitz-api.ai/sdks/rate-limits.md)**. `rate_limit_rps` defaults to `5`; set it to your key's `max_requests_per_seconds` to use your plan's full per-endpoint throughput.

## Error handling

```ts theme={null} theme={null}
import {
  APIConnectionError,
  APIResponseValidationError,
  APIStatusError,
  APITimeoutError,
  AuthenticationError,
  BlitzError,
  InsufficientRecordsError,
  NotFoundError,
  RateLimitError,
  ServerError,
} from "blitz-api-js";

try {
  await client.enrichment.email({ person_linkedin_url: "..." });
} catch (err) {
  if (err instanceof InsufficientRecordsError) {
    // 402: Fair Use record limit reached; err.fair_usage?.next_reset_at
  } else if (err instanceof AuthenticationError) {
    // 401: missing or invalid key, or an endpoint outside the key's allowed_apis
  } else if (err instanceof APIResponseValidationError) {
    // 2xx, but the body wasn't valid JSON or didn't match the schema
  } else if (err instanceof APIStatusError) {
    console.log(err.status_code, err.message, err.body, err.request_id);
    // The usage block of the error body: the request id and the records the request used.
    console.log(err.fair_usage?.request_id, err.fair_usage?.records_used);
  } else if (err instanceof BlitzError) {
    // base class for everything this SDK raises
  }
}
```

`401` / `402` / `404` throw immediately; `429` and `5xx` are retried automatically; timeouts surface as `APITimeoutError` (not retried). A `401` with a valid key means the endpoint is not in the key's `allowed_apis` ("You do not have access to this route"); read `allowed_apis` from `client.account.key_info()`. `FairUsageLimitError` is still exported as a deprecated alias of `InsufficientRecordsError` (the same class, not a subclass) and is scheduled for removal in 4.0.0, so existing `instanceof` checks keep working for now; `err.name` is already `"InsufficientRecordsError"`. See **[Rate limits & retries](https://docs.blitz-api.ai/sdks/rate-limits.md)** for the full retry and timeout behavior.

Every `APIStatusError` carries `err.fair_usage`, the usage block of the error body (`null` when the body has none). On an error, only `request_id` and `records_used` are always set; read `records_remaining`, `next_reset_at` and `rate_limit` as optional.

A `400` or `422` also throws immediately, as `APIStatusError`. For a `422`, `err.body.errors` lists each invalid field as `{ field, message }`; see **[Errors](https://docs.blitz-api.ai/guide/reference/errors.md#validation-errors-422)**. The API rejects any field it does not define, so an extra key in a params object returns a `422` even when TypeScript does not flag it.

## Types & enums

Response objects keep their snake\_case wire keys and **preserve unknown fields**: if the API adds a property before this SDK models it, the value is still present (typed as `unknown`); known fields stay precisely typed.

```ts theme={null} theme={null}
import { INDUSTRY } from "blitz-api-js";              // the full value array (536 values, with "Unknown")
import type { CompanyFilter, Industry } from "blitz-api-js";
```

Enum-backed filter fields (e.g. `industry`, `job_level`, `continent`) accept a known value (autocompleted from a union like `Industry`) or any raw string, so a value missing from the vendored taxonomy never blocks you.

## Next steps

> [card] [Python SDK](https://docs.blitz-api.ai/sdks/python.md)
>
> The same API surface with sync + async clients.

> [card] [Field Normalization](https://docs.blitz-api.ai/guide/reference/normalization.md)
>
> Accepted values for industry, job level, job function, and geography filters.

> [card] [API reference](https://docs.blitz-api.ai/api-reference/account/get-api-key-details.md)
>
> Full request/response schemas and an interactive try-it console.

> [card] [Recipes](https://docs.blitz-api.ai/guide/recipes/icp-list-building.md)
>
> End-to-end workflows: build an ICP list, enrich it, and sync to your CRM.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.