1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "html": "<style>body{margin:0}</style><div style=\"width:1200px;height:630px;box-sizing:border-box;padding:72px;background:linear-gradient(135deg,#0ea5e9,#6366f1);color:#fff;font-family:Inter,Segoe UI,Arial,sans-serif;display:flex;flex-direction:column;justify-content:space-between\"><div style=\"font-size:28px;opacity:.85\">{{site}}</div><div style=\"font-size:64px;font-weight:800;line-height:1.1\">{{title}}</div><div style=\"font-size:30px\">{{author}} · {{date}}</div></div>",
12 "data": [
13 {
14 "site": "blog.example.com",
15 "title": "How we cut our cloud bill by 40%",
16 "author": "Maria Lopez",
17 "date": "Oct 2026",
18 "fileName": "cloud-bill"
19 },
20 {
21 "site": "blog.example.com",
22 "title": "10 lessons from shipping every week",
23 "author": "Sam Chen",
24 "date": "Oct 2026",
25 "fileName": "shipping-weekly"
26 }
27 ],
28 "fileNameField": "fileName"
29};
30
31
32const run = await client.actor("bossless/html-to-image").call(input);
33
34
35console.log('Results from dataset');
36console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
37const { items } = await client.dataset(run.defaultDatasetId).listItems();
38items.forEach((item) => {
39 console.dir(item);
40});
41
42