1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "reviews": [
12 {
13 "id": "r1",
14 "title": "Great value",
15 "text": "Excellent build quality and it arrived two days early. Easy to set up, highly recommend.",
16 "rating": 5
17 },
18 {
19 "id": "r2",
20 "title": "Stopped working",
21 "text": "Broken after three weeks. Customer service refused a refund. Waste of money.",
22 "rating": 1
23 },
24 {
25 "id": "r3",
26 "text": "It is ok for the price, nothing special.",
27 "rating": 3
28 },
29 {
30 "id": "r4",
31 "title": "Ottimo prodotto",
32 "text": "Materiali solidi e spedizione veloce, lo consiglio.",
33 "rating": 5
34 },
35 {
36 "id": "r5",
37 "text": "Not good. The packaging was damaged and the seller was slow to reply.",
38 "rating": 2
39 }
40 ]
41};
42
43
44const run = await client.actor("jobdata_labs/review-sentiment-analyzer").call(input);
45
46
47console.log('Results from dataset');
48console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
49const { items } = await client.dataset(run.defaultDatasetId).listItems();
50items.forEach((item) => {
51 console.dir(item);
52});
53
54