specstream-client 1.3.3__tar.gz → 1.4.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.
- {specstream_client-1.3.3 → specstream_client-1.4.0}/PKG-INFO +71 -5
- {specstream_client-1.3.3 → specstream_client-1.4.0}/README.md +70 -4
- {specstream_client-1.3.3 → specstream_client-1.4.0}/pyproject.toml +1 -1
- {specstream_client-1.3.3 → specstream_client-1.4.0}/specstream_client/__init__.py +3 -1
- {specstream_client-1.3.3 → specstream_client-1.4.0}/specstream_client/cli.py +2 -1
- {specstream_client-1.3.3 → specstream_client-1.4.0}/specstream_client/client.py +212 -3
- {specstream_client-1.3.3 → specstream_client-1.4.0}/specstream_client/lifecycle_commands.py +128 -1
- specstream_client-1.4.0/specstream_client/monitors.py +387 -0
- specstream_client-1.4.0/tests/test_monitors.py +285 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/.gitignore +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/LICENSE +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/specstream_client/__main__.py +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/specstream_client/authorization.py +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/specstream_client/families.py +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/specstream_client/py.typed +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/tests/__init__.py +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/tests/test_cli.py +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/tests/test_client.py +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/tests/test_convergence.py +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/tests/test_http_boundary.py +0 -0
- {specstream_client-1.3.3 → specstream_client-1.4.0}/tests/test_m16_exports.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: specstream-client
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Python client for building lead lists and company lists from the live web. Every match comes with its source, priced before it runs.
|
|
5
5
|
Project-URL: Homepage, https://specstream.ai
|
|
6
6
|
Project-URL: Documentation, https://specstream.ai/docs/sdk
|
|
@@ -52,7 +52,7 @@ export SPECSTREAM_API_KEY="ss_live_..."
|
|
|
52
52
|
|
|
53
53
|
## Search the web
|
|
54
54
|
|
|
55
|
-
`web_search` calls the [Search API](https://specstream.ai/docs/search-api), `GET /v1/web-search`, at $5 per 1,000 searches of up to 10 results.
|
|
55
|
+
`web_search` calls the [Search API](https://specstream.ai/docs/search-api), `GET /v1/web-search`, at $5 per 1,000 searches of up to 10 results, or $1 on the fast tier.
|
|
56
56
|
|
|
57
57
|
```python
|
|
58
58
|
import os
|
|
@@ -82,7 +82,7 @@ for page in extract["results"][:1]:
|
|
|
82
82
|
|
|
83
83
|
## Drop-in for the API you already call
|
|
84
84
|
|
|
85
|
-
SpecStream answers calls written for these search APIs at its own address, in each API's own reply shape. To switch, change the base address and the key. Each search call is one Search API web search on your SpecStream key: $0.
|
|
85
|
+
SpecStream answers calls written for these search APIs at its own address, in each API's own reply shape. To switch, change the base address and the key. Each search call is one Search API web search on your SpecStream key. A drop-in call runs the fast search: $0.001 for up to 10 results ($1 per 1,000 searches), and each 10 results more in the same call add $0.0012. A call that asks for an answer or the API's thorough mode runs the default search: $0.005 for up to 10 results, and $0.006 for each 10 more.
|
|
86
86
|
|
|
87
87
|
| API you call | Base address you have | SpecStream address | Where the SpecStream key goes |
|
|
88
88
|
| --- | --- | --- | --- |
|
|
@@ -106,7 +106,7 @@ tavily = TavilyClient(api_key=os.environ["SPECSTREAM_API_KEY"], api_base_url="ht
|
|
|
106
106
|
exa = Exa(api_key=os.environ["SPECSTREAM_API_KEY"], base_url="https://api.specstream.ai/exa")
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
- A
|
|
109
|
+
- A call that names no result count returns 10 results, at $0.001 on the fast search. Brave's own default is 20: send `count=20` for 20 results at $0.0022.
|
|
110
110
|
- A Firecrawl `/v2/scrape` call is one Extract API page at $0.0008. The Firecrawl JavaScript SDK works with this address; the Firecrawl Python SDK does not yet.
|
|
111
111
|
- Each route's request and reply fields: [specstream.ai/agents.md](https://specstream.ai/agents.md). Create a key under **Agents & API** at [specstream.ai/workspace](https://specstream.ai/workspace). New accounts start with $10 of credit, no card.
|
|
112
112
|
|
|
@@ -151,11 +151,77 @@ If the response is lost, `get_capacity_request(saved_request_key)` returns the s
|
|
|
151
151
|
|
|
152
152
|
`authorize_capacity_work` refuses to send anything unless the quote, its signature, the maximum and the key are all present.
|
|
153
153
|
|
|
154
|
+
## Keep a list current on a schedule
|
|
155
|
+
|
|
156
|
+
A monitor checks a list again on the live web every hour, day, week or month ("month" is every 30 days).
|
|
157
|
+
Each check is a refresh: half the row rate for a row that changed or is new, and 1 cent for a row that comes back unchanged.
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
monitor = client.monitor_list(
|
|
161
|
+
find_id,
|
|
162
|
+
every="week",
|
|
163
|
+
max_price_per_run_usd=2,
|
|
164
|
+
max_price_per_month_usd=8,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
if monitor["status"] == "saved":
|
|
168
|
+
print(monitor["monitor_id"], monitor["next_run_at"])
|
|
169
|
+
else:
|
|
170
|
+
print(monitor["message"]) # "over_maximum": one check costs more than max_price_per_run_usd, nothing was saved
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The client prices one check before it saves anything.
|
|
174
|
+
When one check can cost more than `max_price_per_run_usd`, nothing is saved.
|
|
175
|
+
`max_price_per_month_usd` is the most the monitor spends in one UTC calendar month, checks run on demand included.
|
|
176
|
+
Without it, the limit is `max_price_per_run_usd` times the checks in 31 days.
|
|
177
|
+
The first check runs one interval after the current hour began, and the monitor ends a year after it, unless you set `first_run_at=` and `ends_at=` (a `datetime` with a time zone or an ISO 8601 string).
|
|
178
|
+
The same call again in the same hour returns the monitor already saved, not a second one.
|
|
179
|
+
|
|
180
|
+
| Call | What it does | Cost |
|
|
181
|
+
| --- | --- | --- |
|
|
182
|
+
| `monitor_list(list_id, ...)` | Prices one check of the list and saves the schedule within your limits | Each check, within the limits |
|
|
183
|
+
| `monitors()` | Every monitor of the account, with its state, next check and last list | Free |
|
|
184
|
+
| `monitor_runs(monitor_id)` | The recent checks, newest first: when, the outcome, the reason and the list each one made | Free |
|
|
185
|
+
| `run_monitor_now(monitor_id)` | One check now, inside the monitor's limits. The regular times stay as they are | One check |
|
|
186
|
+
| `pause_monitor(monitor_id)`, `resume_monitor(monitor_id)` | Stops and starts the checks. A missed check is never bought later | Free |
|
|
187
|
+
| `delete_monitor(monitor_id)` | Ends the monitor. The lists it made stay yours | Free |
|
|
188
|
+
| `revisit(list_id)` | Each record of a refreshed list: still matches, no longer matches, unresolved or unavailable | Free |
|
|
189
|
+
|
|
190
|
+
A blocked or missed check is not an unchanged result, and it is not bought later.
|
|
191
|
+
For a calendar schedule (for example Mondays at 9:00 in your time zone), call `create_capacity_schedule` with the API's own fields, including `calendar_schedule`; `list_capacity_schedules`, `update_capacity_schedule`, `list_capacity_occurrences` and `run_capacity_schedule_now` are there too.
|
|
192
|
+
|
|
193
|
+
### Send new and changed records to a webhook
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
delivery = client.set_monitor_delivery(monitor["monitor_id"], webhook="https://example.com/hooks/specstream")
|
|
197
|
+
signing_secret = delivery["webhook_secret"] # shown once: store it, never log it
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`set_monitor_delivery` also takes `slack=` (a channel of your connected Slack workspace), `send_to=` (a connected tool) and `notify=` (SpecStream notifications). Nothing runs when you set it.
|
|
201
|
+
Slack and webhook delivery need a plan that includes deliveries.
|
|
202
|
+
|
|
203
|
+
Each delivery is a JSON POST with the headers `Specstream-Event-Id` and `Specstream-Signature: t=<unix time>,v1=<hex>`.
|
|
204
|
+
Check it before you trust the body, and use the event id to drop repeats:
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
import json
|
|
208
|
+
import os
|
|
209
|
+
from specstream_client import verify_webhook
|
|
210
|
+
|
|
211
|
+
# In your web endpoint, with the raw request body
|
|
212
|
+
verify_webhook(
|
|
213
|
+
secret=os.environ["SPECSTREAM_WEBHOOK_SECRET"],
|
|
214
|
+
signature=request.headers["Specstream-Signature"],
|
|
215
|
+
body=raw_body,
|
|
216
|
+
) # raises SpecstreamError when the signature is wrong or older than 5 minutes
|
|
217
|
+
event = json.loads(raw_body)
|
|
218
|
+
```
|
|
219
|
+
|
|
154
220
|
## More than a first request
|
|
155
221
|
|
|
156
222
|
- `quote_capacity_work` also prices `extend` (more results), `add_facts` and `refresh` (a recheck, at half price) on a finished run. Pass the original `parent_find_id`.
|
|
157
223
|
- `spec_options(kind)` lists the facts you can ask for, per kind of thing. `edit_spec` changes a request without rereading it.
|
|
158
|
-
- `create_capacity_schedule` keeps
|
|
224
|
+
- `create_capacity_schedule` keeps any request up to date, hourly to yearly, inside per-run and per-period limits.
|
|
159
225
|
- `export` and `download_export` give CSV, XLSX, JSON or HTML. `create_customer_webhook` sends signed events.
|
|
160
226
|
- Projects, members, shares and starred items have their own methods.
|
|
161
227
|
|
|
@@ -25,7 +25,7 @@ export SPECSTREAM_API_KEY="ss_live_..."
|
|
|
25
25
|
|
|
26
26
|
## Search the web
|
|
27
27
|
|
|
28
|
-
`web_search` calls the [Search API](https://specstream.ai/docs/search-api), `GET /v1/web-search`, at $5 per 1,000 searches of up to 10 results.
|
|
28
|
+
`web_search` calls the [Search API](https://specstream.ai/docs/search-api), `GET /v1/web-search`, at $5 per 1,000 searches of up to 10 results, or $1 on the fast tier.
|
|
29
29
|
|
|
30
30
|
```python
|
|
31
31
|
import os
|
|
@@ -55,7 +55,7 @@ for page in extract["results"][:1]:
|
|
|
55
55
|
|
|
56
56
|
## Drop-in for the API you already call
|
|
57
57
|
|
|
58
|
-
SpecStream answers calls written for these search APIs at its own address, in each API's own reply shape. To switch, change the base address and the key. Each search call is one Search API web search on your SpecStream key: $0.
|
|
58
|
+
SpecStream answers calls written for these search APIs at its own address, in each API's own reply shape. To switch, change the base address and the key. Each search call is one Search API web search on your SpecStream key. A drop-in call runs the fast search: $0.001 for up to 10 results ($1 per 1,000 searches), and each 10 results more in the same call add $0.0012. A call that asks for an answer or the API's thorough mode runs the default search: $0.005 for up to 10 results, and $0.006 for each 10 more.
|
|
59
59
|
|
|
60
60
|
| API you call | Base address you have | SpecStream address | Where the SpecStream key goes |
|
|
61
61
|
| --- | --- | --- | --- |
|
|
@@ -79,7 +79,7 @@ tavily = TavilyClient(api_key=os.environ["SPECSTREAM_API_KEY"], api_base_url="ht
|
|
|
79
79
|
exa = Exa(api_key=os.environ["SPECSTREAM_API_KEY"], base_url="https://api.specstream.ai/exa")
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
- A
|
|
82
|
+
- A call that names no result count returns 10 results, at $0.001 on the fast search. Brave's own default is 20: send `count=20` for 20 results at $0.0022.
|
|
83
83
|
- A Firecrawl `/v2/scrape` call is one Extract API page at $0.0008. The Firecrawl JavaScript SDK works with this address; the Firecrawl Python SDK does not yet.
|
|
84
84
|
- Each route's request and reply fields: [specstream.ai/agents.md](https://specstream.ai/agents.md). Create a key under **Agents & API** at [specstream.ai/workspace](https://specstream.ai/workspace). New accounts start with $10 of credit, no card.
|
|
85
85
|
|
|
@@ -124,11 +124,77 @@ If the response is lost, `get_capacity_request(saved_request_key)` returns the s
|
|
|
124
124
|
|
|
125
125
|
`authorize_capacity_work` refuses to send anything unless the quote, its signature, the maximum and the key are all present.
|
|
126
126
|
|
|
127
|
+
## Keep a list current on a schedule
|
|
128
|
+
|
|
129
|
+
A monitor checks a list again on the live web every hour, day, week or month ("month" is every 30 days).
|
|
130
|
+
Each check is a refresh: half the row rate for a row that changed or is new, and 1 cent for a row that comes back unchanged.
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
monitor = client.monitor_list(
|
|
134
|
+
find_id,
|
|
135
|
+
every="week",
|
|
136
|
+
max_price_per_run_usd=2,
|
|
137
|
+
max_price_per_month_usd=8,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
if monitor["status"] == "saved":
|
|
141
|
+
print(monitor["monitor_id"], monitor["next_run_at"])
|
|
142
|
+
else:
|
|
143
|
+
print(monitor["message"]) # "over_maximum": one check costs more than max_price_per_run_usd, nothing was saved
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The client prices one check before it saves anything.
|
|
147
|
+
When one check can cost more than `max_price_per_run_usd`, nothing is saved.
|
|
148
|
+
`max_price_per_month_usd` is the most the monitor spends in one UTC calendar month, checks run on demand included.
|
|
149
|
+
Without it, the limit is `max_price_per_run_usd` times the checks in 31 days.
|
|
150
|
+
The first check runs one interval after the current hour began, and the monitor ends a year after it, unless you set `first_run_at=` and `ends_at=` (a `datetime` with a time zone or an ISO 8601 string).
|
|
151
|
+
The same call again in the same hour returns the monitor already saved, not a second one.
|
|
152
|
+
|
|
153
|
+
| Call | What it does | Cost |
|
|
154
|
+
| --- | --- | --- |
|
|
155
|
+
| `monitor_list(list_id, ...)` | Prices one check of the list and saves the schedule within your limits | Each check, within the limits |
|
|
156
|
+
| `monitors()` | Every monitor of the account, with its state, next check and last list | Free |
|
|
157
|
+
| `monitor_runs(monitor_id)` | The recent checks, newest first: when, the outcome, the reason and the list each one made | Free |
|
|
158
|
+
| `run_monitor_now(monitor_id)` | One check now, inside the monitor's limits. The regular times stay as they are | One check |
|
|
159
|
+
| `pause_monitor(monitor_id)`, `resume_monitor(monitor_id)` | Stops and starts the checks. A missed check is never bought later | Free |
|
|
160
|
+
| `delete_monitor(monitor_id)` | Ends the monitor. The lists it made stay yours | Free |
|
|
161
|
+
| `revisit(list_id)` | Each record of a refreshed list: still matches, no longer matches, unresolved or unavailable | Free |
|
|
162
|
+
|
|
163
|
+
A blocked or missed check is not an unchanged result, and it is not bought later.
|
|
164
|
+
For a calendar schedule (for example Mondays at 9:00 in your time zone), call `create_capacity_schedule` with the API's own fields, including `calendar_schedule`; `list_capacity_schedules`, `update_capacity_schedule`, `list_capacity_occurrences` and `run_capacity_schedule_now` are there too.
|
|
165
|
+
|
|
166
|
+
### Send new and changed records to a webhook
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
delivery = client.set_monitor_delivery(monitor["monitor_id"], webhook="https://example.com/hooks/specstream")
|
|
170
|
+
signing_secret = delivery["webhook_secret"] # shown once: store it, never log it
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`set_monitor_delivery` also takes `slack=` (a channel of your connected Slack workspace), `send_to=` (a connected tool) and `notify=` (SpecStream notifications). Nothing runs when you set it.
|
|
174
|
+
Slack and webhook delivery need a plan that includes deliveries.
|
|
175
|
+
|
|
176
|
+
Each delivery is a JSON POST with the headers `Specstream-Event-Id` and `Specstream-Signature: t=<unix time>,v1=<hex>`.
|
|
177
|
+
Check it before you trust the body, and use the event id to drop repeats:
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
import json
|
|
181
|
+
import os
|
|
182
|
+
from specstream_client import verify_webhook
|
|
183
|
+
|
|
184
|
+
# In your web endpoint, with the raw request body
|
|
185
|
+
verify_webhook(
|
|
186
|
+
secret=os.environ["SPECSTREAM_WEBHOOK_SECRET"],
|
|
187
|
+
signature=request.headers["Specstream-Signature"],
|
|
188
|
+
body=raw_body,
|
|
189
|
+
) # raises SpecstreamError when the signature is wrong or older than 5 minutes
|
|
190
|
+
event = json.loads(raw_body)
|
|
191
|
+
```
|
|
192
|
+
|
|
127
193
|
## More than a first request
|
|
128
194
|
|
|
129
195
|
- `quote_capacity_work` also prices `extend` (more results), `add_facts` and `refresh` (a recheck, at half price) on a finished run. Pass the original `parent_find_id`.
|
|
130
196
|
- `spec_options(kind)` lists the facts you can ask for, per kind of thing. `edit_spec` changes a request without rereading it.
|
|
131
|
-
- `create_capacity_schedule` keeps
|
|
197
|
+
- `create_capacity_schedule` keeps any request up to date, hourly to yearly, inside per-run and per-period limits.
|
|
132
198
|
- `export` and `download_export` give CSV, XLSX, JSON or HTML. `create_customer_webhook` sends signed events.
|
|
133
199
|
- Projects, members, shares and starred items have their own methods.
|
|
134
200
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "specstream-client"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.4.0"
|
|
4
4
|
description = "Python client for building lead lists and company lists from the live web. Every match comes with its source, priced before it runs."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from specstream_client.client import DEFAULT_BASE_URL, Client, SpecstreamError
|
|
4
4
|
from specstream_client.families import FAMILIES, FAMILY_SET, assert_family
|
|
5
|
+
from specstream_client.monitors import verify_webhook
|
|
5
6
|
|
|
6
7
|
__all__ = [
|
|
7
8
|
"Client",
|
|
@@ -10,5 +11,6 @@ __all__ = [
|
|
|
10
11
|
"FAMILY_SET",
|
|
11
12
|
"SpecstreamError",
|
|
12
13
|
"assert_family",
|
|
14
|
+
"verify_webhook",
|
|
13
15
|
]
|
|
14
|
-
__version__ = "1.
|
|
16
|
+
__version__ = "1.4.0"
|
|
@@ -75,7 +75,8 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
75
75
|
options["action"] = argparse.BooleanOptionalAction
|
|
76
76
|
else:
|
|
77
77
|
options["type"] = int if kind == "integer" else str
|
|
78
|
-
|
|
78
|
+
flag = "--" + parameter.rstrip("_").replace("_", "-")
|
|
79
|
+
command.add_argument(flag, dest=parameter, **options)
|
|
79
80
|
return parser
|
|
80
81
|
|
|
81
82
|
|
|
@@ -16,9 +16,10 @@ from urllib.parse import urlencode, urljoin, urlsplit
|
|
|
16
16
|
|
|
17
17
|
from specstream_client.authorization import require_work_authorization
|
|
18
18
|
from specstream_client.families import FAMILIES
|
|
19
|
+
from specstream_client.monitors import MonitorsMixin
|
|
19
20
|
|
|
20
21
|
DEFAULT_BASE_URL = "https://api.specstream.ai"
|
|
21
|
-
USER_AGENT = "specstream-python/1.
|
|
22
|
+
USER_AGENT = "specstream-python/1.4.0"
|
|
22
23
|
|
|
23
24
|
OpenFn = Callable[[urllib.request.Request, float], Any]
|
|
24
25
|
|
|
@@ -73,7 +74,7 @@ class SpecstreamError(RuntimeError):
|
|
|
73
74
|
self.details = dict(error["details"])
|
|
74
75
|
|
|
75
76
|
|
|
76
|
-
class Client:
|
|
77
|
+
class Client(MonitorsMixin):
|
|
77
78
|
"""Typed HTTP client for finder.cross-source.v1 public operations."""
|
|
78
79
|
|
|
79
80
|
def __init__(
|
|
@@ -294,7 +295,22 @@ class Client:
|
|
|
294
295
|
path += "?" + encoded
|
|
295
296
|
return self._request("GET", path, None)
|
|
296
297
|
|
|
297
|
-
def web_search(
|
|
298
|
+
def web_search(
|
|
299
|
+
self,
|
|
300
|
+
*,
|
|
301
|
+
q: str,
|
|
302
|
+
passages: bool | None = None,
|
|
303
|
+
num: int | None = None,
|
|
304
|
+
page: int | None = None,
|
|
305
|
+
speed: str | None = None,
|
|
306
|
+
news: bool | None = None,
|
|
307
|
+
language: str | None = None,
|
|
308
|
+
country: str | None = None,
|
|
309
|
+
safe: str | None = None,
|
|
310
|
+
engines: str | None = None,
|
|
311
|
+
engines_asked: bool | None = None,
|
|
312
|
+
pages_wait_ms: int | None = None,
|
|
313
|
+
) -> dict[str, Any]:
|
|
298
314
|
"""
|
|
299
315
|
Search API: answer a question from the live web in seconds, each value with its source.
|
|
300
316
|
"""
|
|
@@ -302,6 +318,16 @@ class Client:
|
|
|
302
318
|
query: dict[str, Any] = {
|
|
303
319
|
"q": q,
|
|
304
320
|
"passages": passages,
|
|
321
|
+
"num": num,
|
|
322
|
+
"page": page,
|
|
323
|
+
"speed": speed,
|
|
324
|
+
"news": news,
|
|
325
|
+
"language": language,
|
|
326
|
+
"country": country,
|
|
327
|
+
"safe": safe,
|
|
328
|
+
"engines": engines,
|
|
329
|
+
"engines_asked": engines_asked,
|
|
330
|
+
"pages_wait_ms": pages_wait_ms,
|
|
305
331
|
}
|
|
306
332
|
encoded = urlencode(
|
|
307
333
|
{
|
|
@@ -323,6 +349,52 @@ class Client:
|
|
|
323
349
|
path = "/v1/extract"
|
|
324
350
|
return self._request("POST", path, request)
|
|
325
351
|
|
|
352
|
+
def list_search_dialects(self) -> dict[str, Any]:
|
|
353
|
+
"""
|
|
354
|
+
List the other search and page APIs SpecStream answers in, each with the addresses to
|
|
355
|
+
paste and a curl call; no key needed.
|
|
356
|
+
"""
|
|
357
|
+
path = "/v1/search-dialects"
|
|
358
|
+
return self._request("GET", path, None)
|
|
359
|
+
|
|
360
|
+
def map_site(self, request: dict[str, Any]) -> dict[str, Any]:
|
|
361
|
+
"""
|
|
362
|
+
Map a site: its start page's links and its sitemaps' pages, kept to the site. One page
|
|
363
|
+
read when it gives a link.
|
|
364
|
+
"""
|
|
365
|
+
path = "/v1/map"
|
|
366
|
+
return self._request("POST", path, request)
|
|
367
|
+
|
|
368
|
+
def start_crawl(self, request: dict[str, Any]) -> dict[str, Any]:
|
|
369
|
+
"""
|
|
370
|
+
Start a crawl: read a site page by page, breadth first, as a job to poll. Each page that
|
|
371
|
+
gives text is one page read.
|
|
372
|
+
"""
|
|
373
|
+
path = "/v1/crawl"
|
|
374
|
+
return self._request("POST", path, request)
|
|
375
|
+
|
|
376
|
+
def get_crawl(self, crawl_id: str, *, skip: int | None = None) -> dict[str, Any]:
|
|
377
|
+
"""Read a crawl job: its state and its pages from skip; follow next_skip."""
|
|
378
|
+
path = f"/v1/crawl/{quote_path(crawl_id, safe='')}"
|
|
379
|
+
query: dict[str, Any] = {
|
|
380
|
+
"skip": skip,
|
|
381
|
+
}
|
|
382
|
+
encoded = urlencode(
|
|
383
|
+
{
|
|
384
|
+
key: str(value).lower() if isinstance(value, bool) else value
|
|
385
|
+
for key, value in query.items()
|
|
386
|
+
if value is not None
|
|
387
|
+
}
|
|
388
|
+
)
|
|
389
|
+
if encoded:
|
|
390
|
+
path += "?" + encoded
|
|
391
|
+
return self._request("GET", path, None)
|
|
392
|
+
|
|
393
|
+
def cancel_crawl(self, crawl_id: str) -> dict[str, Any]:
|
|
394
|
+
"""Stop a crawl job; the pages it read stay."""
|
|
395
|
+
path = f"/v1/crawl/{quote_path(crawl_id, safe='')}"
|
|
396
|
+
return self._request("DELETE", path, None)
|
|
397
|
+
|
|
326
398
|
def web_search_answers(
|
|
327
399
|
self,
|
|
328
400
|
*,
|
|
@@ -353,6 +425,74 @@ class Client:
|
|
|
353
425
|
path = f"/v1/web-search/answers/{quote_path(answer_id, safe='')}"
|
|
354
426
|
return self._request("GET", path, None)
|
|
355
427
|
|
|
428
|
+
def list_account_requests(
|
|
429
|
+
self,
|
|
430
|
+
*,
|
|
431
|
+
endpoint: str | None = None,
|
|
432
|
+
key_id: str | None = None,
|
|
433
|
+
status: str | None = None,
|
|
434
|
+
from_: str | None = None,
|
|
435
|
+
to: str | None = None,
|
|
436
|
+
cursor: str | None = None,
|
|
437
|
+
limit: int | None = None,
|
|
438
|
+
) -> dict[str, Any]:
|
|
439
|
+
"""List the account's Search API and Extract API calls, charged or not, newest first."""
|
|
440
|
+
path = "/v1/account/requests"
|
|
441
|
+
query: dict[str, Any] = {
|
|
442
|
+
"endpoint": endpoint,
|
|
443
|
+
"key_id": key_id,
|
|
444
|
+
"status": status,
|
|
445
|
+
"from": from_,
|
|
446
|
+
"to": to,
|
|
447
|
+
"cursor": cursor,
|
|
448
|
+
"limit": limit,
|
|
449
|
+
}
|
|
450
|
+
encoded = urlencode(
|
|
451
|
+
{
|
|
452
|
+
key: str(value).lower() if isinstance(value, bool) else value
|
|
453
|
+
for key, value in query.items()
|
|
454
|
+
if value is not None
|
|
455
|
+
}
|
|
456
|
+
)
|
|
457
|
+
if encoded:
|
|
458
|
+
path += "?" + encoded
|
|
459
|
+
return self._request("GET", path, None)
|
|
460
|
+
|
|
461
|
+
def get_account_request(self, request_log_id: str) -> dict[str, Any]:
|
|
462
|
+
"""Open one call of the request log, with its reply where it is kept."""
|
|
463
|
+
path = f"/v1/account/requests/{quote_path(request_log_id, safe='')}"
|
|
464
|
+
return self._request("GET", path, None)
|
|
465
|
+
|
|
466
|
+
def get_account_usage(
|
|
467
|
+
self,
|
|
468
|
+
*,
|
|
469
|
+
group: str | None = None,
|
|
470
|
+
format: str | None = None,
|
|
471
|
+
from_: str | None = None,
|
|
472
|
+
to: str | None = None,
|
|
473
|
+
) -> dict[str, Any]:
|
|
474
|
+
"""
|
|
475
|
+
Sum calls and spend by day, endpoint, key or end user, for the Search API, the Extract
|
|
476
|
+
API and Deep Search, as JSON or CSV.
|
|
477
|
+
"""
|
|
478
|
+
path = "/v1/account/usage"
|
|
479
|
+
query: dict[str, Any] = {
|
|
480
|
+
"group": group,
|
|
481
|
+
"format": format,
|
|
482
|
+
"from": from_,
|
|
483
|
+
"to": to,
|
|
484
|
+
}
|
|
485
|
+
encoded = urlencode(
|
|
486
|
+
{
|
|
487
|
+
key: str(value).lower() if isinstance(value, bool) else value
|
|
488
|
+
for key, value in query.items()
|
|
489
|
+
if value is not None
|
|
490
|
+
}
|
|
491
|
+
)
|
|
492
|
+
if encoded:
|
|
493
|
+
path += "?" + encoded
|
|
494
|
+
return self._request("GET", path, None)
|
|
495
|
+
|
|
356
496
|
def workspace_list_notifications(
|
|
357
497
|
self,
|
|
358
498
|
*,
|
|
@@ -722,6 +862,11 @@ class Client:
|
|
|
722
862
|
path = "/v1/capacity/referral"
|
|
723
863
|
return self._request("GET", path, None)
|
|
724
864
|
|
|
865
|
+
def get_capacity_partner(self) -> dict[str, Any]:
|
|
866
|
+
"""Read a partner's own link, terms and monthly sign-ups, payments and commission."""
|
|
867
|
+
path = "/v1/capacity/partner"
|
|
868
|
+
return self._request("GET", path, None)
|
|
869
|
+
|
|
725
870
|
def capture_capacity_referral(self, request: dict[str, Any]) -> dict[str, Any]:
|
|
726
871
|
"""Remember the first referral visit for sign-up within thirty days."""
|
|
727
872
|
path = "/v1/capacity/referral/visit"
|
|
@@ -732,11 +877,75 @@ class Client:
|
|
|
732
877
|
path = "/v1/capacity/history"
|
|
733
878
|
return self._request("GET", path, None)
|
|
734
879
|
|
|
880
|
+
def list_capacity_payments(
|
|
881
|
+
self,
|
|
882
|
+
*,
|
|
883
|
+
cursor: str | None = None,
|
|
884
|
+
limit: int | None = None,
|
|
885
|
+
) -> dict[str, Any]:
|
|
886
|
+
"""
|
|
887
|
+
List the account's payments as receipts, newest first; app store payments are counted,
|
|
888
|
+
not listed, since the store issues their receipts.
|
|
889
|
+
"""
|
|
890
|
+
path = "/v1/capacity/payments"
|
|
891
|
+
query: dict[str, Any] = {
|
|
892
|
+
"cursor": cursor,
|
|
893
|
+
"limit": limit,
|
|
894
|
+
}
|
|
895
|
+
encoded = urlencode(
|
|
896
|
+
{
|
|
897
|
+
key: str(value).lower() if isinstance(value, bool) else value
|
|
898
|
+
for key, value in query.items()
|
|
899
|
+
if value is not None
|
|
900
|
+
}
|
|
901
|
+
)
|
|
902
|
+
if encoded:
|
|
903
|
+
path += "?" + encoded
|
|
904
|
+
return self._request("GET", path, None)
|
|
905
|
+
|
|
906
|
+
def get_capacity_payment_receipt(self, payment_id: str) -> dict[str, Any]:
|
|
907
|
+
"""
|
|
908
|
+
Read one payment's receipt: paid, tax, credit added with any prepayment bonus, refunds
|
|
909
|
+
and the cash value of the credit left; an app store payment answers 409
|
|
910
|
+
receipt_issued_by_store.
|
|
911
|
+
"""
|
|
912
|
+
path = f"/v1/capacity/payments/{quote_path(payment_id, safe='')}/receipt"
|
|
913
|
+
return self._request("GET", path, None)
|
|
914
|
+
|
|
735
915
|
def claim_free_capacity(self) -> dict[str, Any]:
|
|
736
916
|
"""Claim the one-time free balance for a verified eligible account."""
|
|
737
917
|
path = "/v1/capacity/free"
|
|
738
918
|
return self._request("POST", path, None)
|
|
739
919
|
|
|
920
|
+
def get_capacity_auto_topup(self) -> dict[str, Any]:
|
|
921
|
+
"""
|
|
922
|
+
Read the automatic top-up setting, its saved card, this month's charges and the allowed
|
|
923
|
+
ranges.
|
|
924
|
+
"""
|
|
925
|
+
path = "/v1/capacity/auto-topup"
|
|
926
|
+
return self._request("GET", path, None)
|
|
927
|
+
|
|
928
|
+
def set_capacity_auto_topup(self) -> dict[str, Any]:
|
|
929
|
+
"""
|
|
930
|
+
Turn automatic top-up on or off and set its level, amount or search pack, and monthly
|
|
931
|
+
limits (owner only).
|
|
932
|
+
"""
|
|
933
|
+
path = "/v1/capacity/auto-topup"
|
|
934
|
+
return self._request("PUT", path, None)
|
|
935
|
+
|
|
936
|
+
def start_capacity_auto_topup_card(self) -> dict[str, Any]:
|
|
937
|
+
"""
|
|
938
|
+
Open a Stripe page to save or change the card for automatic top-up, with no payment
|
|
939
|
+
(owner only).
|
|
940
|
+
"""
|
|
941
|
+
path = "/v1/capacity/auto-topup/card"
|
|
942
|
+
return self._request("POST", path, None)
|
|
943
|
+
|
|
944
|
+
def remove_capacity_auto_topup_card(self) -> dict[str, Any]:
|
|
945
|
+
"""Remove the saved card; automatic top-up turns off (owner only)."""
|
|
946
|
+
path = "/v1/capacity/auto-topup/card"
|
|
947
|
+
return self._request("DELETE", path, None)
|
|
948
|
+
|
|
740
949
|
def set_capacity_budget(self, request: dict[str, Any]) -> dict[str, Any]:
|
|
741
950
|
"""Set an owner-approved monthly account spending maximum."""
|
|
742
951
|
path = "/v1/capacity/budget"
|