1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "sources": [
12 {
13 "id": "crm",
14 "format": "records",
15 "records": [
16 {
17 "Customer ID": "C-100",
18 "Name": "Ada Lovelace",
19 "Email": "ADA@example.com",
20 "Company": "Engines Ltd"
21 },
22 {
23 "Customer ID": "C-100",
24 "Name": "Ada Lovelace",
25 "Email": "ada@example.com",
26 "Company": "Analytical Engines Limited"
27 },
28 {
29 "Customer ID": "C-102",
30 "Name": "Grace Hopper",
31 "Email": "grace@example.com",
32 "Company": "Compiler Systems"
33 }
34 ]
35 }
36 ],
37 "identityFields": [
38 {
39 "field": "email",
40 "matchType": "email",
41 "weight": 3
42 },
43 {
44 "field": "name",
45 "matchType": "fuzzy",
46 "weight": 1
47 }
48 ],
49 "blockingFields": [
50 "email"
51 ],
52 "neverMergeFields": [
53 "customer_id"
54 ],
55 "survivorship": {
56 "company": "longest"
57 }
58};
59
60
61const run = await client.actor("first_watch/duplicate-record-detection-and-merging").call(input);
62
63
64console.log('Results from dataset');
65console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
66const { items } = await client.dataset(run.defaultDatasetId).listItems();
67items.forEach((item) => {
68 console.dir(item);
69});
70
71