Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this package are documented here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
[Semantic Versioning](https://semver.org/).

## [0.2.0] - 2026-11-19

### Added

- `companies.search`: `keywords` and `exclude_keywords`, matched as whole words in the company's
name, description and specialties. Companies carry `specialties` and `email_domain`.
- `people.search`: `company_keywords` and `exclude_company_keywords` (what the person's company does),
`match_headline` (title words also match the LinkedIn headline) and `priorities` with
`company_linkedin_url`: the best contacts at one company, in your order of preference, each
tagged with `priority`. People carry `headline`; the response carries `company` with `priorities`.
- `people.count` and `companies.count`: how many records match (`count`, `count_capped`), using no
records.
- `Usage.limits` and `Usage.resets_at`: the limits behind the remaining counts, and when each window
resets.

## [0.1.1] - 2026-11-11

### Changed
Expand All @@ -25,4 +40,6 @@ All notable changes to this package are documented here. The format follows
- Parsed rate-limit headers on `lastResponse.rateLimit`.
- ESM and CommonJS builds with type declarations; no runtime dependencies.

[0.2.0]: https://github.com/leadsets/sdk/releases/tag/v0.2.0
[0.1.1]: https://github.com/leadsets/sdk/releases/tag/v0.1.1
[0.1.0]: https://github.com/leadsets/sdk/releases/tag/v0.1.0
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,26 @@ Every method takes an optional last argument with [request options](#per-request

### People search

Filters: `title`, `seniority` (`c_level`, `vp`, `head`, `director`, `manager`, `ic`), `function` (`revenue`, `marketing`, `engineering`, `product`, `ops`, `finance`, `hr`), `company_domain`, `employees` (`"50-200"`, `"1000+"`, `"<50"`), `industry` (slugs such as `"saas"`), `country` (ISO 3166-1 alpha-2), `has_verified_email`, `max_age_days`, `exclude_stale`, `limit` (1–100, default 25) and `cursor`. A string or an array works wherever a list is accepted.
Filters: `title` (add `match_headline: true` to also match the LinkedIn headline), `seniority` (`c_level`, `vp`, `head`, `director`, `manager`, `ic`), `function` (`revenue`, `marketing`, `engineering`, `product`, `ops`, `finance`, `hr`), `company_domain`, `company_keywords` / `exclude_company_keywords` (what their company does), `employees` (`"50-200"`, `"1000+"`, `"<50"`), `industry` (slugs such as `"saas"`), `country` (ISO 3166-1 alpha-2), `has_verified_email`, `max_age_days`, `exclude_stale`, `limit` (1–100, default 25) and `cursor`. A string or an array works wherever a list is accepted.

Count before you pull, for free, and find the best contacts at one company in your order of preference:

```ts
const { count } = await ls.companies.count({
keywords: ['clay', 'gtm engineering'],
exclude_keywords: ['pottery'],
country: 'US',
})

const res = await ls.people.search({
company_domain: 'northwind.io',
priorities: [{ title: ['founder', 'ceo'], match_headline: true }, { title: ['head of growth', 'vp sales'] }],
limit: 3,
})
for (const p of res.items) console.log(p.priority, p.full_name, p.email?.address)
```

`companies.search` also takes `keywords` and `exclude_keywords`: whole words in the company's name, description and specialties.

```ts
const res = await ls.people.search({
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@leadsetsai/sdk",
"version": "0.1.1",
"version": "0.2.0",
"description": "Official TypeScript and JavaScript SDK for the Leadsets B2B data API: people and company search, enrichment, email verification and web scraping.",
"license": "MIT",
"author": "Leadsets",
Expand Down
15 changes: 15 additions & 0 deletions src/resources/companies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
Company,
CompanyEnrichParams,
CompanyEnrichResponse,
CountResponse,
} from '../types.js'

export class Companies {
Expand All @@ -16,6 +17,20 @@ export class Companies {
return this.http.request({ method: 'POST', path: '/companies/search', body: params, idempotent: true }, options)
}

/**
* POST /v1/companies/search with `count_only`: how many companies match, without returning them.
* Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
*/
count(
params: Omit<CompaniesSearchParams, 'limit' | 'cursor'> = {},
options?: RequestOptions,
): Promise<CountResponse> {
return this.http.request(
{ method: 'POST', path: '/companies/search', body: { ...params, count_only: true }, idempotent: true },
options,
)
}

/** Every matching company, page after page. Use `maxItems` to cap what you pay for. */
searchAll(params: CompaniesSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Company, void, undefined> {
return items<Company, CompaniesSearchResponse>(this.searchPages(params, options))
Expand Down
15 changes: 15 additions & 0 deletions src/resources/people.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { HttpClient, RequestOptions } from '../core.js'
import { items, type PaginationOptions, paginate } from '../pagination.js'
import type {
CountResponse,
PeopleSearchParams,
PeopleSearchResponse,
Person,
Expand All @@ -16,6 +17,20 @@ export class People {
return this.http.request({ method: 'POST', path: '/people/search', body: params, idempotent: true }, options)
}

/**
* POST /v1/people/search with `count_only`: how many people match, without returning them.
* Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
*/
count(
params: Omit<PeopleSearchParams, 'limit' | 'cursor' | 'priorities'> = {},
options?: RequestOptions,
): Promise<CountResponse> {
return this.http.request(
{ method: 'POST', path: '/people/search', body: { ...params, count_only: true }, idempotent: true },
options,
)
}

/** Every matching person, page after page. Use `maxItems` to cap what you pay for. */
searchAll(params: PeopleSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Person, void, undefined> {
return items<Person, PeopleSearchResponse>(this.searchPages(params, options))
Expand Down
69 changes: 67 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export interface Usage {
scrape_units_left?: number
/** True when limits could not be checked for this call. */
degraded?: boolean
[key: string]: number | boolean | undefined
/** Paid plans: the limits behind the `*_left_*` numbers, e.g. `search_records_5h`, `concurrent_searches`. */
limits?: Record<string, number>
/** Paid plans: when the oldest usage leaves each window (ISO 8601), e.g. `search_5h`, `search_week`. */
resets_at?: Record<string, string | null>
[key: string]: number | boolean | Record<string, number> | Record<string, string | null> | undefined
}

/** Rate-limit headers of a response, parsed. `null` when the header was absent. */
Expand Down Expand Up @@ -107,6 +111,8 @@ export interface PersonCompany {
company_id: string | null
name: string | null
domain: string | null
/** The domain the company's work emails use, when known. */
email_domain?: string | null
industry: string | null
employees: number | null
employee_range: string | null
Expand All @@ -118,6 +124,8 @@ export interface Person {
first_name: string | null
last_name: string | null
title: string | null
/** LinkedIn headline, when known. */
headline?: string | null
seniority: Seniority | null
/** Finer-grained seniority, e.g. "founder" or "senior". */
seniority_detail: string | null
Expand All @@ -132,6 +140,8 @@ export interface Person {
personal_email?: Email | null
/** Which filters this record matched (search results only). */
match_reasons?: string[]
/** With `priorities`: which priority found this person (1 for the first group). */
priority?: number
refreshed_at: string | null
confirmed_at: string | null
stale_after_at: string | null
Expand All @@ -140,13 +150,43 @@ export interface Person {
sources: Record<string, FieldSource>
}

/** One group of titles for `PeopleSearchParams.priorities`, best first. */
export interface PeoplePriority {
/** Titles for this priority, fuzzy-matched like `title`. */
title: OneOrMany<string>
/** Titles that rule a person out of this priority, e.g. ["assistant", "intern"]. */
exclude_title?: OneOrMany<string>
/** Replaces the top-level `seniority` for this priority. */
seniority?: OneOrMany<Seniority>
/** Replaces the top-level `function` for this priority. */
function?: OneOrMany<PersonFunction>
/** Replaces the top-level `country` for this priority. */
country?: OneOrMany<string>
/** Also match these titles against the LinkedIn headline. */
match_headline?: boolean
}

export interface PeopleSearchParams {
/** Job titles. Fuzzy-matched: "VP Sales" also finds "Vice President, Sales". */
title?: OneOrMany<string>
/** Also match title words against the LinkedIn headline. */
match_headline?: boolean
seniority?: OneOrMany<Seniority>
function?: OneOrMany<PersonFunction>
/** Only people at these companies (domains). */
company_domain?: OneOrMany<string>
/** With `priorities`: the company by its LinkedIn page, instead of `company_domain`. */
company_linkedin_url?: string
/** What their company does, e.g. ["clay", "gtm engineering"]: whole words in its name, description and specialties. */
company_keywords?: OneOrMany<string>
/** Leave out people whose company mentions any of these. */
exclude_company_keywords?: OneOrMany<string>
/**
* Best contacts at ONE company (one `company_domain` or `company_linkedin_url`): 1–10 groups of
* titles, best first. Results fill from the first group, never repeat a person and carry
* `priority`. `limit` 1–25 (default 5); no cursor, no top-level `title`.
*/
priorities?: PeoplePriority[]
/** Company headcount range, e.g. "50-200", "1000+" or "<50". */
employees?: string
/** Leadsets industry slugs, e.g. "saas". */
Expand All @@ -170,6 +210,23 @@ export interface PeopleSearchParams {
export interface PeopleSearchResponse extends APIResponse {
items: Person[]
next_cursor: string | null
/** With `priorities`: the company that was matched, or null when none is on file. */
company?: {
company_id: string | null
name: string | null
domain: string | null
email_domain: string | null
linkedin_url: string | null
} | null
/** With `priorities`, when no company is on file for the LinkedIn page. */
note?: string
}

/** `people.count` / `companies.count`: how many records match. Uses no records. */
export interface CountResponse extends APIResponse {
count: number
/** True when counting stopped at 10,000: there are at least `count` matches. */
count_capped: boolean
}

export interface PersonEnrichParams {
Expand Down Expand Up @@ -201,6 +258,8 @@ export interface Company {
company_id: string
name: string | null
domain: string | null
/** The domain its work emails use, when known (may differ from `domain`). */
email_domain?: string | null
linkedin_url: string | null
industry: string | null
naics: string | null
Expand All @@ -211,6 +270,8 @@ export interface Company {
founded_year: number | null
description: string | null
technologies: string[]
/** What the company says it does (LinkedIn specialties). */
specialties?: string[]
match_reasons?: string[]
refreshed_at: string | null
confirmed_at: string | null
Expand All @@ -220,13 +281,17 @@ export interface Company {
}

export interface CompaniesSearchParams {
/** What the company does, e.g. ["lead generation", "appointment setting"]: whole words in its name, description and specialties; any matches. */
keywords?: OneOrMany<string>
/** Leave out companies that mention any of these, e.g. ["pottery"]. */
exclude_keywords?: OneOrMany<string>
industry?: OneOrMany<string>
/** Headcount range, e.g. "50-200" or "1000+". */
employees?: string
country?: OneOrMany<string>
/** Technologies the company uses, e.g. "hubspot". Matches any. */
technology?: OneOrMany<string>
/** Only these domains. */
/** Only these domains (website or email domain). */
domain?: OneOrMany<string>
max_age_days?: number
exclude_stale?: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.1.1'
export const VERSION = '0.2.0'
61 changes: 61 additions & 0 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,64 @@ describe('endpoints', () => {
expect(res.lastResponse.idempotencyKey).toBe('row-1')
})
})

describe('keywords, priorities and counts', () => {
it('count sends count_only and returns the count', async () => {
const m = mockFetch({
body: { count: 10_000, count_capped: true, usage: { search_records_counted: 0 }, request_id: 'req_1' },
})
const ls = client(m)
const res = await ls.companies.count({
keywords: ['clay', 'gtm engineering'],
exclude_keywords: 'pottery',
country: 'US',
})
expect(m.calls[0]?.url).toMatch(/\/v1\/companies\/search$/)
expect(m.calls[0]?.body).toEqual({
keywords: ['clay', 'gtm engineering'],
exclude_keywords: 'pottery',
country: 'US',
count_only: true,
})
expect(res).toMatchObject({ count: 10_000, count_capped: true })
await ls.people.count({ company_keywords: 'clay', title: 'founder', match_headline: true })
expect(m.calls[1]?.url).toMatch(/\/v1\/people\/search$/)
expect(m.calls[1]?.body).toMatchObject({ company_keywords: 'clay', count_only: true })
})

it('search with priorities sends them as given and types the answer', async () => {
const m = mockFetch({
body: {
company: {
company_id: 'c1',
name: 'Northwind',
domain: 'northwind.io',
email_domain: 'northwind.com',
linkedin_url: null,
},
items: [{ ...person(), priority: 1, headline: 'Founder at Northwind' }],
next_cursor: null,
usage: { ...usage, limits: { search_records_5h: 7500 }, resets_at: { search_5h: '2026-11-19T18:30:00Z' } },
request_id: 'req_1',
},
})
const res = await client(m).people.search({
company_domain: 'northwind.io',
priorities: [
{ title: ['founder', 'ceo'], match_headline: true },
{ title: 'head of growth', exclude_title: 'intern' },
],
limit: 3,
})
expect(m.calls[0]?.body).toMatchObject({
priorities: [
{ title: ['founder', 'ceo'], match_headline: true },
{ title: 'head of growth', exclude_title: 'intern' },
],
})
expect(res.company?.email_domain).toBe('northwind.com')
expect(res.items[0]?.priority).toBe(1)
expect(res.items[0]?.headline).toBe('Founder at Northwind')
expect(res.usage.limits?.search_records_5h).toBe(7500)
})
})
Loading