Skip to content

Commit 56241a8

Browse files
authored
Add ask and feedback, new search engines, and pagination (v0.3.0) (#3)
Resync the OpenAPI snapshot with the live contract: POST /ask and POST /feedback, the bingcn, yandex and grokipedia engines (sogou removed), page on search, and published_date plus GitHub and Hacker News fields on results. ask() defaults to a 45s timeout because the gateway allows Ask 35s; feedback() is never retried because the API has no idempotency key. The client header now reports python/0.3.0 (it still said 0.2.0).
1 parent 9dcc7f3 commit 56241a8

7 files changed

Lines changed: 833 additions & 18 deletions

File tree

‎README.md‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ for result in response["results"]:
2626
print(result["title"], result["link"])
2727
```
2828

29+
`search_service` selects one engine (`google` by default), for example `bing`,
30+
`bingcn`, `yandex`, `reddit`, `github`, `arxiv`, `wikipedia`, or `grokipedia`.
31+
`page` requests a later results page on engines with native pagination
32+
(`bing`, `bingcn`, `baidu`, `grokipedia`). Results carry `published_date` when the source
33+
exposes one.
34+
2935
Use the client as a context manager when it owns the HTTP connection pool:
3036

3137
```python
@@ -42,6 +48,24 @@ async with AsyncSearch1API() as client:
4248
response = await client.search("latest AI agent frameworks")
4349
```
4450

51+
## Ask
52+
53+
`ask` sends a natural-language request and lets Search1API choose the engines
54+
and time window. It returns at most 10 results ranked by relevance, and
55+
`intent` reports what was searched:
56+
57+
```python
58+
answer = client.ask("What are developers saying about Bun 1.3 this month?")
59+
60+
print(answer["intent"]["sources"], answer["intent"]["time_range"])
61+
for result in answer["results"]:
62+
print(result["relevance"], result["source"], result["title"], result["link"])
63+
```
64+
65+
A completed request costs 5 credits. Ask is not available with pay-per-request
66+
payments, and its default timeout is 45 seconds. Use `search` when you already
67+
know which engine and keywords you want.
68+
4569
## Deepcrawl
4670

4771
`deepcrawl` starts a task and waits for it to finish:
@@ -75,7 +99,21 @@ The clients also support news, crawl, sitemap, trending, extract, usage, and
7599
batch operations exposed by the Search1API HTTP API. Requests time out after
76100
30 seconds and retry `429` and transient `5xx` responses twice by default.
77101
Authentication, payment, and validation errors are never retried. Deepcrawl
78-
task creation is not retried automatically because it is not idempotent.
102+
task creation and feedback are not retried automatically because they are not
103+
idempotent.
104+
105+
## Feedback
106+
107+
`feedback` reports a Search1API problem, missing capability, or confusing
108+
documentation. It is free. Do not include credentials or personal data:
109+
110+
```python
111+
client.feedback(
112+
"Results for this query have no publication dates",
113+
category="feature_request",
114+
request_id="the x-search1api-request-id of the original request",
115+
)
116+
```
79117

80118
## Development
81119

0 commit comments

Comments
 (0)