1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "batches": [
12 {
13 "id": "store-qa-orders",
14 "format": "csv",
15 "content": "order_id,amount,currency\nA-1001,42.50,EUR\nA-1002,18.00,EUR"
16 }
17 ],
18 "contract": {
19 "version": "orders-v1",
20 "allowAdditionalFields": false,
21 "fields": [
22 {
23 "name": "order_id",
24 "type": "string",
25 "required": true,
26 "unique": true
27 },
28 {
29 "name": "amount",
30 "type": "number",
31 "required": true,
32 "min": 0
33 },
34 {
35 "name": "currency",
36 "type": "string",
37 "required": true,
38 "allowedValues": [
39 "EUR",
40 "USD"
41 ]
42 }
43 ]
44 }
45};
46
47
48const run = await client.actor("ceddl/csv-jsonl-data-contract-gate").call(input);
49
50
51console.log('Results from dataset');
52console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
53const { items } = await client.dataset(run.defaultDatasetId).listItems();
54items.forEach((item) => {
55 console.dir(item);
56});
57
58