1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "items": [
12 {
13 "name": "Blue Door Cafe",
14 "website": "https://bluedoor.example",
15 "rating": 4.6,
16 "emails": [
17 "hello@bluedoor.example"
18 ],
19 "address": {
20 "city": "Oslo"
21 }
22 },
23 {
24 "name": "Corner Bar",
25 "website": "",
26 "rating": 4.2,
27 "emails": [],
28 "address": {
29 "city": "Bergen"
30 }
31 },
32 {
33 "name": "Harbor Hotel",
34 "website": "https://harbor.example",
35 "rating": 3.8,
36 "emails": [
37 "info@harbor.example"
38 ],
39 "address": {
40 "city": "Bergen"
41 }
42 },
43 {
44 "name": "Fjord Bakery",
45 "website": "https://fjordbakery.example",
46 "rating": "4.9",
47 "emails": [
48 "post@fjordbakery.example"
49 ],
50 "address": {
51 "city": "Oslo"
52 }
53 }
54 ],
55 "filters": [
56 {
57 "field": "website",
58 "op": "isNotEmpty"
59 },
60 {
61 "field": "rating",
62 "op": "greaterOrEqual",
63 "value": 4
64 }
65 ]
66};
67
68
69const run = await client.actor("charlesmarkette/dataset-filter-transform-rename-flatten-fields").call(input);
70
71
72console.log('Results from dataset');
73console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
74const { items } = await client.dataset(run.defaultDatasetId).listItems();
75items.forEach((item) => {
76 console.dir(item);
77});
78
79