1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "mode": "infer",
12 "data": {
13 "name": "Example",
14 "age": 30,
15 "email": "user@example.com"
16 },
17 "schema": {
18 "$schema": "http://json-schema.org/draft-07/schema#",
19 "type": "object",
20 "properties": {
21 "name": {
22 "type": "string"
23 },
24 "age": {
25 "type": "integer",
26 "minimum": 0
27 },
28 "email": {
29 "type": "string",
30 "format": "email"
31 }
32 },
33 "required": [
34 "name",
35 "email"
36 ]
37 },
38 "items": [
39 {
40 "data": {
41 "name": "Alice",
42 "email": "alice@example.com"
43 }
44 },
45 {
46 "data": {
47 "name": "Bob",
48 "email": "invalid"
49 }
50 }
51 ],
52 "draft": "draft-07"
53};
54
55
56const run = await client.actor("perryay/json-schema-validator-generator").call(input);
57
58
59console.log('Results from dataset');
60console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
61const { items } = await client.dataset(run.defaultDatasetId).listItems();
62items.forEach((item) => {
63 console.dir(item);
64});
65
66