1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "requests": [
12 {
13 "name": "httpbin echo",
14 "url": "https://httpbin.org/get",
15 "params": {
16 "hello": "world"
17 }
18 },
19 {
20 "name": "httpbin POST JSON",
21 "method": "POST",
22 "url": "https://httpbin.org/post",
23 "json": {
24 "task": "demo",
25 "items": [
26 1,
27 2,
28 3
29 ]
30 }
31 },
32 {
33 "name": "JSONPlaceholder post",
34 "url": "https://jsonplaceholder.typicode.com/posts/1"
35 },
36 {
37 "name": "GitHub repo",
38 "url": "https://api.github.com/repos/apify/crawlee",
39 "headers": {
40 "Accept": "application/vnd.github+json"
41 }
42 },
43 {
44 "name": "npm package",
45 "url": "https://registry.npmjs.org/express/latest"
46 },
47 {
48 "name": "Open-Meteo weather",
49 "url": "https://api.open-meteo.com/v1/forecast",
50 "params": {
51 "latitude": 52.52,
52 "longitude": 13.41,
53 "current": "temperature_2m"
54 }
55 },
56 {
57 "name": "Cat fact",
58 "url": "https://catfact.ninja/fact"
59 },
60 {
61 "name": "Dog image",
62 "url": "https://dog.ceo/api/breeds/image/random"
63 },
64 {
65 "name": "US ZIP code",
66 "url": "https://api.zippopotam.us/us/90210"
67 },
68 {
69 "name": "CoinGecko ping",
70 "url": "https://api.coingecko.com/api/v3/ping"
71 },
72 {
73 "name": "Frankfurter FX",
74 "url": "https://api.frankfurter.app/latest",
75 "params": {
76 "from": "USD",
77 "to": "EUR"
78 }
79 }
80 ],
81 "maxResults": 50
82};
83
84
85const run = await client.actor("henrycrawl/http-request-api").call(input);
86
87
88console.log('Results from dataset');
89console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
90const { items } = await client.dataset(run.defaultDatasetId).listItems();
91items.forEach((item) => {
92 console.dir(item);
93});
94
95