Skip to content

AlejandroAkbal/Screenshot-API

Repository files navigation

Icon

Screenshot API

A simple self-hosted API to take screenshots of websites using Puppeteer.

Technologies

A NestJS wrapper around capture-website.

Check the package.json for the full list of dependencies.

Check the Dockerfile to see how the image is built.

Endpoints

GET /v1/capture

Parameter Type Default Value Description
url string URL to capture
width number 1024 Viewport width
height number 768 Viewport height
scale number 1 Scale factor of the viewport
timeout number 15 Timeout before giving up
delay number 0 Delay after page load
mime_type string webp jpg, png or webp
quality number 0.8 Image quality

You can view the full query parameters here.

Development

Installation

pnpm install

Configuration

cp .env.example .env
nano .env

Running the app

# development
pnpm run start

# watch mode
pnpm run start:dev

# production mode
pnpm run start:prod

Test

# unit tests
pnpm run test

# e2e tests
pnpm run test:e2e

# test coverage
pnpm run test:cov

Building for production

docker build -t screenshot-api .

docker run -p 3000:3000 screenshot-api