1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "spreadsheet": "https://docs.google.com/spreadsheets/d/1EZLnhDCfmhGUnlubmGE-WIfFie8KrJnJkKE2w9f-4AQ/edit",
12 "sheetName": "Demo",
13 "keyColumns": [
14 "sku"
15 ],
16 "columns": [
17 {
18 "name": "sku",
19 "type": "string",
20 "pattern": "[A-Z]{3}-\\d{3}"
21 },
22 {
23 "name": "qty",
24 "type": "integer",
25 "min": 0
26 },
27 {
28 "name": "price",
29 "type": "number",
30 "min": 0
31 },
32 {
33 "name": "active",
34 "type": "boolean"
35 },
36 {
37 "name": "updated",
38 "type": "date"
39 }
40 ],
41 "rows": [
42 {
43 "sku": "ABC-001",
44 "qty": 5,
45 "price": 9.5,
46 "active": true,
47 "updated": "2026-10-21"
48 },
49 {
50 "sku": "ABC-002",
51 "qty": 0,
52 "price": 12,
53 "active": false,
54 "updated": "2026-10-20"
55 }
56 ]
57};
58
59
60const run = await client.actor("kumo-data-tools/google-sheets-safe-upsert").call(input);
61
62
63console.log('Results from dataset');
64console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
65const { items } = await client.dataset(run.defaultDatasetId).listItems();
66items.forEach((item) => {
67 console.dir(item);
68});
69
70