-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathgoogle.ts
More file actions
133 lines (118 loc) · 2.81 KB
/
google.ts
File metadata and controls
133 lines (118 loc) · 2.81 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
/** Parameters for the Google Search engine. */
export interface GoogleSearchParameters {
engine: "google";
q: string;
api_key?: string;
timeout?: number;
// Geographic Location
location?: string;
uule?: string;
lat?: number;
lon?: number;
radius?: number;
// Localization
google_domain?: string;
gl?: string;
hl?: string;
cr?: string;
lr?: string;
// Search Type
tbm?: "isch" | "lcl" | "vid" | "nws" | "shop" | "pts";
// Pagination
start?: number;
num?: number;
// Advanced Filters
tbs?: string;
safe?: "active" | "off";
nfpr?: 0 | 1;
filter?: 0 | 1;
// Advanced Google Parameters
ludocid?: string;
lsig?: string;
kgmid?: string;
si?: string;
// SerpApi Parameters
device?: "desktop" | "tablet" | "mobile";
no_cache?: boolean;
async?: boolean;
// deno-lint-ignore no-explicit-any
[key: string]: any;
}
/** Metadata returned with every SerpApi response. */
export interface SearchMetadata {
id: string;
status: string;
json_endpoint: string;
created_at: string;
processed_at: string;
google_url: string;
raw_html_file: string;
total_time_taken: number;
}
/** Echoed search parameters in the response. */
export interface SearchParameters {
engine: string;
q: string;
google_domain?: string;
hl?: string;
gl?: string;
device?: string;
location_requested?: string;
location_used?: string;
[key: string]: unknown;
}
/** Search result info. */
export interface SearchInformation {
query_displayed: string;
total_results: number;
time_taken_displayed: number;
organic_results_state: string;
page_number?: number;
}
/** A single organic search result. */
export interface OrganicResult {
position: number;
title: string;
link: string;
redirect_link?: string;
displayed_link: string;
snippet: string;
snippet_highlighted_words?: string[];
date?: string;
sitelinks?: {
inline?: { title: string; link: string }[];
expanded?: { title: string; link: string; snippet: string }[];
};
rich_snippet?: Record<string, unknown>;
source?: string;
}
/** Knowledge graph result. */
export interface KnowledgeGraph {
title?: string;
type?: string;
description?: string;
source?: { name: string; link: string };
[key: string]: unknown;
}
/** "People also ask" question. */
export interface RelatedQuestion {
question: string;
snippet?: string;
title?: string;
link?: string;
}
/** Google Search JSON response. */
export interface GoogleSearchResponse {
search_metadata: SearchMetadata;
search_parameters: SearchParameters;
search_information?: SearchInformation;
organic_results?: OrganicResult[];
knowledge_graph?: KnowledgeGraph;
related_questions?: RelatedQuestion[];
pagination?: {
current: number;
next?: string;
other_pages?: Record<string, string>;
};
[key: string]: unknown;
}