The SDK client stays up-to-date with the latest API capabilities.
Getting Started
Install the SDK using npm:
npm install @screenshotmax/sdk
Usage Examples
Use the SDK to generate signed or unsigned URLs for screenshots, PDFs, web scraping, or animated screenshot without executing the request. Or fetch and download the result directly. You have full control over when and how each capture runs.
The SDK also supports the Scheduled Tasks API, allowing you to queue captures to run at a later time or on a recurring schedule.
Screenshot example
import fs from "node:fs";
import { SDK } from "@screenshotmax/sdk";
// create API client
const sdk = new SDK("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY");
// set up options
sdk.screenshot.setOptions({
url: "https://example.com",
format: "png"
});
// optionally: generate signed URL
// (https://api.screenshotmax.com/v1/screenshot?url=https%3A%2F%2Fexample.com&format=png&access_key=YOUR_ACCESS_KEY&signature=370f5b161bc59eed13b76........1f778635d7fc595dbab12)
const url = sdk.screenshot.getUrl();
// generate screenshot
const result = await sdk.screenshot.fetch();
fs.writeFileSync("screenshot.png", Buffer.from(result.data, "binary"));
PDF generation example
import fs from "node:fs";
import { SDK } from "@screenshotmax/sdk";
// create API client
const sdk = new SDK("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY");
// set up options and scrape content (chaining)
const result = await sdk.pdf
.setOptions({
url: "https://example.com",
pdf_paper_format: "letter",
})
.fetch();
// generate unsigned URL
// (https://api.screenshotmax.com/v1/pdf?&access_key=YOUR_ACCESS_KEY&url=https%3A%2F%2Fexample.com&pdf_paper_format=letter)
const url = sdk.pdf.getUrl(false);
fs.writeFileSync("pdf.pdf", Buffer.from(result.data, "binary"));
Web scraping example
import fs from "node:fs";
import { SDK } from "@screenshotmax/sdk";
// create API client
const sdk = new SDK("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY");
// set up options
sdk.scrape.setOptions({
url: "https://example.com",
format: "html",
});
const result = await sdk.scrape.fetch();
fs.writeFileSync("scrape.html", result.data);
Scheduled task example
import { SDK } from "@screenshotmax/sdk";
// create API client
const sdk = new SDK("<ACCESS_KEY>", "<SECRET_KEY>");
// get all tasks from account
const tasks = await sdk.task.getTasks();
// {
// tasks: [
// {
// id: 5678133109850112,
// name: 'My cron test',
// api: 'screenshot',
// query: 'url=https%3A%2F%2Fexample.com',
// frequency: 'every_day',
// crontab: '25 13 * * *',
// timezone: 'Etc/UTC',
// enabled: true,
// created: 1747229104,
// last_run: 1748438712,
// runs: 16
// }
// ]
// }
Next Steps
- Explore other API options like HTML to PDF, animated screenshots, or web scraping.
- Create scheduled recurring screenshots via Scheduled Tasks API
Support
For questions, issues, or feature requests, please open an issue on the GitHub repository or contact our support team at support@screenshotmax.com.