1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "calculations": [
12 {
13 "type": "ohms-law",
14 "voltage": 12,
15 "current": 0.5,
16 "label": "12 V at 0.5 A"
17 },
18 {
19 "type": "resistor-color-code",
20 "bands": [
21 "yellow",
22 "violet",
23 "red",
24 "gold"
25 ],
26 "label": "Decode a 4-band resistor"
27 },
28 {
29 "type": "resistor-color-code",
30 "resistance": "4.7k",
31 "bandCount": 5,
32 "label": "Encode 4.7 kohm to 5 bands"
33 },
34 {
35 "type": "led-resistor",
36 "supplyVoltage": 5,
37 "ledForwardVoltage": 2,
38 "ledCurrentMa": 20,
39 "numberOfLeds": 1,
40 "label": "Series resistor for a red LED"
41 },
42 {
43 "type": "voltage-divider",
44 "vin": 9,
45 "r1": "10k",
46 "r2": "4.7k",
47 "label": "9 V divider"
48 },
49 {
50 "type": "component-network",
51 "componentType": "resistor",
52 "connection": "parallel",
53 "values": [
54 "10k",
55 "10k"
56 ],
57 "label": "Two 10 kohm in parallel"
58 },
59 {
60 "type": "rc-filter",
61 "resistance": "10k",
62 "capacitance": "100n",
63 "label": "RC low-pass cutoff"
64 },
65 {
66 "type": "reactance",
67 "frequency": "1k",
68 "inductance": "10m",
69 "capacitance": "100n",
70 "label": "Reactance and LC resonance"
71 },
72 {
73 "type": "energy-cost",
74 "power": 60,
75 "hours": 720,
76 "energyRate": 0.15,
77 "currency": "USD",
78 "label": "60 W load for a month"
79 }
80 ]
81};
82
83
84const run = await client.actor("mangudai/electronics-calculator").call(input);
85
86
87console.log('Results from dataset');
88console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
89const { items } = await client.dataset(run.defaultDatasetId).listItems();
90items.forEach((item) => {
91 console.dir(item);
92});
93
94