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 "id": 1,
14 "name": "Anna Smith",
15 "email": "anna@acme.com",
16 "company": "Acme Inc",
17 "phone": "",
18 "city": "Austin"
19 },
20 {
21 "id": 2,
22 "name": "Ben Jones",
23 "email": "ben@globex.com",
24 "company": "Globex",
25 "phone": "+1 555 010 2000",
26 "city": "Boston"
27 },
28 {
29 "id": 3,
30 "name": "Carla Diaz",
31 "email": "carla@initech.com",
32 "company": "Initech",
33 "phone": "",
34 "city": "Denver"
35 },
36 {
37 "id": 4,
38 "name": " ANNA SMITH ",
39 "email": "Anna@Acme.com",
40 "company": "Acme Inc",
41 "phone": "+1 555 010 1000",
42 "city": ""
43 },
44 {
45 "id": 5,
46 "name": "Ben Jones",
47 "email": "ben@globex.com",
48 "company": "Globex",
49 "phone": "+1 555 010 2000",
50 "city": "Boston"
51 },
52 {
53 "id": 6,
54 "name": "Carla Diaz",
55 "email": "CARLA@initech.com ",
56 "company": "Initech",
57 "phone": "",
58 "city": "Denver"
59 },
60 {
61 "id": 7,
62 "name": "Ana Smith",
63 "email": "ana@acme.com",
64 "company": "Acme Inc",
65 "phone": "",
66 "city": "Austin"
67 },
68 {
69 "id": 8,
70 "name": "Ben Jonse",
71 "email": "ben@globex.com",
72 "company": "Globex",
73 "phone": "",
74 "city": "Boston"
75 }
76 ],
77 "keyFields": [
78 "name",
79 "email"
80 ],
81 "matchMode": "fuzzy",
82 "fuzzyThreshold": 90,
83 "fieldTypes": {
84 "email": "email"
85 },
86 "keepStrategy": "first",
87 "mergeDuplicates": true,
88 "addDuplicateCount": true,
89 "addClusterId": true,
90 "exports": [
91 "csv"
92 ]
93};
94
95
96const run = await client.actor("data-done-right/remove-duplicates").call(input);
97
98
99console.log('Results from dataset');
100console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
101const { items } = await client.dataset(run.defaultDatasetId).listItems();
102items.forEach((item) => {
103 console.dir(item);
104});
105
106