-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch.ts
More file actions
32 lines (30 loc) · 1.08 KB
/
search.ts
File metadata and controls
32 lines (30 loc) · 1.08 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
// NOTE: Experimental
import type { InnertubeSearchRequest } from "../../types/innertube";
export default async function (query: string) {
try {
const response = await fetch(
"https://www.youtube.com/youtubei/v1/search?prettyPrint=false",
{
headers: {
"X-Goog-Fieldmask":
"contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents.itemSectionRenderer.contents",
},
body: JSON.stringify({
context: {
client: {
clientName: "WEB",
clientVersion: "2.20241212.08.00",
},
},
params: "EgIQAg%3D%3D",
query: query,
}),
method: "POST",
},
);
const data = (await response.json()) as Promise<InnertubeSearchRequest>;
console.dir(data, { depth: null });
} catch (err) {
console.error(err);
}
}