cernisdata 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cernisdata-0.1.0/.gitignore +10 -0
- cernisdata-0.1.0/PKG-INFO +127 -0
- cernisdata-0.1.0/README.md +113 -0
- cernisdata-0.1.0/pyproject.toml +27 -0
- cernisdata-0.1.0/src/cernisdata/__init__.py +65 -0
- cernisdata-0.1.0/src/cernisdata/_client.py +975 -0
- cernisdata-0.1.0/src/cernisdata/_errors.py +132 -0
- cernisdata-0.1.0/src/cernisdata/_generated.py +2935 -0
- cernisdata-0.1.0/src/cernisdata/_types.py +100 -0
- cernisdata-0.1.0/src/cernisdata/_version.py +1 -0
- cernisdata-0.1.0/src/cernisdata/_webhooks.py +46 -0
- cernisdata-0.1.0/src/cernisdata/py.typed +0 -0
- cernisdata-0.1.0/tests/test_client.py +345 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: cernisdata
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for Cernis Data: people, company, contact, signal and web data behind one API key.
|
|
5
|
+
Keywords: api,b2b data,enrichment,gtm,sdk
|
|
6
|
+
Classifier: Framework :: AsyncIO
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Typing :: Typed
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Requires-Dist: httpx<1,>=0.25
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# cernisdata
|
|
16
|
+
|
|
17
|
+
Python SDK for Cernis Data. People, company, contact, signal and web data behind one API key. Sync and async, fully typed, one dependency (httpx).
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install cernisdata
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from cernisdata import CernisData
|
|
25
|
+
|
|
26
|
+
client = CernisData() # reads CERNIS_DATA_API_KEY and CERNIS_DATA_BASE_URL (your API base URL)
|
|
27
|
+
|
|
28
|
+
page = client.people.search(job_titles=["VP Sales"], company_domains="stripe.com", limit=10)
|
|
29
|
+
for person in page["data"]["results"]:
|
|
30
|
+
print(person["full_name"], person["title"])
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
You can also pass both explicitly: `CernisData("ck_live_...", base_url="https://your-api-host")`.
|
|
34
|
+
|
|
35
|
+
## How calls work
|
|
36
|
+
|
|
37
|
+
- Namespaces: `client.people`, `client.companies`, `client.contacts`, `client.signals`, `client.web`. Methods take keyword arguments and are snake_case.
|
|
38
|
+
- Filters can be passed flat (`job_titles=...`) or as `filters={...}`. List filters take a string, a list, or `{"include": [...], "exclude": [...]}`.
|
|
39
|
+
- Every method returns the API envelope as a dict: `request_id`, `status`, `data`, `meta`.
|
|
40
|
+
|
|
41
|
+
### Async endpoints wait for you
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
found = client.contacts.email(first_name="Karri", last_name="Saarinen", company="linear.app")
|
|
45
|
+
print(found["data"])
|
|
46
|
+
|
|
47
|
+
pending = client.contacts.email(first_name="Karri", last_name="Saarinen", company="linear.app", wait=False)
|
|
48
|
+
result = client.requests.wait(pending["job_id"])
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Bulk jobs
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
job = client.contacts.email_bulk(items=[{"first_name": "Karri", "last_name": "Saarinen", "company": "linear.app"}])
|
|
55
|
+
job.wait()
|
|
56
|
+
for item in job.results():
|
|
57
|
+
print(item["index"], item["status"], item["data"])
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Pagination
|
|
61
|
+
|
|
62
|
+
Every page is a billed request, so cap it.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
for person in client.people.iter_search(job_titles="CTO", locations="Austin", max_items=200):
|
|
66
|
+
print(person["full_name"])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Errors
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from cernisdata import CernisDataError, InsufficientBalanceError, RateLimitError
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
client.companies.enrich(domain="stripe.com")
|
|
76
|
+
except InsufficientBalanceError as e:
|
|
77
|
+
print("Top up:", e.checkout_url)
|
|
78
|
+
except RateLimitError as e:
|
|
79
|
+
print("Retry in", e.retry_after)
|
|
80
|
+
except CernisDataError as e:
|
|
81
|
+
print(e.status, e.code, e.message, e.request_id)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Subclasses: `InvalidInputError`, `AuthenticationError`, `InsufficientBalanceError`, `PermissionDeniedError`, `NotFoundError`, `ConflictError`, `RateLimitError`, `EndpointNotAvailableError`, `TimeoutError`, `ServerError`, `APIConnectionError`, `WebhookVerificationError`.
|
|
85
|
+
|
|
86
|
+
### Retries, idempotency and timeouts
|
|
87
|
+
|
|
88
|
+
429, 5xx and network errors are retried with backoff and jitter (`max_retries=2` by default, honours `Retry-After`). Endpoint POSTs get an automatic `Idempotency-Key`, so a retry is never charged twice; pass `idempotency_key=` to choose your own. `timeout=` (seconds) per call is also sent to the API as its time budget.
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
client = CernisData(timeout=30, max_retries=4, wait_timeout=600)
|
|
92
|
+
client.companies.enrich(domain="stripe.com", timeout=10, idempotency_key="enrich-stripe")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Async client
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import asyncio
|
|
99
|
+
from cernisdata import AsyncCernisData
|
|
100
|
+
|
|
101
|
+
async def main():
|
|
102
|
+
async with AsyncCernisData() as client:
|
|
103
|
+
page = await client.people.search(job_titles="CTO")
|
|
104
|
+
async for person in client.people.iter_search(job_titles="CTO", max_items=50):
|
|
105
|
+
print(person["full_name"])
|
|
106
|
+
|
|
107
|
+
asyncio.run(main())
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Account
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
client.wallet() # balance and free_requests {limit, used, remaining}
|
|
114
|
+
client.usage(days=7)
|
|
115
|
+
client.requests.list(limit=20)
|
|
116
|
+
client.keys.create(name="ci", scopes=["people"])
|
|
117
|
+
client.billing.checkout(amount_usd=25)
|
|
118
|
+
client.call("company.enrich", {"domain": "stripe.com"}) # any endpoint by id
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Webhooks
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from cernisdata import verify_webhook
|
|
125
|
+
|
|
126
|
+
event = verify_webhook(raw_body, request.headers["CernisData-Signature"], secret)
|
|
127
|
+
```
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# cernisdata
|
|
2
|
+
|
|
3
|
+
Python SDK for Cernis Data. People, company, contact, signal and web data behind one API key. Sync and async, fully typed, one dependency (httpx).
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install cernisdata
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from cernisdata import CernisData
|
|
11
|
+
|
|
12
|
+
client = CernisData() # reads CERNIS_DATA_API_KEY and CERNIS_DATA_BASE_URL (your API base URL)
|
|
13
|
+
|
|
14
|
+
page = client.people.search(job_titles=["VP Sales"], company_domains="stripe.com", limit=10)
|
|
15
|
+
for person in page["data"]["results"]:
|
|
16
|
+
print(person["full_name"], person["title"])
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
You can also pass both explicitly: `CernisData("ck_live_...", base_url="https://your-api-host")`.
|
|
20
|
+
|
|
21
|
+
## How calls work
|
|
22
|
+
|
|
23
|
+
- Namespaces: `client.people`, `client.companies`, `client.contacts`, `client.signals`, `client.web`. Methods take keyword arguments and are snake_case.
|
|
24
|
+
- Filters can be passed flat (`job_titles=...`) or as `filters={...}`. List filters take a string, a list, or `{"include": [...], "exclude": [...]}`.
|
|
25
|
+
- Every method returns the API envelope as a dict: `request_id`, `status`, `data`, `meta`.
|
|
26
|
+
|
|
27
|
+
### Async endpoints wait for you
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
found = client.contacts.email(first_name="Karri", last_name="Saarinen", company="linear.app")
|
|
31
|
+
print(found["data"])
|
|
32
|
+
|
|
33
|
+
pending = client.contacts.email(first_name="Karri", last_name="Saarinen", company="linear.app", wait=False)
|
|
34
|
+
result = client.requests.wait(pending["job_id"])
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Bulk jobs
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
job = client.contacts.email_bulk(items=[{"first_name": "Karri", "last_name": "Saarinen", "company": "linear.app"}])
|
|
41
|
+
job.wait()
|
|
42
|
+
for item in job.results():
|
|
43
|
+
print(item["index"], item["status"], item["data"])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Pagination
|
|
47
|
+
|
|
48
|
+
Every page is a billed request, so cap it.
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
for person in client.people.iter_search(job_titles="CTO", locations="Austin", max_items=200):
|
|
52
|
+
print(person["full_name"])
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Errors
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from cernisdata import CernisDataError, InsufficientBalanceError, RateLimitError
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
client.companies.enrich(domain="stripe.com")
|
|
62
|
+
except InsufficientBalanceError as e:
|
|
63
|
+
print("Top up:", e.checkout_url)
|
|
64
|
+
except RateLimitError as e:
|
|
65
|
+
print("Retry in", e.retry_after)
|
|
66
|
+
except CernisDataError as e:
|
|
67
|
+
print(e.status, e.code, e.message, e.request_id)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Subclasses: `InvalidInputError`, `AuthenticationError`, `InsufficientBalanceError`, `PermissionDeniedError`, `NotFoundError`, `ConflictError`, `RateLimitError`, `EndpointNotAvailableError`, `TimeoutError`, `ServerError`, `APIConnectionError`, `WebhookVerificationError`.
|
|
71
|
+
|
|
72
|
+
### Retries, idempotency and timeouts
|
|
73
|
+
|
|
74
|
+
429, 5xx and network errors are retried with backoff and jitter (`max_retries=2` by default, honours `Retry-After`). Endpoint POSTs get an automatic `Idempotency-Key`, so a retry is never charged twice; pass `idempotency_key=` to choose your own. `timeout=` (seconds) per call is also sent to the API as its time budget.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
client = CernisData(timeout=30, max_retries=4, wait_timeout=600)
|
|
78
|
+
client.companies.enrich(domain="stripe.com", timeout=10, idempotency_key="enrich-stripe")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Async client
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import asyncio
|
|
85
|
+
from cernisdata import AsyncCernisData
|
|
86
|
+
|
|
87
|
+
async def main():
|
|
88
|
+
async with AsyncCernisData() as client:
|
|
89
|
+
page = await client.people.search(job_titles="CTO")
|
|
90
|
+
async for person in client.people.iter_search(job_titles="CTO", max_items=50):
|
|
91
|
+
print(person["full_name"])
|
|
92
|
+
|
|
93
|
+
asyncio.run(main())
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Account
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
client.wallet() # balance and free_requests {limit, used, remaining}
|
|
100
|
+
client.usage(days=7)
|
|
101
|
+
client.requests.list(limit=20)
|
|
102
|
+
client.keys.create(name="ci", scopes=["people"])
|
|
103
|
+
client.billing.checkout(amount_usd=25)
|
|
104
|
+
client.call("company.enrich", {"domain": "stripe.com"}) # any endpoint by id
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Webhooks
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from cernisdata import verify_webhook
|
|
111
|
+
|
|
112
|
+
event = verify_webhook(raw_body, request.headers["CernisData-Signature"], secret)
|
|
113
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cernisdata"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for Cernis Data: people, company, contact, signal and web data behind one API key."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
dependencies = ["httpx>=0.25,<1"]
|
|
12
|
+
keywords = ["gtm", "enrichment", "b2b data", "api", "sdk"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Typing :: Typed",
|
|
16
|
+
"Framework :: AsyncIO",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
dev = ["pytest>=8"]
|
|
21
|
+
|
|
22
|
+
[tool.hatch.build.targets.wheel]
|
|
23
|
+
packages = ["src/cernisdata"]
|
|
24
|
+
|
|
25
|
+
[tool.pytest.ini_options]
|
|
26
|
+
testpaths = ["tests"]
|
|
27
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Cernis Data: one API key for people, company, contact, signal and web data.
|
|
2
|
+
|
|
3
|
+
from cernisdata import CernisData
|
|
4
|
+
|
|
5
|
+
client = CernisData() # reads CERNIS_DATA_API_KEY and CERNIS_DATA_BASE_URL
|
|
6
|
+
page = client.people.search(job_titles=["VP Sales"], company_domains="stripe.com", limit=10)
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from ._client import AsyncCernisData, AsyncJob, CernisData, Job, prepare_input, snake_keys
|
|
10
|
+
from ._errors import (
|
|
11
|
+
APIConnectionError,
|
|
12
|
+
AuthenticationError,
|
|
13
|
+
CernisDataError,
|
|
14
|
+
ConflictError,
|
|
15
|
+
EndpointNotAvailableError,
|
|
16
|
+
InsufficientBalanceError,
|
|
17
|
+
InvalidInputError,
|
|
18
|
+
NotFoundError,
|
|
19
|
+
PermissionDeniedError,
|
|
20
|
+
RateLimitError,
|
|
21
|
+
ServerError,
|
|
22
|
+
TimeoutError,
|
|
23
|
+
WebhookVerificationError,
|
|
24
|
+
)
|
|
25
|
+
from ._generated import DEFAULT_BASE_URL, ENDPOINTS, CompanyFilters, PeopleFilters
|
|
26
|
+
from ._types import Envelope, IncludeExclude, JobItem, JobStatus, Meta, Page, Range, RequestRecord, Wallet
|
|
27
|
+
from ._version import __version__
|
|
28
|
+
from ._webhooks import verify_webhook
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"CernisData",
|
|
32
|
+
"AsyncCernisData",
|
|
33
|
+
"Job",
|
|
34
|
+
"AsyncJob",
|
|
35
|
+
"verify_webhook",
|
|
36
|
+
"prepare_input",
|
|
37
|
+
"snake_keys",
|
|
38
|
+
"ENDPOINTS",
|
|
39
|
+
"DEFAULT_BASE_URL",
|
|
40
|
+
"CernisDataError",
|
|
41
|
+
"InvalidInputError",
|
|
42
|
+
"AuthenticationError",
|
|
43
|
+
"InsufficientBalanceError",
|
|
44
|
+
"PermissionDeniedError",
|
|
45
|
+
"NotFoundError",
|
|
46
|
+
"ConflictError",
|
|
47
|
+
"RateLimitError",
|
|
48
|
+
"EndpointNotAvailableError",
|
|
49
|
+
"TimeoutError",
|
|
50
|
+
"ServerError",
|
|
51
|
+
"APIConnectionError",
|
|
52
|
+
"WebhookVerificationError",
|
|
53
|
+
"Envelope",
|
|
54
|
+
"Meta",
|
|
55
|
+
"Page",
|
|
56
|
+
"Wallet",
|
|
57
|
+
"JobItem",
|
|
58
|
+
"JobStatus",
|
|
59
|
+
"RequestRecord",
|
|
60
|
+
"IncludeExclude",
|
|
61
|
+
"Range",
|
|
62
|
+
"PeopleFilters",
|
|
63
|
+
"CompanyFilters",
|
|
64
|
+
"__version__",
|
|
65
|
+
]
|