specstream-client 1.5.0__tar.gz → 1.5.2__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.5.2/PKG-INFO +132 -0
- specstream_client-1.5.2/README.md +105 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/pyproject.toml +2 -2
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/__init__.py +1 -1
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/client.py +81 -28
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/lifecycle_commands.py +13 -0
- specstream_client-1.5.0/PKG-INFO +0 -297
- specstream_client-1.5.0/README.md +0 -270
- {specstream_client-1.5.0 → specstream_client-1.5.2}/.gitignore +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/LICENSE +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/__main__.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/authorization.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/browser.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/cli.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/families.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/monitors.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/specstream_client/py.typed +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/tests/__init__.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/tests/test_browser.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/tests/test_cli.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/tests/test_client.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/tests/test_convergence.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/tests/test_http_boundary.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/tests/test_m16_exports.py +0 -0
- {specstream_client-1.5.0 → specstream_client-1.5.2}/tests/test_monitors.py +0 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: specstream-client
|
|
3
|
+
Version: 1.5.2
|
|
4
|
+
Summary: Python client for the live web data engine: Search API ($5 per 1,000 searches of up to 10 results, or $1 on the fast tier), Extract API ($0.80 per 1,000 pages) and Deep Search, each result with its source.
|
|
5
|
+
Project-URL: Homepage, https://specstream.ai
|
|
6
|
+
Project-URL: Documentation, https://specstream.ai/docs/sdk
|
|
7
|
+
Project-URL: API, https://api.specstream.ai
|
|
8
|
+
Project-URL: Changelog, https://specstream.ai/changelog
|
|
9
|
+
Project-URL: Repository, https://github.com/specstream/specstream-tools
|
|
10
|
+
Project-URL: Issues, https://github.com/specstream/specstream-tools/issues
|
|
11
|
+
Author-email: SpecStream <support@specstream.ai>
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: ai-agents,api-client,company-list,enrichment,grants,lead-generation,lead-list,lead-lists,live-web,mcp,monitoring,specstream,web-data
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Environment :: Console
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.12
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# specstream-client
|
|
29
|
+
|
|
30
|
+
SpecStream Python and CLI
|
|
31
|
+
|
|
32
|
+
Find records in everyday language, work with saved results, and connect SpecStream
|
|
33
|
+
to your own code. The client uses the same account, permissions, projects, and
|
|
34
|
+
balance as the workspace.
|
|
35
|
+
|
|
36
|
+
Install it from PyPI with pip install -U specstream-client. Instructions are at
|
|
37
|
+
https://specstream.ai/docs/sdk.
|
|
38
|
+
Set SPECSTREAM_API_KEY in your environment to a key from Agents & API.
|
|
39
|
+
|
|
40
|
+
Interpret a request and get a quote:
|
|
41
|
+
|
|
42
|
+
from specstream_client import Client
|
|
43
|
+
import os
|
|
44
|
+
|
|
45
|
+
client = Client(os.environ["SPECSTREAM_API_KEY"])
|
|
46
|
+
parsed = client.compile("Open-source document-signing tools I can self-host. Include the license and latest release.")
|
|
47
|
+
offer = client.quote_capacity_work({
|
|
48
|
+
"ast_hash": parsed["ast_hash"], "operation": "find",
|
|
49
|
+
"requested_units": parsed["ast"]["limit"]["max"],
|
|
50
|
+
})
|
|
51
|
+
print(offer)
|
|
52
|
+
|
|
53
|
+
Review the quote's scope, useful minimum, completion terms, expiry, and maximum.
|
|
54
|
+
After approval, submit the approved maximum in cents and a saved unique request key:
|
|
55
|
+
|
|
56
|
+
result = client.authorize_capacity_work({
|
|
57
|
+
"quote_id": offer["quote_id"], "quote_hash": offer["quote_hash"],
|
|
58
|
+
"confirm_max_cents": approved_maximum_cents,
|
|
59
|
+
"idempotency_key": persisted_request_key,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
If the response is uncertain, get_capacity_request(persisted_request_key) recovers
|
|
63
|
+
that same work. Keep the original key when retrying. get_capacity_quote retrieves
|
|
64
|
+
the original quote. get_find reports progress; list_find_rows retrieves records.
|
|
65
|
+
Use get_delivery and export_find to retrieve saved results without buying them again.
|
|
66
|
+
|
|
67
|
+
## Work beyond the first request
|
|
68
|
+
|
|
69
|
+
Use spec_options to inspect the supported fields for a record type. Save requests
|
|
70
|
+
with create_spec, browse revisions with list_spec_revisions, and inspect their
|
|
71
|
+
connections with get_find_lineage. Projects organize work and member permissions.
|
|
72
|
+
Request links and result shares have separate access controls.
|
|
73
|
+
|
|
74
|
+
quote_capacity_work also accepts extend, add_facts, and refresh with the original
|
|
75
|
+
parent_find_id and exact revised request where required. create_capacity_schedule
|
|
76
|
+
accepts scope, cadence, validity, and spending limits. list_capacity_occurrences
|
|
77
|
+
shows what ran and which occurrences were blocked or missed.
|
|
78
|
+
|
|
79
|
+
Supported types include companies, local businesses, creators, products, apps, jobs,
|
|
80
|
+
papers, tenders, grants, software repositories, packages, datasets, clinical trials,
|
|
81
|
+
regulatory documents, vulnerabilities, books, and podcasts. Supported fields vary
|
|
82
|
+
by type. Missing and conflicting information stays explicit, with observation times
|
|
83
|
+
and source evidence available in saved results.
|
|
84
|
+
|
|
85
|
+
## Command line
|
|
86
|
+
|
|
87
|
+
specstream compile "your request"
|
|
88
|
+
specstream get-capacity-catalog
|
|
89
|
+
specstream get-capacity-balance
|
|
90
|
+
specstream quote-capacity-work --body quote-request.json
|
|
91
|
+
specstream authorize-capacity-work --body approved-execution.json
|
|
92
|
+
specstream get-capacity-request --help
|
|
93
|
+
specstream create-capacity-schedule --body approved-schedule.json
|
|
94
|
+
|
|
95
|
+
--body accepts a JSON file or '-' for stdin. Each command's --help describes its
|
|
96
|
+
path and query parameters. The CLI exposes the same public operations as the client.
|
|
97
|
+
Funding and membership administration require an owner browser session.
|
|
98
|
+
|
|
99
|
+
## Pricing
|
|
100
|
+
|
|
101
|
+
A free account comes with $2 of credit, enough for 2,000 fast searches, with no card.
|
|
102
|
+
Search API: $5 per 1,000 searches of up to 10 results, or $1 per 1,000 on the fast tier.
|
|
103
|
+
Extract API: $0.80 per 1,000 pages; a page with no text is not charged.
|
|
104
|
+
Deep Search: a delivered row costs 5 cents, 15 cents or $1 depending on the facts it carries.
|
|
105
|
+
Monthly credit plans turn the full fee into credit: Starter $49, Growth $199, Scale $499.
|
|
106
|
+
A top-up of $1,000 or more adds 20% more credit. People and agents share one balance.
|
|
107
|
+
Prices: https://specstream.ai/pricing
|
|
108
|
+
|
|
109
|
+
## Benchmarks
|
|
110
|
+
|
|
111
|
+
SpecStream is hosted in the EU and is first on 15 public search, research and
|
|
112
|
+
extraction benchmarks: AA-Omniscience 82.67% on all 600 questions, SurfBench v2 84.6,
|
|
113
|
+
WideSearch on all 200 official tasks over 4 trials, FRAMES 90.78% and TRACE Extract
|
|
114
|
+
v6 88.51%. Scores and method: https://specstream.ai/benchmarks
|
|
115
|
+
Every raw answer: https://huggingface.co/datasets/SpecStreamAI/benchmark-results
|
|
116
|
+
|
|
117
|
+
## Moving off Google Custom Search
|
|
118
|
+
|
|
119
|
+
Google ends its Custom Search JSON API for existing customers on January 1, 2027.
|
|
120
|
+
SpecStream answers the same call in Google's shape, so the move is one line: change
|
|
121
|
+
the base address from https://www.googleapis.com to https://api.specstream.ai.
|
|
122
|
+
|
|
123
|
+
curl "https://api.specstream.ai/customsearch/v1?key=$SPECSTREAM_API_KEY&q=open+source+vector+databases&num=10"
|
|
124
|
+
|
|
125
|
+
items[].title, link, snippet and displayLink come back as before. cx is accepted and
|
|
126
|
+
not needed. Each call runs on the fast tier at $1 per 1,000.
|
|
127
|
+
Guide: https://specstream.ai/migrate/google-custom-search
|
|
128
|
+
|
|
129
|
+
Use quote_capacity_work and authorize_capacity_work for new integrations.
|
|
130
|
+
Older client method names remain for compatibility.
|
|
131
|
+
|
|
132
|
+
Documentation: https://specstream.ai/docs/api
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# specstream-client
|
|
2
|
+
|
|
3
|
+
SpecStream Python and CLI
|
|
4
|
+
|
|
5
|
+
Find records in everyday language, work with saved results, and connect SpecStream
|
|
6
|
+
to your own code. The client uses the same account, permissions, projects, and
|
|
7
|
+
balance as the workspace.
|
|
8
|
+
|
|
9
|
+
Install it from PyPI with pip install -U specstream-client. Instructions are at
|
|
10
|
+
https://specstream.ai/docs/sdk.
|
|
11
|
+
Set SPECSTREAM_API_KEY in your environment to a key from Agents & API.
|
|
12
|
+
|
|
13
|
+
Interpret a request and get a quote:
|
|
14
|
+
|
|
15
|
+
from specstream_client import Client
|
|
16
|
+
import os
|
|
17
|
+
|
|
18
|
+
client = Client(os.environ["SPECSTREAM_API_KEY"])
|
|
19
|
+
parsed = client.compile("Open-source document-signing tools I can self-host. Include the license and latest release.")
|
|
20
|
+
offer = client.quote_capacity_work({
|
|
21
|
+
"ast_hash": parsed["ast_hash"], "operation": "find",
|
|
22
|
+
"requested_units": parsed["ast"]["limit"]["max"],
|
|
23
|
+
})
|
|
24
|
+
print(offer)
|
|
25
|
+
|
|
26
|
+
Review the quote's scope, useful minimum, completion terms, expiry, and maximum.
|
|
27
|
+
After approval, submit the approved maximum in cents and a saved unique request key:
|
|
28
|
+
|
|
29
|
+
result = client.authorize_capacity_work({
|
|
30
|
+
"quote_id": offer["quote_id"], "quote_hash": offer["quote_hash"],
|
|
31
|
+
"confirm_max_cents": approved_maximum_cents,
|
|
32
|
+
"idempotency_key": persisted_request_key,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
If the response is uncertain, get_capacity_request(persisted_request_key) recovers
|
|
36
|
+
that same work. Keep the original key when retrying. get_capacity_quote retrieves
|
|
37
|
+
the original quote. get_find reports progress; list_find_rows retrieves records.
|
|
38
|
+
Use get_delivery and export_find to retrieve saved results without buying them again.
|
|
39
|
+
|
|
40
|
+
## Work beyond the first request
|
|
41
|
+
|
|
42
|
+
Use spec_options to inspect the supported fields for a record type. Save requests
|
|
43
|
+
with create_spec, browse revisions with list_spec_revisions, and inspect their
|
|
44
|
+
connections with get_find_lineage. Projects organize work and member permissions.
|
|
45
|
+
Request links and result shares have separate access controls.
|
|
46
|
+
|
|
47
|
+
quote_capacity_work also accepts extend, add_facts, and refresh with the original
|
|
48
|
+
parent_find_id and exact revised request where required. create_capacity_schedule
|
|
49
|
+
accepts scope, cadence, validity, and spending limits. list_capacity_occurrences
|
|
50
|
+
shows what ran and which occurrences were blocked or missed.
|
|
51
|
+
|
|
52
|
+
Supported types include companies, local businesses, creators, products, apps, jobs,
|
|
53
|
+
papers, tenders, grants, software repositories, packages, datasets, clinical trials,
|
|
54
|
+
regulatory documents, vulnerabilities, books, and podcasts. Supported fields vary
|
|
55
|
+
by type. Missing and conflicting information stays explicit, with observation times
|
|
56
|
+
and source evidence available in saved results.
|
|
57
|
+
|
|
58
|
+
## Command line
|
|
59
|
+
|
|
60
|
+
specstream compile "your request"
|
|
61
|
+
specstream get-capacity-catalog
|
|
62
|
+
specstream get-capacity-balance
|
|
63
|
+
specstream quote-capacity-work --body quote-request.json
|
|
64
|
+
specstream authorize-capacity-work --body approved-execution.json
|
|
65
|
+
specstream get-capacity-request --help
|
|
66
|
+
specstream create-capacity-schedule --body approved-schedule.json
|
|
67
|
+
|
|
68
|
+
--body accepts a JSON file or '-' for stdin. Each command's --help describes its
|
|
69
|
+
path and query parameters. The CLI exposes the same public operations as the client.
|
|
70
|
+
Funding and membership administration require an owner browser session.
|
|
71
|
+
|
|
72
|
+
## Pricing
|
|
73
|
+
|
|
74
|
+
A free account comes with $2 of credit, enough for 2,000 fast searches, with no card.
|
|
75
|
+
Search API: $5 per 1,000 searches of up to 10 results, or $1 per 1,000 on the fast tier.
|
|
76
|
+
Extract API: $0.80 per 1,000 pages; a page with no text is not charged.
|
|
77
|
+
Deep Search: a delivered row costs 5 cents, 15 cents or $1 depending on the facts it carries.
|
|
78
|
+
Monthly credit plans turn the full fee into credit: Starter $49, Growth $199, Scale $499.
|
|
79
|
+
A top-up of $1,000 or more adds 20% more credit. People and agents share one balance.
|
|
80
|
+
Prices: https://specstream.ai/pricing
|
|
81
|
+
|
|
82
|
+
## Benchmarks
|
|
83
|
+
|
|
84
|
+
SpecStream is hosted in the EU and is first on 15 public search, research and
|
|
85
|
+
extraction benchmarks: AA-Omniscience 82.67% on all 600 questions, SurfBench v2 84.6,
|
|
86
|
+
WideSearch on all 200 official tasks over 4 trials, FRAMES 90.78% and TRACE Extract
|
|
87
|
+
v6 88.51%. Scores and method: https://specstream.ai/benchmarks
|
|
88
|
+
Every raw answer: https://huggingface.co/datasets/SpecStreamAI/benchmark-results
|
|
89
|
+
|
|
90
|
+
## Moving off Google Custom Search
|
|
91
|
+
|
|
92
|
+
Google ends its Custom Search JSON API for existing customers on January 1, 2027.
|
|
93
|
+
SpecStream answers the same call in Google's shape, so the move is one line: change
|
|
94
|
+
the base address from https://www.googleapis.com to https://api.specstream.ai.
|
|
95
|
+
|
|
96
|
+
curl "https://api.specstream.ai/customsearch/v1?key=$SPECSTREAM_API_KEY&q=open+source+vector+databases&num=10"
|
|
97
|
+
|
|
98
|
+
items[].title, link, snippet and displayLink come back as before. cx is accepted and
|
|
99
|
+
not needed. Each call runs on the fast tier at $1 per 1,000.
|
|
100
|
+
Guide: https://specstream.ai/migrate/google-custom-search
|
|
101
|
+
|
|
102
|
+
Use quote_capacity_work and authorize_capacity_work for new integrations.
|
|
103
|
+
Older client method names remain for compatibility.
|
|
104
|
+
|
|
105
|
+
Documentation: https://specstream.ai/docs/api
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "specstream-client"
|
|
3
|
-
version = "1.5.
|
|
4
|
-
description = "Python client for
|
|
3
|
+
version = "1.5.2"
|
|
4
|
+
description = "Python client for the live web data engine: Search API ($5 per 1,000 searches of up to 10 results, or $1 on the fast tier), Extract API ($0.80 per 1,000 pages) and Deep Search, each result with its source."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
7
|
license = "MIT"
|
|
@@ -20,7 +20,7 @@ from specstream_client.families import FAMILIES
|
|
|
20
20
|
from specstream_client.monitors import MonitorsMixin
|
|
21
21
|
|
|
22
22
|
DEFAULT_BASE_URL = "https://api.specstream.ai"
|
|
23
|
-
USER_AGENT = "specstream-python/1.5.
|
|
23
|
+
USER_AGENT = "specstream-python/1.5.2"
|
|
24
24
|
|
|
25
25
|
OpenFn = Callable[[urllib.request.Request, float], Any]
|
|
26
26
|
|
|
@@ -260,7 +260,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
260
260
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
261
261
|
for key, value in query.items()
|
|
262
262
|
if value is not None
|
|
263
|
-
}
|
|
263
|
+
},
|
|
264
|
+
doseq=True,
|
|
264
265
|
)
|
|
265
266
|
if encoded:
|
|
266
267
|
path += "?" + encoded
|
|
@@ -290,7 +291,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
290
291
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
291
292
|
for key, value in query.items()
|
|
292
293
|
if value is not None
|
|
293
|
-
}
|
|
294
|
+
},
|
|
295
|
+
doseq=True,
|
|
294
296
|
)
|
|
295
297
|
if encoded:
|
|
296
298
|
path += "?" + encoded
|
|
@@ -301,6 +303,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
301
303
|
*,
|
|
302
304
|
q: str,
|
|
303
305
|
passages: bool | None = None,
|
|
306
|
+
compact: bool | None = None,
|
|
307
|
+
source_max_chars: int | None = None,
|
|
304
308
|
num: int | None = None,
|
|
305
309
|
page: int | None = None,
|
|
306
310
|
speed: str | None = None,
|
|
@@ -310,6 +314,17 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
310
314
|
safe: str | None = None,
|
|
311
315
|
engines: str | None = None,
|
|
312
316
|
engines_asked: bool | None = None,
|
|
317
|
+
images: bool | None = None,
|
|
318
|
+
image_size: str | None = None,
|
|
319
|
+
min_width: int | None = None,
|
|
320
|
+
min_height: int | None = None,
|
|
321
|
+
max_width: int | None = None,
|
|
322
|
+
max_height: int | None = None,
|
|
323
|
+
image_type: str | None = None,
|
|
324
|
+
image_color: str | None = None,
|
|
325
|
+
image_aspect: str | None = None,
|
|
326
|
+
like: list[str] | None = None,
|
|
327
|
+
unlike: list[str] | None = None,
|
|
313
328
|
pages_wait_ms: int | None = None,
|
|
314
329
|
) -> dict[str, Any]:
|
|
315
330
|
"""
|
|
@@ -319,6 +334,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
319
334
|
query: dict[str, Any] = {
|
|
320
335
|
"q": q,
|
|
321
336
|
"passages": passages,
|
|
337
|
+
"compact": compact,
|
|
338
|
+
"source_max_chars": source_max_chars,
|
|
322
339
|
"num": num,
|
|
323
340
|
"page": page,
|
|
324
341
|
"speed": speed,
|
|
@@ -328,6 +345,17 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
328
345
|
"safe": safe,
|
|
329
346
|
"engines": engines,
|
|
330
347
|
"engines_asked": engines_asked,
|
|
348
|
+
"images": images,
|
|
349
|
+
"image_size": image_size,
|
|
350
|
+
"min_width": min_width,
|
|
351
|
+
"min_height": min_height,
|
|
352
|
+
"max_width": max_width,
|
|
353
|
+
"max_height": max_height,
|
|
354
|
+
"image_type": image_type,
|
|
355
|
+
"image_color": image_color,
|
|
356
|
+
"image_aspect": image_aspect,
|
|
357
|
+
"like": like,
|
|
358
|
+
"unlike": unlike,
|
|
331
359
|
"pages_wait_ms": pages_wait_ms,
|
|
332
360
|
}
|
|
333
361
|
encoded = urlencode(
|
|
@@ -335,7 +363,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
335
363
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
336
364
|
for key, value in query.items()
|
|
337
365
|
if value is not None
|
|
338
|
-
}
|
|
366
|
+
},
|
|
367
|
+
doseq=True,
|
|
339
368
|
)
|
|
340
369
|
if encoded:
|
|
341
370
|
path += "?" + encoded
|
|
@@ -385,7 +414,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
385
414
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
386
415
|
for key, value in query.items()
|
|
387
416
|
if value is not None
|
|
388
|
-
}
|
|
417
|
+
},
|
|
418
|
+
doseq=True,
|
|
389
419
|
)
|
|
390
420
|
if encoded:
|
|
391
421
|
path += "?" + encoded
|
|
@@ -415,7 +445,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
415
445
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
416
446
|
for key, value in query.items()
|
|
417
447
|
if value is not None
|
|
418
|
-
}
|
|
448
|
+
},
|
|
449
|
+
doseq=True,
|
|
419
450
|
)
|
|
420
451
|
if encoded:
|
|
421
452
|
path += "?" + encoded
|
|
@@ -453,7 +484,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
453
484
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
454
485
|
for key, value in query.items()
|
|
455
486
|
if value is not None
|
|
456
|
-
}
|
|
487
|
+
},
|
|
488
|
+
doseq=True,
|
|
457
489
|
)
|
|
458
490
|
if encoded:
|
|
459
491
|
path += "?" + encoded
|
|
@@ -488,7 +520,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
488
520
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
489
521
|
for key, value in query.items()
|
|
490
522
|
if value is not None
|
|
491
|
-
}
|
|
523
|
+
},
|
|
524
|
+
doseq=True,
|
|
492
525
|
)
|
|
493
526
|
if encoded:
|
|
494
527
|
path += "?" + encoded
|
|
@@ -513,7 +546,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
513
546
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
514
547
|
for key, value in query.items()
|
|
515
548
|
if value is not None
|
|
516
|
-
}
|
|
549
|
+
},
|
|
550
|
+
doseq=True,
|
|
517
551
|
)
|
|
518
552
|
if encoded:
|
|
519
553
|
path += "?" + encoded
|
|
@@ -614,7 +648,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
614
648
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
615
649
|
for key, value in query.items()
|
|
616
650
|
if value is not None
|
|
617
|
-
}
|
|
651
|
+
},
|
|
652
|
+
doseq=True,
|
|
618
653
|
)
|
|
619
654
|
if encoded:
|
|
620
655
|
path += "?" + encoded
|
|
@@ -648,7 +683,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
648
683
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
649
684
|
for key, value in query.items()
|
|
650
685
|
if value is not None
|
|
651
|
-
}
|
|
686
|
+
},
|
|
687
|
+
doseq=True,
|
|
652
688
|
)
|
|
653
689
|
if encoded:
|
|
654
690
|
path += "?" + encoded
|
|
@@ -687,7 +723,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
687
723
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
688
724
|
for key, value in query.items()
|
|
689
725
|
if value is not None
|
|
690
|
-
}
|
|
726
|
+
},
|
|
727
|
+
doseq=True,
|
|
691
728
|
)
|
|
692
729
|
if encoded:
|
|
693
730
|
path += "?" + encoded
|
|
@@ -721,7 +758,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
721
758
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
722
759
|
for key, value in query.items()
|
|
723
760
|
if value is not None
|
|
724
|
-
}
|
|
761
|
+
},
|
|
762
|
+
doseq=True,
|
|
725
763
|
)
|
|
726
764
|
if encoded:
|
|
727
765
|
path += "?" + encoded
|
|
@@ -749,7 +787,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
749
787
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
750
788
|
for key, value in query.items()
|
|
751
789
|
if value is not None
|
|
752
|
-
}
|
|
790
|
+
},
|
|
791
|
+
doseq=True,
|
|
753
792
|
)
|
|
754
793
|
if encoded:
|
|
755
794
|
path += "?" + encoded
|
|
@@ -788,7 +827,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
788
827
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
789
828
|
for key, value in query.items()
|
|
790
829
|
if value is not None
|
|
791
|
-
}
|
|
830
|
+
},
|
|
831
|
+
doseq=True,
|
|
792
832
|
)
|
|
793
833
|
if encoded:
|
|
794
834
|
path += "?" + encoded
|
|
@@ -835,7 +875,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
835
875
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
836
876
|
for key, value in query.items()
|
|
837
877
|
if value is not None
|
|
838
|
-
}
|
|
878
|
+
},
|
|
879
|
+
doseq=True,
|
|
839
880
|
)
|
|
840
881
|
if encoded:
|
|
841
882
|
path += "?" + encoded
|
|
@@ -852,7 +893,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
852
893
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
853
894
|
for key, value in query.items()
|
|
854
895
|
if value is not None
|
|
855
|
-
}
|
|
896
|
+
},
|
|
897
|
+
doseq=True,
|
|
856
898
|
)
|
|
857
899
|
if encoded:
|
|
858
900
|
path += "?" + encoded
|
|
@@ -898,7 +940,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
898
940
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
899
941
|
for key, value in query.items()
|
|
900
942
|
if value is not None
|
|
901
|
-
}
|
|
943
|
+
},
|
|
944
|
+
doseq=True,
|
|
902
945
|
)
|
|
903
946
|
if encoded:
|
|
904
947
|
path += "?" + encoded
|
|
@@ -992,7 +1035,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
992
1035
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
993
1036
|
for key, value in query.items()
|
|
994
1037
|
if value is not None
|
|
995
|
-
}
|
|
1038
|
+
},
|
|
1039
|
+
doseq=True,
|
|
996
1040
|
)
|
|
997
1041
|
if encoded:
|
|
998
1042
|
path += "?" + encoded
|
|
@@ -1020,7 +1064,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1020
1064
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1021
1065
|
for key, value in query.items()
|
|
1022
1066
|
if value is not None
|
|
1023
|
-
}
|
|
1067
|
+
},
|
|
1068
|
+
doseq=True,
|
|
1024
1069
|
)
|
|
1025
1070
|
if encoded:
|
|
1026
1071
|
path += "?" + encoded
|
|
@@ -1090,7 +1135,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1090
1135
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1091
1136
|
for key, value in query.items()
|
|
1092
1137
|
if value is not None
|
|
1093
|
-
}
|
|
1138
|
+
},
|
|
1139
|
+
doseq=True,
|
|
1094
1140
|
)
|
|
1095
1141
|
if encoded:
|
|
1096
1142
|
path += "?" + encoded
|
|
@@ -1119,7 +1165,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1119
1165
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1120
1166
|
for key, value in query.items()
|
|
1121
1167
|
if value is not None
|
|
1122
|
-
}
|
|
1168
|
+
},
|
|
1169
|
+
doseq=True,
|
|
1123
1170
|
)
|
|
1124
1171
|
if encoded:
|
|
1125
1172
|
path += "?" + encoded
|
|
@@ -1231,7 +1278,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1231
1278
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1232
1279
|
for key, value in query.items()
|
|
1233
1280
|
if value is not None
|
|
1234
|
-
}
|
|
1281
|
+
},
|
|
1282
|
+
doseq=True,
|
|
1235
1283
|
)
|
|
1236
1284
|
if encoded:
|
|
1237
1285
|
path += "?" + encoded
|
|
@@ -1304,7 +1352,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1304
1352
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1305
1353
|
for key, value in query.items()
|
|
1306
1354
|
if value is not None
|
|
1307
|
-
}
|
|
1355
|
+
},
|
|
1356
|
+
doseq=True,
|
|
1308
1357
|
)
|
|
1309
1358
|
if encoded:
|
|
1310
1359
|
path += "?" + encoded
|
|
@@ -1421,7 +1470,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1421
1470
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1422
1471
|
for key, value in query.items()
|
|
1423
1472
|
if value is not None
|
|
1424
|
-
}
|
|
1473
|
+
},
|
|
1474
|
+
doseq=True,
|
|
1425
1475
|
)
|
|
1426
1476
|
if encoded:
|
|
1427
1477
|
path += "?" + encoded
|
|
@@ -1521,7 +1571,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1521
1571
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1522
1572
|
for key, value in query.items()
|
|
1523
1573
|
if value is not None
|
|
1524
|
-
}
|
|
1574
|
+
},
|
|
1575
|
+
doseq=True,
|
|
1525
1576
|
)
|
|
1526
1577
|
if encoded:
|
|
1527
1578
|
path += "?" + encoded
|
|
@@ -1543,7 +1594,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1543
1594
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1544
1595
|
for key, value in query.items()
|
|
1545
1596
|
if value is not None
|
|
1546
|
-
}
|
|
1597
|
+
},
|
|
1598
|
+
doseq=True,
|
|
1547
1599
|
)
|
|
1548
1600
|
if encoded:
|
|
1549
1601
|
path += "?" + encoded
|
|
@@ -1587,7 +1639,8 @@ class Client(MonitorsMixin, BrowserMixin):
|
|
|
1587
1639
|
key: str(value).lower() if isinstance(value, bool) else value
|
|
1588
1640
|
for key, value in query.items()
|
|
1589
1641
|
if value is not None
|
|
1590
|
-
}
|
|
1642
|
+
},
|
|
1643
|
+
doseq=True,
|
|
1591
1644
|
)
|
|
1592
1645
|
if encoded:
|
|
1593
1646
|
path += "?" + encoded
|
|
@@ -34,6 +34,8 @@ COMMANDS = {'get-vocabulary': {'method': 'get_vocabulary',
|
|
|
34
34
|
'body_required': False,
|
|
35
35
|
'query': {'q': 'string',
|
|
36
36
|
'passages': 'boolean',
|
|
37
|
+
'compact': 'boolean',
|
|
38
|
+
'source_max_chars': 'integer',
|
|
37
39
|
'num': 'integer',
|
|
38
40
|
'page': 'integer',
|
|
39
41
|
'speed': 'string',
|
|
@@ -43,6 +45,17 @@ COMMANDS = {'get-vocabulary': {'method': 'get_vocabulary',
|
|
|
43
45
|
'safe': 'string',
|
|
44
46
|
'engines': 'string',
|
|
45
47
|
'engines_asked': 'boolean',
|
|
48
|
+
'images': 'boolean',
|
|
49
|
+
'image_size': 'string',
|
|
50
|
+
'min_width': 'integer',
|
|
51
|
+
'min_height': 'integer',
|
|
52
|
+
'max_width': 'integer',
|
|
53
|
+
'max_height': 'integer',
|
|
54
|
+
'image_type': 'string',
|
|
55
|
+
'image_color': 'string',
|
|
56
|
+
'image_aspect': 'string',
|
|
57
|
+
'like': 'array',
|
|
58
|
+
'unlike': 'array',
|
|
46
59
|
'pages_wait_ms': 'integer'},
|
|
47
60
|
'summary': 'Search API: answer a question from the live web in seconds, each value '
|
|
48
61
|
'with its source'},
|
specstream_client-1.5.0/PKG-INFO
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.5
|
|
2
|
-
Name: specstream-client
|
|
3
|
-
Version: 1.5.0
|
|
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
|
-
Project-URL: Homepage, https://specstream.ai
|
|
6
|
-
Project-URL: Documentation, https://specstream.ai/docs/sdk
|
|
7
|
-
Project-URL: API, https://api.specstream.ai
|
|
8
|
-
Project-URL: Changelog, https://specstream.ai/changelog
|
|
9
|
-
Project-URL: Repository, https://github.com/specstream/specstream-tools
|
|
10
|
-
Project-URL: Issues, https://github.com/specstream/specstream-tools/issues
|
|
11
|
-
Author-email: SpecStream <support@specstream.ai>
|
|
12
|
-
License-Expression: MIT
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Keywords: ai-agents,api-client,company-list,enrichment,grants,lead-generation,lead-list,lead-lists,live-web,mcp,monitoring,specstream,web-data
|
|
15
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
-
Classifier: Environment :: Console
|
|
17
|
-
Classifier: Intended Audience :: Developers
|
|
18
|
-
Classifier: Operating System :: OS Independent
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
-
Classifier: Topic :: Internet :: WWW/HTTP
|
|
24
|
-
Classifier: Typing :: Typed
|
|
25
|
-
Requires-Python: >=3.12
|
|
26
|
-
Description-Content-Type: text/markdown
|
|
27
|
-
|
|
28
|
-
# specstream-client
|
|
29
|
-
|
|
30
|
-
`pip install specstream-client` (the `specstream` package on PyPI is a different project)
|
|
31
|
-
|
|
32
|
-
Python client and command line for [SpecStream](https://specstream.ai), the live web data engine. One platform to build, search, extract, enrich, map, and monitor data across the entire web.
|
|
33
|
-
|
|
34
|
-
Ask for any dataset in plain words, and SpecStream builds it from the entire live web: every match found, extracted and enriched into structured records, then monitored for change.
|
|
35
|
-
|
|
36
|
-
- Source URL and read time on every value.
|
|
37
|
-
- You pay for each row delivered.
|
|
38
|
-
|
|
39
|
-
The client has no dependencies and needs Python 3.12 or newer. It uses the same account, permissions, projects and balance as the workspace.
|
|
40
|
-
|
|
41
|
-
```sh
|
|
42
|
-
pip install specstream-client
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
The package installs the import name `specstream_client` and the command `specstream`.
|
|
46
|
-
|
|
47
|
-
Create an API key under **Agents & API** in your SpecStream workspace and keep it in the environment:
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
export SPECSTREAM_API_KEY="ss_live_..."
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Search the web
|
|
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, or $1 on the fast tier.
|
|
56
|
-
|
|
57
|
-
```python
|
|
58
|
-
import os
|
|
59
|
-
from specstream_client import Client
|
|
60
|
-
|
|
61
|
-
client = Client(os.environ["SPECSTREAM_API_KEY"])
|
|
62
|
-
|
|
63
|
-
search = client.web_search(q="What is the population of Japan?")
|
|
64
|
-
for source in search["sources"][:1]:
|
|
65
|
-
print(source["title"], source["url"], source["snippet"])
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Extract pages
|
|
69
|
-
|
|
70
|
-
`extract_pages` calls the [Extract API](https://specstream.ai/docs/extract-api), `POST /v1/extract`, at $0.80 per 1,000 pages, and a page with no text is not charged.
|
|
71
|
-
|
|
72
|
-
```python
|
|
73
|
-
import os
|
|
74
|
-
from specstream_client import Client
|
|
75
|
-
|
|
76
|
-
client = Client(os.environ["SPECSTREAM_API_KEY"])
|
|
77
|
-
|
|
78
|
-
extract = client.extract_pages({"urls": ["https://example.com"]})
|
|
79
|
-
for page in extract["results"][:1]:
|
|
80
|
-
print(page["title"], page["url"], page["text"])
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Drop-in for the API you already call
|
|
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. 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
|
-
|
|
87
|
-
| API you call | Base address you have | SpecStream address | Where the SpecStream key goes |
|
|
88
|
-
| --- | --- | --- | --- |
|
|
89
|
-
| Tavily | `https://api.tavily.com` | `https://api.specstream.ai/tavily` | Bearer token or `api_key` |
|
|
90
|
-
| Exa | `https://api.exa.ai` | `https://api.specstream.ai/exa` | `x-api-key` or Bearer token |
|
|
91
|
-
| Brave Search API | `https://api.search.brave.com` | `https://api.specstream.ai` | `X-Subscription-Token` |
|
|
92
|
-
| Serper | `https://google.serper.dev` | `https://api.specstream.ai/serper` | `X-API-KEY` |
|
|
93
|
-
| Bing Web Search API v7 | `https://api.bing.microsoft.com/v7.0/search` | `https://api.specstream.ai/v7.0/search` | `Ocp-Apim-Subscription-Key` |
|
|
94
|
-
| Google Custom Search JSON API | `https://www.googleapis.com` or `https://customsearch.googleapis.com` | `https://api.specstream.ai` | `key=` (`cx` is accepted and not used) |
|
|
95
|
-
| SearXNG (JSON) | your instance address | `https://api.specstream.ai/searxng/<key>` | in the address, `key=`, `X-API-Key` or Bearer token |
|
|
96
|
-
| Firecrawl v2 | `https://api.firecrawl.dev` | `https://api.specstream.ai/firecrawl` | Bearer token |
|
|
97
|
-
|
|
98
|
-
The official Tavily and Exa Python SDKs take the address as an argument:
|
|
99
|
-
|
|
100
|
-
```python
|
|
101
|
-
import os
|
|
102
|
-
from tavily import TavilyClient
|
|
103
|
-
from exa_py import Exa
|
|
104
|
-
|
|
105
|
-
tavily = TavilyClient(api_key=os.environ["SPECSTREAM_API_KEY"], api_base_url="https://api.specstream.ai/tavily")
|
|
106
|
-
exa = Exa(api_key=os.environ["SPECSTREAM_API_KEY"], base_url="https://api.specstream.ai/exa")
|
|
107
|
-
```
|
|
108
|
-
|
|
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
|
-
- 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
|
-
- 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
|
-
|
|
113
|
-
## Read a request, get the price
|
|
114
|
-
|
|
115
|
-
```python
|
|
116
|
-
import os
|
|
117
|
-
from specstream_client import Client
|
|
118
|
-
|
|
119
|
-
client = Client(os.environ["SPECSTREAM_API_KEY"])
|
|
120
|
-
|
|
121
|
-
read = client.compile("Open-source document-signing tools I can self-host. Include the license and latest release.")
|
|
122
|
-
offer = client.quote_capacity_work({
|
|
123
|
-
"ast_hash": read["ast_hash"],
|
|
124
|
-
"operation": "find",
|
|
125
|
-
"requested_units": read["ast"]["limit"]["max"],
|
|
126
|
-
})
|
|
127
|
-
print(offer["maximum_cents"], offer["expires_at"])
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Nothing has run yet. Review the quote: what will be found, the facts that come back, the most the work can cost, and when the price expires. A price lasts 30 minutes.
|
|
131
|
-
|
|
132
|
-
## Approve it, then read the results
|
|
133
|
-
|
|
134
|
-
After a person approves, send the approved maximum in cents and a request key you saved first:
|
|
135
|
-
|
|
136
|
-
```python
|
|
137
|
-
run = client.authorize_capacity_work({
|
|
138
|
-
"quote_id": offer["quote_id"],
|
|
139
|
-
"quote_hash": offer["quote_hash"],
|
|
140
|
-
"confirm_max_cents": approved_maximum_cents,
|
|
141
|
-
"idempotency_key": saved_request_key,
|
|
142
|
-
})
|
|
143
|
-
find_id = run["find_id"]
|
|
144
|
-
|
|
145
|
-
page = client.rows(find_id)
|
|
146
|
-
for row in page["rows"]:
|
|
147
|
-
print(row)
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
If the response is lost, `get_capacity_request(saved_request_key)` returns the same work. Keep the original key when you retry, and you will not pay twice. `get_find` reports progress, and `rows` pages through results with `next_cursor`. Reading, exporting and sharing results you own cost nothing.
|
|
151
|
-
|
|
152
|
-
`authorize_capacity_work` refuses to send anything unless the quote, its signature, the maximum and the key are all present.
|
|
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
|
-
|
|
220
|
-
## Drive a real browser
|
|
221
|
-
|
|
222
|
-
For a page that needs a real browser, `open_browser` starts a Chromium on SpecStream.
|
|
223
|
-
You drive it one step at a time, and `browser_read` returns the page's text as it stands after its JavaScript ran.
|
|
224
|
-
|
|
225
|
-
```python
|
|
226
|
-
with client.browser(timeout_s=120) as session:
|
|
227
|
-
client.browser_navigate(session["id"], "https://example.com")
|
|
228
|
-
print(client.browser_read(session["id"])) # Markdown; "text" for plain text
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
A session costs $0.10 an hour, charged by the second, plus $1 per 1,000 steps (0.1¢ a step).
|
|
232
|
-
An open session is charged until `timeout_s` passes, so close it: the `with` block does, also when a step fails.
|
|
233
|
-
|
|
234
|
-
| Call | What it does |
|
|
235
|
-
| --- | --- |
|
|
236
|
-
| `open_browser(timeout_s=..., allowed_domains=[...], ...)` | Opens a browser and returns the session, with its `id` and `connect_url` |
|
|
237
|
-
| `browser_navigate(session_id, url)` | Opens the address |
|
|
238
|
-
| `browser_read(session_id, format="markdown")` | The page's text, in Markdown or plain text |
|
|
239
|
-
| `browser_snapshot(session_id)` | The page's links, buttons and fields, each with a reference |
|
|
240
|
-
| `browser_step(session_id, tool, arguments)` | Any step of Playwright MCP by its name: `browser_click`, `browser_type`, `browser_take_screenshot` and the others |
|
|
241
|
-
| `browser_session(session_id)`, `browser_sessions(status="running")` | One session or the account's sessions, with seconds, steps and charge. Free |
|
|
242
|
-
| `browser_downloads(session_id)` | The files the browser downloaded, as the bytes of one zip, until ten minutes after the session ends. Free |
|
|
243
|
-
| `close_browser(session_id)` | Ends the session and returns it with `charged_usd` |
|
|
244
|
-
|
|
245
|
-
A page the browser may not open (a private address, a site that opted out, a host outside `allowed_domains`) is not an exception for a step: the answer's `error` holds the code `blocked` and the reason. `browser_read` raises `SpecstreamError` in that case.
|
|
246
|
-
|
|
247
|
-
Your own Playwright, Puppeteer, browser-use or Stagehand code can drive the same browser over the Chrome DevTools Protocol:
|
|
248
|
-
|
|
249
|
-
```python
|
|
250
|
-
from playwright.sync_api import sync_playwright
|
|
251
|
-
|
|
252
|
-
session = client.open_browser(timeout_s=300, idempotency_key="job-42")
|
|
253
|
-
try:
|
|
254
|
-
with sync_playwright() as p:
|
|
255
|
-
browser = p.chromium.connect_over_cdp(session["connect_url"])
|
|
256
|
-
context = browser.contexts[0] if browser.contexts else browser.new_context()
|
|
257
|
-
page = context.new_page()
|
|
258
|
-
page.goto("https://example.com")
|
|
259
|
-
print(page.title())
|
|
260
|
-
finally:
|
|
261
|
-
print(client.close_browser(session["id"])["charged_usd"])
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
With `idempotency_key`, the same call again answers with the same session and opens no second one.
|
|
265
|
-
|
|
266
|
-
## More than a first request
|
|
267
|
-
|
|
268
|
-
- `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`.
|
|
269
|
-
- `spec_options(kind)` lists the facts you can ask for, per kind of thing. `edit_spec` changes a request without rereading it.
|
|
270
|
-
- `create_capacity_schedule` keeps any request up to date, hourly to yearly, inside per-run and per-period limits.
|
|
271
|
-
- `export` and `download_export` give CSV, XLSX, JSON or HTML. `create_customer_webhook` sends signed events.
|
|
272
|
-
- Projects, members, shares and starred items have their own methods.
|
|
273
|
-
|
|
274
|
-
## Command line
|
|
275
|
-
|
|
276
|
-
```sh
|
|
277
|
-
specstream compile "Open-source vector databases on GitHub with more than 5,000 stars, with their license."
|
|
278
|
-
specstream get-capacity-balance
|
|
279
|
-
specstream quote-capacity-work --body quote-request.json
|
|
280
|
-
specstream authorize-capacity-work --body approved-execution.json
|
|
281
|
-
specstream rows --find-id FIND_ID
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
`--body` takes a JSON file or `-` for stdin. Every command's `--help` describes its parameters. The command line exposes the same operations as the client.
|
|
285
|
-
|
|
286
|
-
## Pricing
|
|
287
|
-
|
|
288
|
-
New accounts start with $10 of credit, no card. A delivered result costs 5 cents, 15 cents or $1 depending on how many facts it carries. No result, no charge. Rechecks cost half. People and agents share one balance. See [pricing](https://specstream.ai/pricing).
|
|
289
|
-
|
|
290
|
-
## Links
|
|
291
|
-
|
|
292
|
-
- [SDK docs](https://specstream.ai/docs/sdk) and [API docs](https://specstream.ai/docs/api)
|
|
293
|
-
- [Source and issues](https://github.com/specstream/specstream-tools)
|
|
294
|
-
- [TypeScript client](https://www.npmjs.com/package/@specstream/sdk)
|
|
295
|
-
- Support: support@specstream.ai
|
|
296
|
-
|
|
297
|
-
MIT license.
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
# specstream-client
|
|
2
|
-
|
|
3
|
-
`pip install specstream-client` (the `specstream` package on PyPI is a different project)
|
|
4
|
-
|
|
5
|
-
Python client and command line for [SpecStream](https://specstream.ai), the live web data engine. One platform to build, search, extract, enrich, map, and monitor data across the entire web.
|
|
6
|
-
|
|
7
|
-
Ask for any dataset in plain words, and SpecStream builds it from the entire live web: every match found, extracted and enriched into structured records, then monitored for change.
|
|
8
|
-
|
|
9
|
-
- Source URL and read time on every value.
|
|
10
|
-
- You pay for each row delivered.
|
|
11
|
-
|
|
12
|
-
The client has no dependencies and needs Python 3.12 or newer. It uses the same account, permissions, projects and balance as the workspace.
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
pip install specstream-client
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
The package installs the import name `specstream_client` and the command `specstream`.
|
|
19
|
-
|
|
20
|
-
Create an API key under **Agents & API** in your SpecStream workspace and keep it in the environment:
|
|
21
|
-
|
|
22
|
-
```sh
|
|
23
|
-
export SPECSTREAM_API_KEY="ss_live_..."
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Search the web
|
|
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, or $1 on the fast tier.
|
|
29
|
-
|
|
30
|
-
```python
|
|
31
|
-
import os
|
|
32
|
-
from specstream_client import Client
|
|
33
|
-
|
|
34
|
-
client = Client(os.environ["SPECSTREAM_API_KEY"])
|
|
35
|
-
|
|
36
|
-
search = client.web_search(q="What is the population of Japan?")
|
|
37
|
-
for source in search["sources"][:1]:
|
|
38
|
-
print(source["title"], source["url"], source["snippet"])
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Extract pages
|
|
42
|
-
|
|
43
|
-
`extract_pages` calls the [Extract API](https://specstream.ai/docs/extract-api), `POST /v1/extract`, at $0.80 per 1,000 pages, and a page with no text is not charged.
|
|
44
|
-
|
|
45
|
-
```python
|
|
46
|
-
import os
|
|
47
|
-
from specstream_client import Client
|
|
48
|
-
|
|
49
|
-
client = Client(os.environ["SPECSTREAM_API_KEY"])
|
|
50
|
-
|
|
51
|
-
extract = client.extract_pages({"urls": ["https://example.com"]})
|
|
52
|
-
for page in extract["results"][:1]:
|
|
53
|
-
print(page["title"], page["url"], page["text"])
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Drop-in for the API you already call
|
|
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. 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
|
-
|
|
60
|
-
| API you call | Base address you have | SpecStream address | Where the SpecStream key goes |
|
|
61
|
-
| --- | --- | --- | --- |
|
|
62
|
-
| Tavily | `https://api.tavily.com` | `https://api.specstream.ai/tavily` | Bearer token or `api_key` |
|
|
63
|
-
| Exa | `https://api.exa.ai` | `https://api.specstream.ai/exa` | `x-api-key` or Bearer token |
|
|
64
|
-
| Brave Search API | `https://api.search.brave.com` | `https://api.specstream.ai` | `X-Subscription-Token` |
|
|
65
|
-
| Serper | `https://google.serper.dev` | `https://api.specstream.ai/serper` | `X-API-KEY` |
|
|
66
|
-
| Bing Web Search API v7 | `https://api.bing.microsoft.com/v7.0/search` | `https://api.specstream.ai/v7.0/search` | `Ocp-Apim-Subscription-Key` |
|
|
67
|
-
| Google Custom Search JSON API | `https://www.googleapis.com` or `https://customsearch.googleapis.com` | `https://api.specstream.ai` | `key=` (`cx` is accepted and not used) |
|
|
68
|
-
| SearXNG (JSON) | your instance address | `https://api.specstream.ai/searxng/<key>` | in the address, `key=`, `X-API-Key` or Bearer token |
|
|
69
|
-
| Firecrawl v2 | `https://api.firecrawl.dev` | `https://api.specstream.ai/firecrawl` | Bearer token |
|
|
70
|
-
|
|
71
|
-
The official Tavily and Exa Python SDKs take the address as an argument:
|
|
72
|
-
|
|
73
|
-
```python
|
|
74
|
-
import os
|
|
75
|
-
from tavily import TavilyClient
|
|
76
|
-
from exa_py import Exa
|
|
77
|
-
|
|
78
|
-
tavily = TavilyClient(api_key=os.environ["SPECSTREAM_API_KEY"], api_base_url="https://api.specstream.ai/tavily")
|
|
79
|
-
exa = Exa(api_key=os.environ["SPECSTREAM_API_KEY"], base_url="https://api.specstream.ai/exa")
|
|
80
|
-
```
|
|
81
|
-
|
|
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
|
-
- 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
|
-
- 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
|
-
|
|
86
|
-
## Read a request, get the price
|
|
87
|
-
|
|
88
|
-
```python
|
|
89
|
-
import os
|
|
90
|
-
from specstream_client import Client
|
|
91
|
-
|
|
92
|
-
client = Client(os.environ["SPECSTREAM_API_KEY"])
|
|
93
|
-
|
|
94
|
-
read = client.compile("Open-source document-signing tools I can self-host. Include the license and latest release.")
|
|
95
|
-
offer = client.quote_capacity_work({
|
|
96
|
-
"ast_hash": read["ast_hash"],
|
|
97
|
-
"operation": "find",
|
|
98
|
-
"requested_units": read["ast"]["limit"]["max"],
|
|
99
|
-
})
|
|
100
|
-
print(offer["maximum_cents"], offer["expires_at"])
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Nothing has run yet. Review the quote: what will be found, the facts that come back, the most the work can cost, and when the price expires. A price lasts 30 minutes.
|
|
104
|
-
|
|
105
|
-
## Approve it, then read the results
|
|
106
|
-
|
|
107
|
-
After a person approves, send the approved maximum in cents and a request key you saved first:
|
|
108
|
-
|
|
109
|
-
```python
|
|
110
|
-
run = client.authorize_capacity_work({
|
|
111
|
-
"quote_id": offer["quote_id"],
|
|
112
|
-
"quote_hash": offer["quote_hash"],
|
|
113
|
-
"confirm_max_cents": approved_maximum_cents,
|
|
114
|
-
"idempotency_key": saved_request_key,
|
|
115
|
-
})
|
|
116
|
-
find_id = run["find_id"]
|
|
117
|
-
|
|
118
|
-
page = client.rows(find_id)
|
|
119
|
-
for row in page["rows"]:
|
|
120
|
-
print(row)
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
If the response is lost, `get_capacity_request(saved_request_key)` returns the same work. Keep the original key when you retry, and you will not pay twice. `get_find` reports progress, and `rows` pages through results with `next_cursor`. Reading, exporting and sharing results you own cost nothing.
|
|
124
|
-
|
|
125
|
-
`authorize_capacity_work` refuses to send anything unless the quote, its signature, the maximum and the key are all present.
|
|
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
|
-
|
|
193
|
-
## Drive a real browser
|
|
194
|
-
|
|
195
|
-
For a page that needs a real browser, `open_browser` starts a Chromium on SpecStream.
|
|
196
|
-
You drive it one step at a time, and `browser_read` returns the page's text as it stands after its JavaScript ran.
|
|
197
|
-
|
|
198
|
-
```python
|
|
199
|
-
with client.browser(timeout_s=120) as session:
|
|
200
|
-
client.browser_navigate(session["id"], "https://example.com")
|
|
201
|
-
print(client.browser_read(session["id"])) # Markdown; "text" for plain text
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
A session costs $0.10 an hour, charged by the second, plus $1 per 1,000 steps (0.1¢ a step).
|
|
205
|
-
An open session is charged until `timeout_s` passes, so close it: the `with` block does, also when a step fails.
|
|
206
|
-
|
|
207
|
-
| Call | What it does |
|
|
208
|
-
| --- | --- |
|
|
209
|
-
| `open_browser(timeout_s=..., allowed_domains=[...], ...)` | Opens a browser and returns the session, with its `id` and `connect_url` |
|
|
210
|
-
| `browser_navigate(session_id, url)` | Opens the address |
|
|
211
|
-
| `browser_read(session_id, format="markdown")` | The page's text, in Markdown or plain text |
|
|
212
|
-
| `browser_snapshot(session_id)` | The page's links, buttons and fields, each with a reference |
|
|
213
|
-
| `browser_step(session_id, tool, arguments)` | Any step of Playwright MCP by its name: `browser_click`, `browser_type`, `browser_take_screenshot` and the others |
|
|
214
|
-
| `browser_session(session_id)`, `browser_sessions(status="running")` | One session or the account's sessions, with seconds, steps and charge. Free |
|
|
215
|
-
| `browser_downloads(session_id)` | The files the browser downloaded, as the bytes of one zip, until ten minutes after the session ends. Free |
|
|
216
|
-
| `close_browser(session_id)` | Ends the session and returns it with `charged_usd` |
|
|
217
|
-
|
|
218
|
-
A page the browser may not open (a private address, a site that opted out, a host outside `allowed_domains`) is not an exception for a step: the answer's `error` holds the code `blocked` and the reason. `browser_read` raises `SpecstreamError` in that case.
|
|
219
|
-
|
|
220
|
-
Your own Playwright, Puppeteer, browser-use or Stagehand code can drive the same browser over the Chrome DevTools Protocol:
|
|
221
|
-
|
|
222
|
-
```python
|
|
223
|
-
from playwright.sync_api import sync_playwright
|
|
224
|
-
|
|
225
|
-
session = client.open_browser(timeout_s=300, idempotency_key="job-42")
|
|
226
|
-
try:
|
|
227
|
-
with sync_playwright() as p:
|
|
228
|
-
browser = p.chromium.connect_over_cdp(session["connect_url"])
|
|
229
|
-
context = browser.contexts[0] if browser.contexts else browser.new_context()
|
|
230
|
-
page = context.new_page()
|
|
231
|
-
page.goto("https://example.com")
|
|
232
|
-
print(page.title())
|
|
233
|
-
finally:
|
|
234
|
-
print(client.close_browser(session["id"])["charged_usd"])
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
With `idempotency_key`, the same call again answers with the same session and opens no second one.
|
|
238
|
-
|
|
239
|
-
## More than a first request
|
|
240
|
-
|
|
241
|
-
- `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`.
|
|
242
|
-
- `spec_options(kind)` lists the facts you can ask for, per kind of thing. `edit_spec` changes a request without rereading it.
|
|
243
|
-
- `create_capacity_schedule` keeps any request up to date, hourly to yearly, inside per-run and per-period limits.
|
|
244
|
-
- `export` and `download_export` give CSV, XLSX, JSON or HTML. `create_customer_webhook` sends signed events.
|
|
245
|
-
- Projects, members, shares and starred items have their own methods.
|
|
246
|
-
|
|
247
|
-
## Command line
|
|
248
|
-
|
|
249
|
-
```sh
|
|
250
|
-
specstream compile "Open-source vector databases on GitHub with more than 5,000 stars, with their license."
|
|
251
|
-
specstream get-capacity-balance
|
|
252
|
-
specstream quote-capacity-work --body quote-request.json
|
|
253
|
-
specstream authorize-capacity-work --body approved-execution.json
|
|
254
|
-
specstream rows --find-id FIND_ID
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
`--body` takes a JSON file or `-` for stdin. Every command's `--help` describes its parameters. The command line exposes the same operations as the client.
|
|
258
|
-
|
|
259
|
-
## Pricing
|
|
260
|
-
|
|
261
|
-
New accounts start with $10 of credit, no card. A delivered result costs 5 cents, 15 cents or $1 depending on how many facts it carries. No result, no charge. Rechecks cost half. People and agents share one balance. See [pricing](https://specstream.ai/pricing).
|
|
262
|
-
|
|
263
|
-
## Links
|
|
264
|
-
|
|
265
|
-
- [SDK docs](https://specstream.ai/docs/sdk) and [API docs](https://specstream.ai/docs/api)
|
|
266
|
-
- [Source and issues](https://github.com/specstream/specstream-tools)
|
|
267
|
-
- [TypeScript client](https://www.npmjs.com/package/@specstream/sdk)
|
|
268
|
-
- Support: support@specstream.ai
|
|
269
|
-
|
|
270
|
-
MIT license.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|