From 64347fd4cfd05c2a4f796523421a330b9a0dd6d1 Mon Sep 17 00:00:00 2001 From: Arslan Date: Thu, 19 Nov 2026 18:58:56 +0500 Subject: [PATCH] 0.2.0: company keywords, priorities on people search, counts, usage limits - companies.search: keywords and exclude_keywords; companies carry specialties and email_domain. - people.search: company_keywords, exclude_company_keywords, match_headline, and priorities with company_linkedin_url (best contacts at one company, each tagged with priority; the response carries the matched company). People carry headline. - people.count and companies.count: how many records match, using no records. - Usage.limits and Usage.resets_at. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BxPEbT7C4cZ5KH8Dp8b8FQ --- CHANGELOG.md | 17 ++++++++++ README.md | 21 +++++++++++- package-lock.json | 4 +-- package.json | 2 +- src/resources/companies.ts | 15 +++++++++ src/resources/people.ts | 15 +++++++++ src/types.ts | 69 ++++++++++++++++++++++++++++++++++++-- src/version.ts | 2 +- test/client.test.ts | 61 +++++++++++++++++++++++++++++++++ 9 files changed, 199 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43b318a..8291948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/README.md b/README.md index 7675a71..4f1360c 100644 --- a/README.md +++ b/README.md @@ -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({ diff --git a/package-lock.json b/package-lock.json index 68ec3e8..ca384e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@leadsetsai/sdk", - "version": "0.1.1", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@leadsetsai/sdk", - "version": "0.1.1", + "version": "0.2.0", "license": "MIT", "devDependencies": { "@biomejs/biome": "^2.6.6", diff --git a/package.json b/package.json index db26432..3a21605 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/resources/companies.ts b/src/resources/companies.ts index f32170c..9fbb091 100644 --- a/src/resources/companies.ts +++ b/src/resources/companies.ts @@ -6,6 +6,7 @@ import type { Company, CompanyEnrichParams, CompanyEnrichResponse, + CountResponse, } from '../types.js' export class Companies { @@ -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 = {}, + options?: RequestOptions, + ): Promise { + 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 { return items(this.searchPages(params, options)) diff --git a/src/resources/people.ts b/src/resources/people.ts index 4d9fcf7..d930362 100644 --- a/src/resources/people.ts +++ b/src/resources/people.ts @@ -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, @@ -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 = {}, + options?: RequestOptions, + ): Promise { + 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 { return items(this.searchPages(params, options)) diff --git a/src/types.ts b/src/types.ts index 9070649..a28ba48 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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 + /** Paid plans: when the oldest usage leaves each window (ISO 8601), e.g. `search_5h`, `search_week`. */ + resets_at?: Record + [key: string]: number | boolean | Record | Record | undefined } /** Rate-limit headers of a response, parsed. `null` when the header was absent. */ @@ -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 @@ -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 @@ -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 @@ -140,13 +150,43 @@ export interface Person { sources: Record } +/** One group of titles for `PeopleSearchParams.priorities`, best first. */ +export interface PeoplePriority { + /** Titles for this priority, fuzzy-matched like `title`. */ + title: OneOrMany + /** Titles that rule a person out of this priority, e.g. ["assistant", "intern"]. */ + exclude_title?: OneOrMany + /** Replaces the top-level `seniority` for this priority. */ + seniority?: OneOrMany + /** Replaces the top-level `function` for this priority. */ + function?: OneOrMany + /** Replaces the top-level `country` for this priority. */ + country?: OneOrMany + /** 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 + /** Also match title words against the LinkedIn headline. */ + match_headline?: boolean seniority?: OneOrMany function?: OneOrMany /** Only people at these companies (domains). */ company_domain?: OneOrMany + /** 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 + /** Leave out people whose company mentions any of these. */ + exclude_company_keywords?: OneOrMany + /** + * 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". */ @@ -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 { @@ -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 @@ -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 @@ -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 + /** Leave out companies that mention any of these, e.g. ["pottery"]. */ + exclude_keywords?: OneOrMany industry?: OneOrMany /** Headcount range, e.g. "50-200" or "1000+". */ employees?: string country?: OneOrMany /** Technologies the company uses, e.g. "hubspot". Matches any. */ technology?: OneOrMany - /** Only these domains. */ + /** Only these domains (website or email domain). */ domain?: OneOrMany max_age_days?: number exclude_stale?: boolean diff --git a/src/version.ts b/src/version.ts index fbb733b..5c5211b 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.1' +export const VERSION = '0.2.0' diff --git a/test/client.test.ts b/test/client.test.ts index ec5f57a..cd0b49a 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -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) + }) +})