1import { Actor } from 'apify';
2
3
4
5
6
7await Actor.init();
8
9
10const input = await Actor.getInput();
11const { url } = input;
12
13
14const response = await fetch('https://api.agentql.com/v1/query-data', {
15 method: 'POST',
16 headers: {
17 'X-API-Key': process.env.AGENTQL_API_KEY,
18 'Content-Type': 'application/json'
19 },
20 body: JSON.stringify({
21 query: "{ articles[] { title upvotes } }",
22 url,
23 params: {
24 wait_for: 0,
25 is_scroll_to_bottom_enabled: false,
26 mode: "fast",
27 is_screenshot_enabled: false
28 }
29 })
30});
31const data = await response.json();
32
33
34await Actor.pushData(data);
35
36
37await Actor.exit();