search-web-api 1.0.219 → 1.0.220
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/package.json
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Web via SearXNG metasearch of all major search engines.
|
|
3
|
+
*/
|
|
4
|
+
export declare function searchWeb(query: string, options?: SearchOptions): Promise<SearxngSearchResult[] | SearchResponse>;
|
|
5
|
+
interface SearxngSearchOptions {
|
|
6
|
+
categories?: string[];
|
|
7
|
+
engines?: string[];
|
|
8
|
+
language?: string;
|
|
9
|
+
pageno?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const searchSearxng: (query: string, opts?: SearxngSearchOptions) => Promise<{
|
|
12
|
+
results: SearxngSearchResult[];
|
|
13
|
+
suggestions: string[];
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Normalized view of whatever `grab` handed back.
|
|
17
|
+
* Exactly one of `json`, `text` or `error` is meaningful.
|
|
18
|
+
*/
|
|
19
|
+
export interface NormalizedGrabResponse {
|
|
20
|
+
/** Parsed JSON body, when the response was JSON with search results. */
|
|
21
|
+
json?: any;
|
|
22
|
+
/** Raw body text, when the response was HTML or another text format. */
|
|
23
|
+
text?: string;
|
|
24
|
+
/** Message describing why the request did not produce a usable body. */
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* `grab` resolves rather than rejects on failure: network and HTTP errors come
|
|
29
|
+
* back as `{ error }`, JSON bodies are merged onto the root of the response
|
|
30
|
+
* object, and text/binary bodies are placed on `.data`. This flattens those
|
|
31
|
+
* shapes (plus the plain string a raw fetch would return) into one union so
|
|
32
|
+
* callers never read `.results` off an error object.
|
|
33
|
+
*
|
|
34
|
+
* @param raw The value returned by `grab`.
|
|
35
|
+
* @returns The body as JSON or text, or the error that prevented both.
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeGrabResponse(raw: any): NormalizedGrabResponse;
|
|
38
|
+
interface SearchOptions {
|
|
39
|
+
category?: string | number;
|
|
40
|
+
recency?: string;
|
|
41
|
+
privateSearxng?: string | boolean | null;
|
|
42
|
+
maxRetries?: number;
|
|
43
|
+
page?: number;
|
|
44
|
+
safesearch?: boolean;
|
|
45
|
+
lang?: string;
|
|
46
|
+
proxy?: string | null;
|
|
47
|
+
useProxy?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface SearxngSearchResult {
|
|
50
|
+
title: string;
|
|
51
|
+
url: string;
|
|
52
|
+
snippet?: string;
|
|
53
|
+
domain?: string;
|
|
54
|
+
favicon?: string;
|
|
55
|
+
score?: number;
|
|
56
|
+
source?: string;
|
|
57
|
+
date?: string;
|
|
58
|
+
img_src?: string;
|
|
59
|
+
thumbnail_src?: string;
|
|
60
|
+
thumbnail?: string;
|
|
61
|
+
content?: string;
|
|
62
|
+
author?: string;
|
|
63
|
+
iframe_src?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface SearchResponse {
|
|
66
|
+
results: SearxngSearchResult[];
|
|
67
|
+
suggestions: string[];
|
|
68
|
+
infoboxes?: any[];
|
|
69
|
+
}
|
|
70
|
+
export {};
|