1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "rawData": [
12 {
13 "company": "Northwind Traders",
14 "website": "https://www.northwind.example/?utm_source=directory",
15 "email": "Sales@Northwind.example",
16 "phone": "(415) 555-2671",
17 "city": "San Francisco"
18 },
19 {
20 "company": "Northwind Traders Inc.",
21 "website": "http://northwind.example/",
22 "email": "sales@northwind.example",
23 "phone": "+1 415 555 2671",
24 "employees": 120
25 },
26 {
27 "company": "Contoso Ltd",
28 "website": "https://contoso.example/about",
29 "phone": "212-555-0187",
30 "city": "New York"
31 },
32 {
33 "company": "Contoso",
34 "website": "https://www.contoso.example/about/#team",
35 "email": "hello@contoso.example",
36 "city": ""
37 },
38 {
39 "company": "Fabrikam",
40 "website": "https://fabrikam.example",
41 "email": "info@fabrikam.example",
42 "city": "Austin"
43 },
44 {
45 "company": "Tailspin Toys",
46 "website": "https://tailspin.example/shop?gclid=abc123",
47 "city": "Denver"
48 },
49 {
50 "company": "Tailspin Toys",
51 "website": "https://tailspin.example/shop",
52 "phone": "720 555 0144",
53 "city": "Denver"
54 }
55 ],
56 "dedupeFields": [
57 "website"
58 ],
59 "urlFields": [
60 "website"
61 ],
62 "keep": "merge"
63};
64
65
66const run = await client.actor("fernandosord/dataset-merge-dedupe").call(input);
67
68
69console.log('Results from dataset');
70console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
71const { items } = await client.dataset(run.defaultDatasetId).listItems();
72items.forEach((item) => {
73 console.dir(item);
74});
75
76