1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "mode": "route",
12 "origin": "Times Square, New York, NY",
13 "destination": "Central Park, New York, NY",
14 "origins": [
15 "Times Square, New York, NY",
16 "Grand Central Terminal, New York, NY"
17 ],
18 "destinations": [
19 "Central Park, New York, NY",
20 "Brooklyn Bridge, New York, NY",
21 "JFK Airport, New York, NY"
22 ],
23 "maxPairs": 100,
24 "travelMode": "driving",
25 "language": "en",
26 "units": "metric",
27 "avoidTolls": false,
28 "avoidHighways": false,
29 "avoidFerries": false
30};
31
32
33const run = await client.actor("crawlerbros/google-maps-directions").call(input);
34
35
36console.log('Results from dataset');
37console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
38const { items } = await client.dataset(run.defaultDatasetId).listItems();
39items.forEach((item) => {
40 console.dir(item);
41});
42
43