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 "stops": [
13 "Times Square, New York, NY",
14 "Central Park, New York, NY"
15 ],
16 "origins": [
17 "Times Square, New York, NY",
18 "Grand Central Terminal, New York, NY"
19 ],
20 "destinations": [
21 "Central Park, New York, NY",
22 "Brooklyn Bridge, New York, NY",
23 "JFK Airport, New York, NY"
24 ],
25 "maxPairs": 100,
26 "travelMode": "driving",
27 "avoidTolls": false,
28 "avoidHighways": false,
29 "avoidFerries": false,
30 "maxAlternatives": 1,
31 "maxItems": 5,
32 "includeSteps": false,
33 "includeStreetView": false,
34 "language": "en",
35 "units": "metric",
36 "requestDelayMs": 250
37};
38
39
40const run = await client.actor("vexaloom-labs/google-maps-route-and-distance-matrix-scraper").call(input);
41
42
43console.log('Results from dataset');
44console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
45const { items } = await client.dataset(run.defaultDatasetId).listItems();
46items.forEach((item) => {
47 console.dir(item);
48});
49
50