1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "schema": {
12 "$schema": "https://json-schema.org/draft/2020-12/schema",
13 "type": "object",
14 "required": [
15 "id",
16 "email"
17 ],
18 "properties": {
19 "id": {
20 "type": "integer"
21 },
22 "email": {
23 "type": "string",
24 "format": "email"
25 }
26 },
27 "additionalProperties": false
28 },
29 "records": [
30 {
31 "id": 1,
32 "email": "analyst@example.org"
33 },
34 {
35 "id": "2",
36 "email": "not-an-email"
37 },
38 {
39 "id": 3
40 }
41 ]
42};
43
44
45const run = await client.actor("automation-lab/apify-dataset-json-schema-validator").call(input);
46
47
48console.log('Results from dataset');
49console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
50const { items } = await client.dataset(run.defaultDatasetId).listItems();
51items.forEach((item) => {
52 console.dir(item);
53});
54
55