Skip to content

Commit 0679fda

Browse files
fatwang2claude
andauthored
Add X post card options to screenshot and dataset methods (0.8.0) (#9)
* Add X post card options to screenshot and dataset methods (0.8.0) screenshot() takes tweet card options; query_dataset() and list_datasets() cover POST/GET /dataset. OpenAPI snapshot re-synced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DuYf7x5hPGyUHWXLsYsdcu * CI: pin runner to ubuntu-24.04 so the Python 3.9 job can run Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DuYf7x5hPGyUHWXLsYsdcu --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent da317fd commit 0679fda

9 files changed

Lines changed: 736 additions & 11 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111

1212
jobs:
1313
test:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04 # ubuntu-latest (26.04) has no Python 3.9 build
1515
strategy:
1616
matrix:
1717
python-version: ["3.9", "3.12"]

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.8.0 - 2026-12-04
4+
5+
`screenshot()` on `Search1API` and `AsyncSearch1API` takes a `tweet` keyword argument (`TweetCardOptions`: `enabled`, `theme`, `width` 300-1000, `scale` 1-3, `background`, `show_metrics`). An X post link (`x.com` or `twitter.com` `/status/`) is drawn as a post card instead of a browser capture; `tweet` styles it, and `enabled: False` keeps the browser capture. Adds `query_dataset(dataset, query, max_results=...)` for `POST /dataset` (facts from a verified dataset with confidence, corroboration, conflicts and sources; 1 credit, free when nothing is found) and `list_datasets()` for `GET /dataset` (free). The bundled OpenAPI snapshot is re-synced with the live contract.
6+
37
## 0.7.0 - 2026-11-09
48

59
Breaking: `extract()` on `Search1API` and `AsyncSearch1API` requires the keyword arguments `prompt` and `response_format`, matching the API. `response_format` is typed as `ExtractResponseFormat` (in `search1api.types`): `{"type": "json_schema", "json_schema": <your JSON Schema>}`. The API never accepted a request without them; it now rejects one with `422` and an `errors` array instead of `400`, which the client raises as `UnprocessableEntityError`. The bundled OpenAPI snapshot records the required fields, the request example and `TARGET_BAD_REQUEST` in `failureCategory`.

‎README.md‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,43 @@ Path("screenshot.png").write_bytes(screenshot["data"])
147147
print(screenshot["content_type"], screenshot.get("request_id"))
148148
```
149149

150+
An X (Twitter) post link (`x.com` or `twitter.com` `/status/`) is drawn as a
151+
post card with the author, text, photos or video poster, quoted post and
152+
counts, instead of a browser capture. `tweet` styles the card:
153+
154+
```python
155+
card = client.screenshot(
156+
"https://x.com/jack/status/20",
157+
color_scheme="dark",
158+
tweet={"background": "ocean", "show_metrics": False},
159+
)
160+
```
161+
162+
`tweet` takes `theme`, `width` (300-1000), `scale` (1-3), `background`
163+
(`none`, `light`, `dark`, `sunset`, `ocean`, `forest`, `candy`) and
164+
`show_metrics`; `enabled: False` captures x.com in the browser instead. Each
165+
screenshot costs 2 credits.
166+
167+
## Datasets
168+
169+
`query_dataset` answers a question from a verified fact dataset instead of the
170+
open web. Each fact comes with its confidence, how many independent sources
171+
state it, whether sources disagree, and source links:
172+
173+
```python
174+
answer = client.query_dataset(
175+
"gta6", "how do I lose a wanted level fast", max_results=3
176+
)
177+
178+
if answer["found"]:
179+
for fact in answer["results"]:
180+
print(fact["fact"], fact["confidence"], fact["sources"][0]["url"])
181+
```
182+
183+
When `found` is false the results are only the closest facts and the request is
184+
free; otherwise it costs 1 credit. `list_datasets()` lists the datasets and what
185+
they cover, free.
186+
150187
## Extract
151188

152189
`extract` pulls structured fields out of one page. Both `prompt` and

0 commit comments

Comments
 (0)