It's that time again — another update! This week we're launching a small but useful API quite a few of our developers have asked for, the utils.screenshot API for capturing screenshots of websites programmatically, built atop Chrome's puppeteer headless browser implementation. As a Standard Library API it's easy to combine it with other APIs and features of the platform, like scheduled tasks. I'm excited to show it off!

Screenshot API

The API, available as utils.screenshot, exposes one endpoint and is ready to use with almost no configuration. It's as simple as:

const screenshot = require('lib').utils.screenshot;
let results = await screenshot({url: 'stdlib.com', screenSize: 'desktop'});

Like all APIs on Standard Library, it's easy to integrate utils.screenshot with other APIs. For instance, utils.mms. The mms API requires a URL that points to some picture. You can just reference the screenshot API and send screenshots right to your phone:

await lib.utils.mms({
  to: number,
  mediaUrl:
    'http://utils.lib.id/screenshot/?url=stdlib.com&screenSize=desktop'
});

You can test out the API from the documentation page, or from Code on Standard Library (embedded below, but you can open a new tab from that link). Click "run", and after a moment you should see the Standard Library main page appear in the results panel.

example

If you follow the API Endpoint URL, you can also open the image in a new tab. Please feel free to play with the API using Code on Standard Library embedded below!

That's All!

As usual, thanks for reading. If you have ideas for integrations or need help, join our Slack workspace or ask us on Twitter @StdLibHQ.

Steve Meyer
Software Engineer, Standard Library