-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
141 lines (116 loc) · 3.45 KB
/
types.d.ts
File metadata and controls
141 lines (116 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* @searchapi/sdk — TypeScript declarations
*/
export interface SearchAPIConfig {
/** Your SearchAPI key. */
apiKey: string;
/** API base URL. Defaults to "https://search.ourweb.ink". */
baseUrl?: string;
}
// ---------------------------------------------------------------------------
// Request option types
// ---------------------------------------------------------------------------
export interface SearchOptions {
/** Search profile / category. */
profile?: string;
/** Page number (1-based). */
page?: number;
/** Comma-separated engine list. */
engines?: string;
/** Time filter: "day", "week", "month", or "year". */
timeRange?: string;
/** Response format. Defaults to "json". */
format?: string;
}
export interface AskOptions {
/** Search profile. */
profile?: string;
/** Maximum number of sources to consult. */
maxSources?: number;
}
export interface ResearchOptions {
/** Research depth: "quick", "standard", or "deep". */
depth?: "quick" | "standard" | "deep";
/** Maximum number of sources to consult. */
maxSources?: number;
}
export interface ExtractOptions {
/** Output format: "markdown", "text", or "html". */
format?: "markdown" | "text" | "html";
}
export interface BatchSearchOptions {
/** Search profile applied to all queries. */
profile?: string;
}
// ---------------------------------------------------------------------------
// Response types
// ---------------------------------------------------------------------------
export interface SearchResultItem {
title: string;
url: string;
snippet: string;
engine?: string;
score?: number;
}
export interface SearchResult {
query: string;
results: SearchResultItem[];
suggestions?: string[];
totalResults?: number;
}
export interface Source {
title: string;
url: string;
snippet?: string;
}
export interface AskResult {
answer: string;
sources: Source[];
confidence: number;
}
export interface Finding {
title: string;
summary: string;
sources: Source[];
}
export interface ResearchResult {
summary: string;
findings: Finding[];
sources: Source[];
papers?: Source[];
}
export interface ExtractResult {
title: string;
content: string;
metadata: Record<string, unknown>;
}
// ---------------------------------------------------------------------------
// Error
// ---------------------------------------------------------------------------
export class SearchAPIError extends Error {
/** HTTP status code (0 for network errors). */
status: number;
/** Machine-readable error code. */
code: string;
constructor(message: string, status: number, code: string);
}
// ---------------------------------------------------------------------------
// Client
// ---------------------------------------------------------------------------
export class SearchAPI {
constructor(config: SearchAPIConfig);
/** Web search. */
search(query: string, options?: SearchOptions): Promise<SearchResult>;
/** AI-powered question answering. */
ask(query: string, options?: AskOptions): Promise<AskResult>;
/** Deep research on a topic. */
research(query: string, options?: ResearchOptions): Promise<ResearchResult>;
/** Extract structured content from a URL. */
extract(url: string, options?: ExtractOptions): Promise<ExtractResult>;
/** Run multiple search queries in a single request. */
batchSearch(
queries: string[],
options?: BatchSearchOptions,
): Promise<SearchResult[]>;
}
export default SearchAPI;