REST API that captures screenshots of web pages using Puppeteer and Fastify.
Locally it uses the full puppeteer package with a system Chrome install. When IS_SERVERLESS is set, it uses puppeteer-core with @sparticuz/chromium for environments such as AWS Lambda.
- A recent Node.js LTS release (the project uses
NodeNextmodules and modern syntax) - For local runs: Chrome installed for Puppeteer (
npm run install:chromeafter dependencies are installed)
npm install
npm run install:chromeinstall:chrome runs npx puppeteer browsers install chrome so Puppeteer can launch the browser on your machine. Serverless deployments do not need this when using the packaged Chromium path.
| Variable | Description |
|---|---|
PORT |
HTTP port (default 3000) |
IS_SERVERLESS |
When set (any truthy value), launch Chromium via @sparticuz/chromium instead of bundled local Chrome |
Optional dotenv-style files are supported in production: npm start uses node --env-file-if-exists .env so you can place PORT or other vars in .env if you use that workflow.
| Command | Description |
|---|---|
npm run dev |
Run the server with hot reload (tsx) |
npm run build |
Compile TypeScript to dist/ |
npm start |
Run compiled server (dist/server.js) |
npm run install:chrome |
Install Chrome for local Puppeteer |
npm run lint |
ESLint |
npm run lint:fix |
ESLint with auto-fix |
Development:
npm run devProduction:
npm run build
npm startThe server listens on port 3000 unless PORT is set.
Returns JSON describing the service, version, and available endpoints (including query parameters for /website-to-blob-img).
Returns a screenshot of the given page as binary image data.
Query parameters
| Name | Required | Description |
|---|---|---|
url |
Yes | Page to capture (must be loadable by the server). |
format |
No | png (default), jpeg, or webp. |
width |
No | Viewport width in pixels (default 1280). |
height |
No | Viewport height in pixels (default 720). |
Success
- Status
200 Content-Type:image/png,image/jpeg, orimage/webpdepending onformat
Errors
400— Missingurl, or invalidformat500— Screenshot failed (e.g. navigation or browser error)
Example
Check this example with this URL: Fetcher.
Requests are limited to 10 per minute per client (see src/server.ts).
ISC