@search1api/client 0.2.0 → 0.3.0
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.
- package/README.md +42 -3
- package/dist/client.d.ts +12 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/generated.d.ts +375 -31
- package/dist/generated.d.ts.map +1 -1
- package/dist/index.cjs +36 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +36 -1
- package/dist/index.js.map +2 -2
- package/dist/types.d.ts +62 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Official TypeScript client for Search1API. It supports Node.js 18+ and runtimes
|
|
4
4
|
with a standards-compatible `fetch` implementation.
|
|
5
5
|
|
|
6
|
-
API documentation: [search1api.com/docs](https://
|
|
6
|
+
API documentation: [search1api.com/docs](https://s1.dev/docs)
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -32,12 +32,39 @@ for (const result of response.results) {
|
|
|
32
32
|
|
|
33
33
|
The constructor reads `SEARCH1API_API_KEY` when `apiKey` is omitted.
|
|
34
34
|
|
|
35
|
+
`searchService` selects one engine (`google` by default), for example `bing`,
|
|
36
|
+
`bingcn`, `yandex`, `reddit`, `github`, `arxiv`, `wikipedia`, or `grokipedia`.
|
|
37
|
+
`page` requests a later results page on engines with native pagination
|
|
38
|
+
(`bing`, `bingcn`, `baidu`, `grokipedia`). Results carry `published_date` when the source
|
|
39
|
+
exposes one.
|
|
40
|
+
|
|
35
41
|
CommonJS projects can load the same client with `require`:
|
|
36
42
|
|
|
37
43
|
```js
|
|
38
44
|
const { Search1API } = require('@search1api/client');
|
|
39
45
|
```
|
|
40
46
|
|
|
47
|
+
## Ask
|
|
48
|
+
|
|
49
|
+
`ask` sends a natural-language request and lets Search1API choose the engines
|
|
50
|
+
and time window. It returns at most 10 results ranked by relevance, and
|
|
51
|
+
`intent` reports what was searched:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const answer = await client.ask(
|
|
55
|
+
'What are developers saying about Bun 1.3 this month?'
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
console.log(answer.intent.sources, answer.intent.time_range);
|
|
59
|
+
for (const result of answer.results) {
|
|
60
|
+
console.log(result.relevance, result.source, result.title, result.link);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A completed request costs 5 credits. Ask is not available with pay-per-request
|
|
65
|
+
payments, and its default timeout is 45 seconds. Use `search` when you already
|
|
66
|
+
know which engine and keywords you want.
|
|
67
|
+
|
|
41
68
|
## Deepcrawl
|
|
42
69
|
|
|
43
70
|
`deepcrawl` starts a task and waits for it to finish:
|
|
@@ -71,10 +98,22 @@ console.log(screenshot.contentType, screenshot.requestId);
|
|
|
71
98
|
The client also provides `news`, `crawl`, `sitemap`, `trending`, `extract`,
|
|
72
99
|
`usage`, and their batch variants where the HTTP API supports them.
|
|
73
100
|
|
|
101
|
+
`feedback` reports a Search1API problem, missing capability, or confusing
|
|
102
|
+
documentation. It is free and is never retried automatically, because a retry
|
|
103
|
+
could file a duplicate report. Do not include credentials or personal data:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
await client.feedback('Results for this query have no publication dates', {
|
|
107
|
+
category: 'feature_request',
|
|
108
|
+
requestId: 'the x-search1api-request-id of the original request',
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
74
112
|
Requests time out after 30 seconds and retry `429` and transient `5xx`
|
|
75
113
|
responses twice by default. Authentication, payment, and validation errors are
|
|
76
|
-
never retried. Deepcrawl task creation
|
|
77
|
-
|
|
114
|
+
never retried. Deepcrawl task creation and feedback are not retried
|
|
115
|
+
automatically because they are not idempotent. Configure this with `timeoutMs`
|
|
116
|
+
and `maxRetries`.
|
|
78
117
|
|
|
79
118
|
## Development
|
|
80
119
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BatchResponse, CrawlOptions, CrawlRequest, CrawlResponse, DeepcrawlAcceptedResponse, DeepcrawlOptions, DeepcrawlStatusResponse, ExtractOptions, ExtractResponse, HealthResponse, JsonValue, NewsOptions, NewsRequest, NewsResponse, RequestOptions, Search1APIOptions, SearchOptions, SearchRequest, SearchResponse, ScreenshotOptions, ScreenshotResponse, SitemapOptions, SitemapResponse, TimeRange, TrendingOptions, TrendingResponse, UsageResponse, WaitForDeepcrawlOptions } from './types.js';
|
|
1
|
+
import type { AskResponse, BatchResponse, CrawlOptions, CrawlRequest, CrawlResponse, DeepcrawlAcceptedResponse, DeepcrawlOptions, DeepcrawlStatusResponse, ExtractOptions, ExtractResponse, FeedbackOptions, FeedbackResponse, HealthResponse, JsonValue, NewsOptions, NewsRequest, NewsResponse, RequestOptions, Search1APIOptions, SearchOptions, SearchRequest, SearchResponse, ScreenshotOptions, ScreenshotResponse, SitemapOptions, SitemapResponse, TimeRange, TrendingOptions, TrendingResponse, UsageResponse, WaitForDeepcrawlOptions } from './types.js';
|
|
2
2
|
export declare class Search1API {
|
|
3
3
|
readonly apiKey: string;
|
|
4
4
|
readonly baseUrl: string;
|
|
@@ -12,6 +12,12 @@ export declare class Search1API {
|
|
|
12
12
|
searchBatch(requests: SearchRequest[], requestOptions?: RequestOptions): Promise<BatchResponse<SearchResponse>>;
|
|
13
13
|
news(query: string, options?: NewsOptions, requestOptions?: RequestOptions): Promise<NewsResponse>;
|
|
14
14
|
newsBatch(requests: NewsRequest[], requestOptions?: RequestOptions): Promise<BatchResponse<NewsResponse>>;
|
|
15
|
+
/**
|
|
16
|
+
* Agentic search: a decision model picks the engines and time window from a
|
|
17
|
+
* natural-language query and returns only relevant results. 5 credits per
|
|
18
|
+
* completed request; requires an API key or OAuth token.
|
|
19
|
+
*/
|
|
20
|
+
ask(query: string, requestOptions?: RequestOptions): Promise<AskResponse>;
|
|
15
21
|
crawl(url: string, options?: CrawlOptions, requestOptions?: RequestOptions): Promise<CrawlResponse>;
|
|
16
22
|
crawlBatch(requests: CrawlRequest[], requestOptions?: RequestOptions): Promise<CrawlResponse[]>;
|
|
17
23
|
screenshot(url: string, options?: ScreenshotOptions, requestOptions?: RequestOptions): Promise<ScreenshotResponse>;
|
|
@@ -24,6 +30,11 @@ export declare class Search1API {
|
|
|
24
30
|
deepcrawl(url: string, options?: DeepcrawlOptions, waitOptions?: WaitForDeepcrawlOptions, requestOptions?: RequestOptions): Promise<DeepcrawlStatusResponse>;
|
|
25
31
|
usage(period?: TimeRange, requestOptions?: RequestOptions): Promise<UsageResponse>;
|
|
26
32
|
health(requestOptions?: RequestOptions): Promise<HealthResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Report a Search1API problem, missing capability, or confusing docs. Free.
|
|
35
|
+
* Never include credentials or personal data in the report.
|
|
36
|
+
*/
|
|
37
|
+
feedback(message: string, options?: FeedbackOptions, requestOptions?: RequestOptions): Promise<FeedbackResponse>;
|
|
27
38
|
private requestJson;
|
|
28
39
|
private request;
|
|
29
40
|
private fetchOnce;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,yBAAyB,EACzB,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACxB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEV,WA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