From b790155d2feba9e2eb59f220efa9848688346cd4 Mon Sep 17 00:00:00 2001 From: Arslan Date: Thu, 19 Nov 2026 18:58:59 +0500 Subject: [PATCH 1/3] 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 | 15 ++++++ README.md | 18 ++++++- src/leadsets/_version.py | 2 +- src/leadsets/resources/companies.py | 55 +++++++++++++++++++++- src/leadsets/resources/people.py | 55 +++++++++++++++++++++- src/leadsets/types.py | 73 +++++++++++++++++++++++++++++ tests/test_async.py | 9 ++++ tests/test_client.py | 54 +++++++++++++++++++++ 8 files changed, 277 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce0fb7e..2af6d03 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. `Company` has `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`. `Person` has `headline`; the response has `company` with `priorities`. +- `people.count` and `companies.count` (sync and async): 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.2] - 2026-11-11 ### Changed diff --git a/README.md b/README.md index ada7261..ec8434a 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,23 @@ Responses are dataclasses: `res.items[0].email.status`. `obj.to_dict()` returns ### 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 a list 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 a list 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: + +```python +n = ls.companies.count(keywords=["clay", "gtm engineering"], exclude_keywords=["pottery"], country="US").count + +res = ls.people.search( + company_domain="northwind.io", + priorities=[{"title": ["founder", "ceo"], "match_headline": True}, {"title": ["head of growth", "vp sales"]}], + limit=3, +) +for p in res.items: + print(p.priority, p.full_name, p.email.address if p.email else None) +``` + +`companies.search` also takes `keywords` and `exclude_keywords`: whole words in the company's name, description and specialties. ```python res = ls.people.search( diff --git a/src/leadsets/_version.py b/src/leadsets/_version.py index b3f4756..d3ec452 100644 --- a/src/leadsets/_version.py +++ b/src/leadsets/_version.py @@ -1 +1 @@ -__version__ = "0.1.2" +__version__ = "0.2.0" diff --git a/src/leadsets/resources/companies.py b/src/leadsets/resources/companies.py index 92f4b39..809a3be 100644 --- a/src/leadsets/resources/companies.py +++ b/src/leadsets/resources/companies.py @@ -7,7 +7,14 @@ from .._base import clean from .._pagination import aiter_pages, iter_pages -from ..types import CompaniesSearchParams, CompaniesSearchResponse, Company, CompanyEnrichParams, CompanyEnrichResponse +from ..types import ( + CompaniesSearchParams, + CompaniesSearchResponse, + Company, + CompanyEnrichParams, + CompanyEnrichResponse, + CountResponse, +) from ._compat import Unpack if TYPE_CHECKING: @@ -40,6 +47,29 @@ def search( extra_headers=extra_headers, ) + def count( + self, + *, + timeout: float | httpx.Timeout | None = None, + max_retries: int | None = None, + extra_headers: Mapping[str, str] | None = None, + **params: Unpack[CompaniesSearchParams], + ) -> CountResponse: + """POST /companies/search with ``count_only``: how many match, without returning them. + + Uses no records; counts as one request. Counting stops at 10,000 (``count_capped``). + """ + return self._client.request( + "POST", + "/companies/search", + CountResponse, + body={**clean(params), "count_only": True}, + idempotent=True, + timeout=timeout, + max_retries=max_retries, + extra_headers=extra_headers, + ) + def search_pages( self, *, @@ -142,6 +172,29 @@ async def search( extra_headers=extra_headers, ) + async def count( + self, + *, + timeout: float | httpx.Timeout | None = None, + max_retries: int | None = None, + extra_headers: Mapping[str, str] | None = None, + **params: Unpack[CompaniesSearchParams], + ) -> CountResponse: + """POST /companies/search with ``count_only``: how many match, without returning them. + + Uses no records; counts as one request. Counting stops at 10,000 (``count_capped``). + """ + return await self._client.request( + "POST", + "/companies/search", + CountResponse, + body={**clean(params), "count_only": True}, + idempotent=True, + timeout=timeout, + max_retries=max_retries, + extra_headers=extra_headers, + ) + def search_pages( self, *, diff --git a/src/leadsets/resources/people.py b/src/leadsets/resources/people.py index 2e5eaaf..ae19254 100644 --- a/src/leadsets/resources/people.py +++ b/src/leadsets/resources/people.py @@ -7,7 +7,14 @@ from .._base import clean from .._pagination import aiter_pages, iter_pages -from ..types import PeopleSearchParams, PeopleSearchResponse, Person, PersonEnrichParams, PersonEnrichResponse +from ..types import ( + CountResponse, + PeopleSearchParams, + PeopleSearchResponse, + Person, + PersonEnrichParams, + PersonEnrichResponse, +) from ._compat import Unpack if TYPE_CHECKING: @@ -40,6 +47,29 @@ def search( extra_headers=extra_headers, ) + def count( + self, + *, + timeout: float | httpx.Timeout | None = None, + max_retries: int | None = None, + extra_headers: Mapping[str, str] | None = None, + **params: Unpack[PeopleSearchParams], + ) -> CountResponse: + """POST /people/search with ``count_only``: how many match, without returning them. + + Uses no records; counts as one request. Counting stops at 10,000 (``count_capped``). + """ + return self._client.request( + "POST", + "/people/search", + CountResponse, + body={**clean(params), "count_only": True}, + idempotent=True, + timeout=timeout, + max_retries=max_retries, + extra_headers=extra_headers, + ) + def search_pages( self, *, @@ -142,6 +172,29 @@ async def search( extra_headers=extra_headers, ) + async def count( + self, + *, + timeout: float | httpx.Timeout | None = None, + max_retries: int | None = None, + extra_headers: Mapping[str, str] | None = None, + **params: Unpack[PeopleSearchParams], + ) -> CountResponse: + """POST /people/search with ``count_only``: how many match, without returning them. + + Uses no records; counts as one request. Counting stops at 10,000 (``count_capped``). + """ + return await self._client.request( + "POST", + "/people/search", + CountResponse, + body={**clean(params), "count_only": True}, + idempotent=True, + timeout=timeout, + max_retries=max_retries, + extra_headers=extra_headers, + ) + def search_pages( self, *, diff --git a/src/leadsets/types.py b/src/leadsets/types.py index fc69af4..1e60f3b 100644 --- a/src/leadsets/types.py +++ b/src/leadsets/types.py @@ -68,13 +68,43 @@ # ---- Request parameters ---------------------------------------------------------------------- +class PeoplePriority(TypedDict, total=False): + """One group of titles for ``PeopleSearchParams.priorities``, best first. ``title`` is required.""" + + #: Titles for this priority, fuzzy-matched like ``title``. + title: _StrList + #: Titles that rule a person out of this priority, e.g. ["assistant", "intern"]. + exclude_title: _StrList + #: Replaces the top-level ``seniority`` for this priority. + seniority: Seniority | Sequence[Seniority] + #: Replaces the top-level ``function`` for this priority. + function: PersonFunction | Sequence[PersonFunction] + #: Replaces the top-level ``country`` for this priority. + country: _StrList + #: Also match these titles against the LinkedIn headline. + match_headline: bool + + class PeopleSearchParams(TypedDict, total=False): #: Job titles. Fuzzy-matched: "VP Sales" also finds "Vice President, Sales". title: _StrList + #: Also match title words against the LinkedIn headline. + match_headline: bool seniority: Seniority | Sequence[Seniority] function: PersonFunction | Sequence[PersonFunction] #: Only people at these companies (domains). company_domain: _StrList + #: With ``priorities``: the company by its LinkedIn page, instead of ``company_domain``. + company_linkedin_url: str + #: What their company does, e.g. ["clay", "gtm engineering"]: whole words in its name, + #: description and specialties. + company_keywords: _StrList + #: Leave out people whose company mentions any of these. + exclude_company_keywords: _StrList + #: Best contacts at ONE company (one ``company_domain`` or ``company_linkedin_url``): 1–10 + #: groups of titles, best first. Results never repeat a person and carry ``priority``. + #: ``limit`` 1–25 (default 5); no cursor, no top-level ``title``. + priorities: Sequence[PeoplePriority] #: Company headcount range, e.g. "50-200", "1000+" or "<50". employees: str #: Leadsets industry slugs, e.g. "saas". @@ -103,6 +133,11 @@ class PersonEnrichParams(TypedDict, total=False): class CompaniesSearchParams(TypedDict, total=False): + #: What the company does, e.g. ["lead generation", "appointment setting"]: whole words in its + #: name, description and specialties; any keyword matches. + keywords: _StrList + #: Leave out companies that mention any of these, e.g. ["pottery"]. + exclude_keywords: _StrList industry: _StrList employees: str country: _StrList @@ -203,6 +238,10 @@ class Usage(Model): scrape_units_left: int | None = None #: True when limits could not be checked for this call. degraded: bool | None = None + #: Paid plans: the limits behind the ``*_left_*`` numbers, e.g. ``search_records_5h``. + limits: dict[str, int] | None = None + #: Paid plans: when the oldest usage leaves each window (ISO 8601), e.g. ``search_5h``. + resets_at: dict[str, str | None] | None = None @dataclasses.dataclass(kw_only=True) @@ -232,6 +271,8 @@ class PersonCompany(Model): company_id: str | None = None name: str | None = None domain: str | None = None + #: The domain the company's work emails use, when known. + email_domain: str | None = None industry: str | None = None employees: int | None = None employee_range: str | None = None @@ -244,6 +285,8 @@ class Person(Model): first_name: str | None = None last_name: str | None = None title: str | None = None + #: LinkedIn headline, when known. + headline: str | None = None seniority: Seniority | None = None #: Finer-grained seniority, e.g. "founder" or "senior". seniority_detail: str | None = None @@ -258,6 +301,8 @@ class Person(Model): personal_email: Email | None = None #: Which filters this record matched (search results only). match_reasons: list[str] | None = None + #: With ``priorities``: which priority found this person (1 for the first group). + priority: int | None = None refreshed_at: str | None = None confirmed_at: str | None = None stale_after_at: str | None = None @@ -266,10 +311,34 @@ class Person(Model): sources: dict[str, FieldSource] = dataclasses.field(default_factory=dict) +@dataclasses.dataclass(kw_only=True) +class MatchedCompany(Model): + """With ``priorities``: the company the search was scoped to.""" + + company_id: str | None = None + name: str | None = None + domain: str | None = None + email_domain: str | None = None + linkedin_url: str | None = None + + @dataclasses.dataclass(kw_only=True) class PeopleSearchResponse(APIResponse): items: list[Person] = dataclasses.field(default_factory=list) next_cursor: str | None = None + #: With ``priorities``: the company that was matched, or ``None`` when none is on file. + company: MatchedCompany | None = None + #: With ``priorities``, when no company is on file for the LinkedIn page. + note: str | None = None + + +@dataclasses.dataclass(kw_only=True) +class CountResponse(APIResponse): + """``people.count`` / ``companies.count``: how many records match. Uses no records.""" + + count: int = 0 + #: True when counting stopped at 10,000: there are at least ``count`` matches. + count_capped: bool = False @dataclasses.dataclass(kw_only=True) @@ -289,6 +358,8 @@ class Company(Model): company_id: str name: str | None = None domain: str | None = None + #: The domain its work emails use, when known (may differ from ``domain``). + email_domain: str | None = None linkedin_url: str | None = None industry: str | None = None naics: str | None = None @@ -299,6 +370,8 @@ class Company(Model): founded_year: int | None = None description: str | None = None technologies: list[str] = dataclasses.field(default_factory=list) + #: What the company says it does (LinkedIn specialties). + specialties: list[str] = dataclasses.field(default_factory=list) match_reasons: list[str] | None = None refreshed_at: str | None = None confirmed_at: str | None = None diff --git a/tests/test_async.py b/tests/test_async.py index 0beebde..8c094f4 100644 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -95,3 +95,12 @@ async def test_async_env_key(mock: respx.MockRouter, monkeypatch: pytest.MonkeyP async with AsyncLeadsets() as c: await c.usage.get() assert route.calls[0].request.headers["authorization"] == f"Bearer {KEY}" + + +async def test_async_count(als: AsyncLeadsets, mock: respx.MockRouter) -> None: + route = mock.post("/v1/people/search").respond(json={"count": 7, "count_capped": False, "request_id": "r"}) + res = await als.people.count(company_keywords="clay") + assert json.loads(route.calls[0].request.content) == {"company_keywords": "clay", "count_only": True} + assert res.count == 7 + mock.post("/v1/companies/search").respond(json={"count": 2, "count_capped": False, "request_id": "r"}) + assert (await als.companies.count(keywords="clay")).count == 2 diff --git a/tests/test_client.py b/tests/test_client.py index b85b2c1..f9fe60f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -375,3 +375,57 @@ def test_replayed(self, ls: Leadsets, mock: respx.MockRouter) -> None: def test_usage_constant_shape() -> None: assert USAGE["search_records_counted"] == 1 assert BASE == DEFAULT_BASE_URL + + +class TestKeywordsPrioritiesCounts: + def test_count_sends_count_only(self, ls: Leadsets, mock: respx.MockRouter) -> None: + route = mock.post("/v1/companies/search").respond( + json={"count": 10000, "count_capped": True, "usage": {"search_records_counted": 0}, "request_id": "r"} + ) + res = ls.companies.count(keywords=["clay", "gtm engineering"], exclude_keywords="pottery", country="US") + assert body(route) == { + "keywords": ["clay", "gtm engineering"], + "exclude_keywords": "pottery", + "country": "US", + "count_only": True, + } + assert (res.count, res.count_capped) == (10000, True) + people = mock.post("/v1/people/search").respond(json={"count": 3, "count_capped": False, "request_id": "r"}) + assert ls.people.count(company_keywords="clay", match_headline=True, title="founder").count == 3 + sent = body(people) + assert isinstance(sent, dict) + assert sent["count_only"] is True + + def test_priorities_and_new_fields(self, ls: Leadsets, mock: respx.MockRouter) -> None: + route = mock.post("/v1/people/search").respond( + json={ + "company": { + "company_id": "c1", + "name": "Northwind", + "domain": "northwind.io", + "email_domain": "northwind.com", + }, + "items": [{**person(), "priority": 1, "headline": "Founder at Northwind"}], + "next_cursor": None, + "usage": { + **USAGE, + "limits": {"search_records_5h": 7500}, + "resets_at": {"search_5h": "2026-11-19T18:30:00Z"}, + }, + "request_id": "r", + } + ) + res = ls.people.search( + company_domain="northwind.io", + priorities=[{"title": ["founder", "ceo"], "match_headline": True}, {"title": "head of growth"}], + limit=3, + ) + sent = body(route) + assert isinstance(sent, dict) + assert sent["priorities"][0] == {"title": ["founder", "ceo"], "match_headline": True} + assert res.company is not None + assert res.company.email_domain == "northwind.com" + assert res.items[0].priority == 1 + assert res.items[0].headline == "Founder at Northwind" + assert res.usage.limits == {"search_records_5h": 7500} + assert res.usage.resets_at == {"search_5h": "2026-11-19T18:30:00Z"} From 9427c354f607292383f062db575f30356dc8884b Mon Sep 17 00:00:00 2001 From: Arslan Date: Thu, 19 Nov 2026 19:02:44 +0500 Subject: [PATCH 2/3] Agent rules: commit email and no AI attribution in commits, PRs and releases --- AGENT.md | 16 ++++++++++++++++ CLAUDE.md | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 AGENT.md create mode 100644 CLAUDE.md diff --git a/AGENT.md b/AGENT.md new file mode 100644 index 0000000..1f038e6 --- /dev/null +++ b/AGENT.md @@ -0,0 +1,16 @@ +# Agent rules + +Instructions for coding agents working in this repo. `CLAUDE.md` and `AGENT.md` hold the same text; +change both together. + +## Commits, pull requests and releases + +- Commit as `arslan@mobylogix.com`. +- **No AI attribution** anywhere in git or GitHub: commit messages, PR titles and bodies, tags, + release notes and changelogs. That means: + - no `Co-Authored-By` trailers; + - no LLM or model names; + - no "Generated with" lines; + - no session IDs or session URLs; + - no mention of the agent instructions files. +- Write commit messages and PR descriptions about the change itself: what changed and why. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..1f038e6 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,16 @@ +# Agent rules + +Instructions for coding agents working in this repo. `CLAUDE.md` and `AGENT.md` hold the same text; +change both together. + +## Commits, pull requests and releases + +- Commit as `arslan@mobylogix.com`. +- **No AI attribution** anywhere in git or GitHub: commit messages, PR titles and bodies, tags, + release notes and changelogs. That means: + - no `Co-Authored-By` trailers; + - no LLM or model names; + - no "Generated with" lines; + - no session IDs or session URLs; + - no mention of the agent instructions files. +- Write commit messages and PR descriptions about the change itself: what changed and why. From dc98af8e2fcd2cdcdf0a125623d69b388f78bc7d Mon Sep 17 00:00:00 2001 From: Arslan Date: Thu, 19 Nov 2026 19:05:22 +0500 Subject: [PATCH 3/3] Remove agent rules files --- AGENT.md | 16 ---------------- CLAUDE.md | 16 ---------------- 2 files changed, 32 deletions(-) delete mode 100644 AGENT.md delete mode 100644 CLAUDE.md diff --git a/AGENT.md b/AGENT.md deleted file mode 100644 index 1f038e6..0000000 --- a/AGENT.md +++ /dev/null @@ -1,16 +0,0 @@ -# Agent rules - -Instructions for coding agents working in this repo. `CLAUDE.md` and `AGENT.md` hold the same text; -change both together. - -## Commits, pull requests and releases - -- Commit as `arslan@mobylogix.com`. -- **No AI attribution** anywhere in git or GitHub: commit messages, PR titles and bodies, tags, - release notes and changelogs. That means: - - no `Co-Authored-By` trailers; - - no LLM or model names; - - no "Generated with" lines; - - no session IDs or session URLs; - - no mention of the agent instructions files. -- Write commit messages and PR descriptions about the change itself: what changed and why. diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 1f038e6..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,16 +0,0 @@ -# Agent rules - -Instructions for coding agents working in this repo. `CLAUDE.md` and `AGENT.md` hold the same text; -change both together. - -## Commits, pull requests and releases - -- Commit as `arslan@mobylogix.com`. -- **No AI attribution** anywhere in git or GitHub: commit messages, PR titles and bodies, tags, - release notes and changelogs. That means: - - no `Co-Authored-By` trailers; - - no LLM or model names; - - no "Generated with" lines; - - no session IDs or session URLs; - - no mention of the agent instructions files. -- Write commit messages and PR descriptions about the change itself: what changed and why.