-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (24 loc) · 815 Bytes
/
index.js
File metadata and controls
30 lines (24 loc) · 815 Bytes
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
import dotenv from "dotenv";
import path from "path";
import { getJson } from "serpapi";
import { colorize } from "json-colorizer";
dotenv.config({ path: path.resolve(import.meta.dirname, "../.env") });
const apiKey = process.env.API_KEY;
try {
const data = await getJson({
api_key: apiKey,
engine: "youtube",
search_query: "top programming languages 2025",
json_restrictor: "shorts_results"
})
data?.shorts_results.forEach(row => {
row.shorts.forEach(video => {
console.log(`Title: ${video.title}`)
console.log("Views: " + video.views);
console.log("Thumbnail: " + video.thumbnail);
console.log("------------------------")
})
})
} catch (error) {
console.error("Error fetching data", error)
}