skrap-ai
v0.2.0
Published
Official Node.js / TypeScript SDK for the Skrap.ai API: email verification, email finder, enrichment, bulk jobs, lists and webhooks.
Maintainers
Readme
Skrap.ai Node.js SDK
The official Node.js and TypeScript library for the Skrap.ai API. Use it to verify email addresses, find work emails, search a company domain, search leads and companies, enrich people and companies, run bulk jobs, manage lists, read your usage and receive webhooks.
- TypeScript types for every request and response
- No runtime dependencies (uses the global
fetchof Node.js 18+) - ESM and CommonJS builds
- Automatic retries with exponential backoff that honour
Retry-After - Typed errors that carry the HTTP status, error code and retry hints
Install
npm install skrap-aiRequires Node.js 18 or later. You need an API key: create one in the app under Settings → API keys & MCP.
Quick start
import { Skrap } from 'skrap-ai';
const skrap = new Skrap({ apiKey: process.env.SKRAP_API_KEY });
// Verify an address
const verified = await skrap.verifyEmail('[email protected]');
console.log(verified.status); // valid | risky | invalid | unknown
// Find a work email
const found = await skrap.findEmail({ firstName: 'Jane', lastName: 'Doe', domain: 'example.com' });
console.log(found.emails[0]?.email);CommonJS works too:
const { Skrap } = require('skrap-ai');If you leave out apiKey, the client reads the SKRAP_API_KEY environment variable. Keep keys on the server and never ship them to a browser.
Configuration
const skrap = new Skrap({
apiKey: 'sk_...', // default: process.env.SKRAP_API_KEY
baseUrl: 'https://api.skrap.ai', // default: process.env.SKRAP_BASE_URL, then https://api.skrap.ai
timeoutMs: 120_000, // per attempt (verify and find can take up to about a minute)
maxRetries: 2, // retries after the first attempt; 0 turns retries off
maxRetryDelayMs: 60_000, // longest Retry-After the SDK will wait for
fetch: customFetch, // optional fetch implementation
defaultHeaders: { 'x-my-trace': 'abc' },
});Every method takes an optional last argument with per-request options:
await skrap.verifyEmail('[email protected]', {
signal: AbortSignal.timeout(30_000), // cancel
timeoutMs: 30_000,
maxRetries: 0,
headers: { 'x-my-trace': 'abc' },
idempotencyKey: 'a-new-uuid-per-operation', // POSTs that create or charge: see "Idempotent retries"
});Test without spending credits
Addresses at sandbox.skrap.ai are answered from fixed rules: no live check runs, nothing is charged, and every answer carries sandbox: true. For example [email protected], invalid@, risky@, role@, disposable@, unknown@ and retry@ (unknown, retryable: true) for verify; last name Valid, Risky or Unknown at the domain sandbox.skrap.ai for find; and sandbox.skrap.ai as the company in domain search and in the company enrichment calls. See the sandbox docs.
const r = await skrap.verifyEmail('[email protected]');
r.status; // 'risky'
r.sandbox; // trueCredits
Lookups that come back invalid, unknown or not found are free. If you repeat a verify or find that you already paid for, it is also free while inside your plan's repeat window, and the answer then carries repeat: { free: true, firstChargedAt }. See pricing and the credit table.
Methods
Verify an email
POST /api/v2/verify-email. Costs 1 credit when the result is valid or risky.
const r = await skrap.verifyEmail('[email protected]'); // or verifyEmail({ email })
r.status; // 'valid' | 'risky' | 'invalid' | 'unknown'
r.retryable; // true: unknown for a temporary reason, try again later
r.score; // 95 valid, 10-70 risky, 0 invalid, null unknown
r.checks; // { syntax, mxFound, smtp, catchAll, disposable, roleAccount, freeProvider }
r.riskReasons; // risky only: catch_all, catch_all_unconfirmed, role_account, disposable
r.didYouMean; // typo hint or null
r.requestId; // same as the X-Request-Id headerFind a work email
POST /api/v2/find-email. Costs 1 credit when a valid or risky email is found. Give a domain when you have one (best results). Otherwise give a company name.
const r = await skrap.findEmail({
firstName: 'Jane',
lastName: 'Doe', // or fullName: 'Jane Doe'
domain: 'example.com', // or company: 'Example Inc' (+ optional location hint)
});
r.email; // best address, or null
r.status; // 'valid' | 'risky' | 'invalid' | 'unknown'
r.score; // confidence 0-100, null without an address
r.catchAll; // true: catch-all domain (the mailbox cannot be proven)
r.source; // mail_server | email_format | best_guess | records | web
r.emails; // [{ email, status }]
r.domainStatus; // 'valid' | 'invalid' | 'unknown'
r.retryable; // true: unknown for a temporary reason, try again later
r.requestId;A find waits for the final answer, which can take up to about 50 seconds when a mail server is slow. To be answered sooner, give a budget:
const r = await skrap.findEmail({ firstName: 'Jane', lastName: 'Doe', domain: 'example.com' }, { budgetMs: 10_000 });
if (r.deferred) {
// Not done within 10 s: status 'unknown', retryable true, not charged.
// The find keeps running; the same request again collects its answer.
const again = await skrap.findEmail({ firstName: 'Jane', lastName: 'Doe', domain: 'example.com' }, { budgetMs: 10_000 });
}The budget is sent as the x-skrap-budget-ms header. The API uses at least 3,000 ms, and ignores a budget that is not shorter than its own.
Some mail servers answer slowly. In that case the first answer has pendingRefinement: true and is not charged yet. Wait for the final answer like this:
if (r.pendingRefinement) {
const final = await skrap.waitForFindRefinement(r.requestId, { intervalMs: 2000, timeoutMs: 120_000 });
final.email; // final.status, final.domainStatus
}
// or poll yourself:
const state = await skrap.getFindRefinement(r.requestId); // { ready, email?, status?, ... }Sometimes a company name matches several companies. Then the answer has needsCompanyConfirmation: true and suggestions: [{ name, domain, employeeCount }]. Resend with the domain you mean.
Domain search
GET /api/v2/domain-search. A company domain (or name, or LinkedIn company id) in: the company, its email format and one page of 25 people. Costs 1 credit when a company or people come back; nothing found is free, and so is the same page again inside your plan's repeat window.
const ds = await skrap.domainSearch({
domain: 'example.com', // or company: 'Example Inc', or companyLinkedinId
seniority: ['vp', 'director'], // c_suite, vp, director, manager, staff
department: ['sales'],
page: 1, // 1-20
});
ds.company; // { name, industry, size, employeeCount, headquarters, ... } or null
ds.emailFormat; // { formats: [{ format: '{first}.{last}', share }], evidence, catchAll } or null
ds.emailFormatInfo; // when emailFormat is null: { reason, catchAll, likelyFormat }
ds.people; // [{ id, name, firstName, lastName, title, location, linkedinUrl }]
ds.hasMore; ds.total;
// People come without emails. Get one (1 credit for a valid or risky email):
const person = ds.people[0]!;
const email = await skrap.search.leadEmail(person.id, { name: person.name, domain: ds.domain! });skrap.domainSearch('example.com') is short for { domain: 'example.com' }.
Enrichment
You are charged only when something is found. Each account can spend up to 5,000 credits a day on enrichment, and the limit resets at midnight UTC. Over the limit, you get a RateLimitError with code ENRICH_DAILY_LIMIT.
// Who is behind a work email. 2 credits when found (+1 with includeCompany when the profile is found).
const who = await skrap.enrich.reverseEmail({ email: '[email protected]', includeCompany: true });
who.found; who.person?.fullName; who.person?.currentJob?.title;
who.company; // the person's current company: { name, domain, linkedinUrl }
who.companyProfile; // full company profile, only with includeCompany: true
// A LinkedIn profile, plus the work email at the current employer when on record. 1 credit (+1 with email).
const p = await skrap.enrich.person({ linkedinUrl: 'https://www.linkedin.com/in/jane-doe', includeEmail: true });
p.person; p.workEmail; // { address, status } | null
// A company from its domain or LinkedIn page. 1 credit (+1 with includeBreakdown).
const c = await skrap.enrich.company({ domain: 'example.com', includeBreakdown: true });
c.company?.industry; c.company?.employees; c.headcountBreakdown?.departments;
// People at a company. 1 credit per person returned (emails included).
const team = await skrap.enrich.companyContacts({
domain: 'example.com',
seniority: ['vp', 'director'],
department: ['sales'],
country: ['US'],
limit: 10,
page: 1,
});
team.people.forEach((x) => console.log(x.fullName, x.title, x.email?.address));
// The best contacts for a role, best match first. 1 credit per person with a verified work email;
// people without one are returned free (name and title only).
const dm = await skrap.enrich.decisionMakers({
domain: 'example.com',
role: 'sales', // founder_ceo, sales, marketing, engineering, hr, finance, operations
titles: ['Head of Revenue'], // optional: your own titles first, up to 10
country: ['US'],
limit: 3, // 1-10
});
dm.people.forEach((x) => console.log(x.tier, x.title, x.email?.address ?? '(no email)'));
dm.withEmail; // what you were charged forEvery enrichment answer carries creditsCharged and requestId.
Search leads and companies
The same search as the app. A search costs 0 credits: it uses one of your plan's daily searches. A repeat of a search you already made, and pages 2 and later, are free. Rows come without emails. Use a key with the search scope (or full access).
const page = await skrap.search.leads({
filters: {
seniority: { include: ['300', '220'] }, // VP, director
department: { include: ['sales'] },
location: { include: [{ id: '101282230', text: 'Germany' }] }, // or a plain name: ['Germany']
},
page: 1,
});
// The first answer can be partial while the rest of the page loads.
let rows = page.results;
let state = page;
while (state.status === 'partial' && state.continuationToken) {
await new Promise((r) => setTimeout(r, 2000));
state = await skrap.search.continuePage(state.continuationToken);
rows = [...rows, ...state.results.filter((x) => !rows.some((y) => y.id === x.id))];
}
// Companies: the same call with searchKind 'company'.
const companies = await skrap.search.companies({ filters: { company_keywords: { include: ['fintech'] }, year_founded: { min: 2018 } } });
const { definitions, catalog } = await skrap.search.filters(); // every filter and option id (cache it)
const { suggestions } = await skrap.search.typeahead({ entity: 'company', q: 'stripe' }); // ids for company and place filters
// The work email of a person row: 1 credit for a valid or risky email; not found is free.
const lead = rows[0]!;
const e = await skrap.search.leadEmail(lead.id, { name: lead.name, domain: lead.domain });
if (e.pendingRefinement) await skrap.waitForFindRefinement(e.requestId);When the day's searches are used up you get a RateLimitError with code QUOTA_EXCEEDED; retryAfter says when the counter resets (00:00 UTC). An expired continuation token throws a SkrapError with status 410 and code CONTINUATION_EXPIRED: run the search again.
Bulk jobs
A bulk job takes up to 25,000 rows and runs in the background. Each verify row is charged once, when it settles as valid or risky.
const job = await skrap.bulk.verify({ emails: ['[email protected]', '[email protected]'], listName: 'Q2' });
const job2 = await skrap.bulk.find({
data: [
{ firstName: 'Jane', lastName: 'Doe', domain: 'example.com' },
{ firstName: 'Li', company: 'Acme' },
],
});
const task = await skrap.tasks.get(job.taskId); // status + progress
const done = await skrap.tasks.wait(job.taskId, { // poll until completed, failed, cancelled or paused
intervalMs: 5000,
onProgress: (t) => console.log(t.progress.percentage),
});
const page = await skrap.tasks.results(job.taskId, { offset: 0, limit: 50 }); // one page
for await (const row of skrap.tasks.iterResults(job.taskId)) { // every row
console.log(row.email, row.status);
}
const { csv, filename } = await skrap.tasks.download(job.taskId); // results CSV
const { downloadUrl, expiresIn } = await skrap.tasks.downloadUrl(job.taskId); // signed link to the stored file
await skrap.tasks.pause(job.taskId);
await skrap.tasks.resume(job.taskId);
await skrap.tasks.cancel(job.taskId); // rows already processed stay charged; nothing else isA job also pauses itself when credits run out (metadata.pauseReason: 'insufficient_credits'). Resume it after a top-up. While a job has no results yet, tasks.download() throws a SkrapError with code TASK_PROCESSING (status 202). Results are kept for 30 days. After that, results and downloads fail with status 410 and code RESULTS_EXPIRED. You can also subscribe to the bulk_job.completed webhook instead of polling.
Lists
const { lists } = await skrap.lists.list({ kind: 'prospect' }); // [{ id, name, kind, leadCount }]
const { list } = await skrap.lists.create({ name: 'Q2 outbound', kind: 'prospect' }); // 'prospect' or 'company'
await skrap.lists.addLead(list.id, {
id: 'lead-123', // your id, unique in the list
name: 'Jane Doe',
company: 'Example Inc',
email: '[email protected]', // required on prospect (people) lists
emailStatus: 'valid',
jobRole: 'CTO',
domain: 'example.com',
});
await skrap.lists.transferLeads(list.id, { targetListId: 'other-list-id', leadIds: ['lead-123'], mode: 'move' });
const { csv, suppressed } = await skrap.lists.export({ ids: [list.id], kind: 'prospect' });
// ids defaults to 'all'; leads on your do-not-contact list are left out unless includeSuppressed: trueAdding a lead whose id or email is already in the list throws a ConflictError (409).
Account
const me = await skrap.account.get(); // { id, email, plan, credits, team, apiKey }This call is free, so it works well as a connection test.
Usage
What your keys and your team spent: single requests and bulk jobs, newest first, with the credits each one cost. Free. Use a key with the account scope (or full access). Team owners and admins see the whole team; members see their own usage.
const page = await skrap.usage.list({
from: '2026-11-01', // YYYY-MM-DD (UTC), ISO timestamp or Date; default: the last 30 days
to: '2026-11-14',
tool: ['verify', 'find'], // verify, find, search, enrichment, bulk, bulk-verify, bulk-find, other
kind: 'request', // or 'bulk_job'
apiKeyId: 'key-id', // optional
limit: 100, // 1-500
});
page.items; // [{ timestamp, endpoint, tool, status, credits, apiKeyName, userEmail, requestId, sandbox, ... }]
page.totals; // { credits, requests, bulkJobs } over the whole range
page.nextCursor; // pass as cursor for the next page
for await (const item of skrap.usage.iterItems({ from: '2026-11-01' })) {
console.log(item.timestamp, item.endpoint, item.credits);
}
const { csv, rows, truncated } = await skrap.usage.export({ from: '2026-11-01', to: '2026-11-14' }); // up to 100,000 rowsWebhooks
const hook = await skrap.webhooks.create({
url: 'https://example.com/skrap-webhook',
events: ['bulk_job.completed', 'credits.low'],
});
hook.secret; // signing secret, returned only once: store it
const { webhooks } = await skrap.webhooks.list();
await skrap.webhooks.delete(hook.id);
const [example] = await skrap.webhooks.sample('bulk_job.completed');The events are bulk_job.completed, bulk_job.failed, credits.low and list.lead_added. Webhooks are available on paid plans. On a team, only owners and admins can subscribe or remove them.
Verify webhook signatures
Pass the raw request body exactly as received. A body you parsed and serialized again will not match the signature.
import { constructWebhookEvent, WebhookSignatureError } from 'skrap-ai';
app.post('/skrap-webhook', express.raw({ type: 'application/json' }), (req, res) => {
try {
const event = constructWebhookEvent(req.body, req.header('skrap-signature'), process.env.SKRAP_WEBHOOK_SECRET!);
// de-duplicate with the Skrap-Event-Id header, then handle event.type / event.data
res.sendStatus(200);
} catch (err) {
if (err instanceof WebhookSignatureError) return res.status(400).send(err.message);
throw err;
}
});verifyWebhookSignature(rawBody, header, secret) returns a boolean instead of throwing. Both functions reject signatures older than 5 minutes by default; change that with { toleranceSec }. The same functions are also available as skrap.webhooks.verifySignature() and skrap.webhooks.constructEvent().
Errors
Every failure throws a SkrapError. Specific cases use these subclasses:
| Class | HTTP | Typical code |
| --- | --- | --- |
| ValidationError | 400 | VALIDATION_ERROR, UNSUPPORTED_EMAIL |
| AuthenticationError | 401 | INVALID_API_KEY, API_KEY_EXPIRED |
| InsufficientCreditsError | 402 | INSUFFICIENT_CREDITS, MEMBER_CREDIT_LIMIT, OVERAGE_LIMIT, OVERAGE_BLOCKED |
| PermissionDeniedError | 403 | PLAN_REQUIRED, SCOPE_REQUIRED, IP_NOT_ALLOWED, FEATURE_NOT_AVAILABLE, RESULTS_CAP, ACCESS_DENIED, AUTHORIZATION_ERROR |
| NotFoundError | 404 | NOT_FOUND, TASK_NOT_FOUND |
| ConflictError | 409 | IDEMPOTENCY_KEY_REUSED, IDEMPOTENCY_REQUEST_IN_PROGRESS, (duplicate list or lead) |
| RateLimitError | 429 | RATE_LIMITED, RATE_LIMIT_EXCEEDED, QUOTA_EXCEEDED, KEY_CREDIT_CAP, ENRICH_DAILY_LIMIT, DECISION_MAKERS_DAILY_LIMIT, FREE_ENRICH_LIMIT |
| ServerError | 5xx | INTERNAL_ERROR, ENRICH_UNAVAILABLE, CREDIT_CONTENTION |
| APIConnectionError | none | CONNECTION_ERROR |
| APITimeoutError | none | TIMEOUT |
Other statuses, such as 410 RESULTS_EXPIRED and CONTINUATION_EXPIRED, throw the base SkrapError.
import { InsufficientCreditsError, RateLimitError, SkrapError } from 'skrap-ai';
try {
await skrap.verifyEmail('[email protected]');
} catch (err) {
if (err instanceof InsufficientCreditsError) {
console.log(err.details); // { required, available, shortfall }
} else if (err instanceof RateLimitError) {
console.log(`retry in ${err.retryAfter}s`, err.body); // plan, planName, limitPerMinute, upgrade
} else if (err instanceof SkrapError) {
console.log(err.status, err.code, err.message, err.retryable, err.requestId);
}
}Every SkrapError has these fields:
status: the HTTP status, ornullwhen no response arrived.code: the API's error code. Some endpoints, such as list errors, send no code, so it can benull.messageretryable: the API'sretryableflag when it sends one. Otherwise it is true for 429, 5xx, connection errors and timeouts.retryAfter: in seconds.details,bodyandheadersrequestId: currentlynullfor most errors, because error responses do not carry a request id.
Aborting through your signal throws the signal's abort reason (an AbortError), not a SkrapError.
Retries
The SDK retries automatically (2 times by default):
- 429, 500 and 503: always retried. The API did no work and charged nothing.
- 502, 504, network errors and timeouts: retried only for calls that are safe to repeat. These are verify, find (a repeat is free) and all reads. Bulk job creation, enrichment, list writes, webhook changes and task controls are not retried after an unknown outcome, so they never run twice.
- Waiting: the SDK waits the
Retry-Afterheader (orretryAfterSec) when the API sends one. Otherwise it backs off exponentially with jitter, from 0.5 s up to 8 s. - Long waits: if the API asks to wait longer than
maxRetryDelayMs(60 s by default), the SDK throws right away witherror.retryAfterset. This happens with the daily enrichment limit, for example. - No retry: a response with
retryable: falseis never retried.
Idempotent retries
Give a POST an idempotencyKey and the API remembers its successful answer for 24 hours: the same key with the same body gets that answer again, with no second charge and no second job, list or webhook. The key is sent as the Idempotency-Key header (1-255 printable ASCII characters; use a new UUID for each logical operation).
import { randomUUID } from 'node:crypto';
const job = await skrap.bulk.verify({ emails }, { idempotencyKey: randomUUID() });It works on verify, find, the enrichment calls, bulk.verify, bulk.find, lists.create, lists.addLead and webhooks.create. With a key, the SDK also retries those calls after a network error or timeout, using the same key, and waits out a 409 IDEMPOTENCY_REQUEST_IN_PROGRESS while the first attempt is still running. The same key with a different body throws a ConflictError with code IDEMPOTENCY_KEY_REUSED.
Plan rate limits are per key: Free 30, Professional 120 and Enterprise 600 requests a minute.
Response details
Each result has a non-enumerable lastResponse property. It is left out of JSON.stringify and Object.keys.
const r = await skrap.verifyEmail('[email protected]');
r.lastResponse.status; // 200
r.lastResponse.requestId; // x-request-id header, else the body's requestId (find and enrichment), else null
r.lastResponse.rateLimit; // { limit, remaining, reset } from the RateLimit headers, or null
r.lastResponse.headers;Examples
The examples import the built package, so run npm run build first.
examples/verify-then-find.mjs: verify, then find, with error handlingexamples/bulk-verify.mjs: bulk job, wait, results, CSVexamples/webhook-server.mjs: receive webhooks and check their signatures
Documentation
- API reference: https://skrap.ai/docs/api
- Webhooks: https://skrap.ai/docs/webhooks
- OpenAPI: https://skrap.ai/openapi.json
License
MIT. See LICENSE.
