---
title: Serverless Function - Screenshot with Puppeteer
description: Use a Serverless Function to take screenshots with Puppeteer and Playwright.
source_url:
  html: https://testingbot.com/support/functions/screenshot
  md: https://testingbot.com/support/functions/screenshot/index.md
---
# Screenshot Function

This function will take a screenshot of the page you specified and return the image in `.png` or `.jpg` format.   
You can take one or more screenshots, in parallel, on different browsers and operating systems without having to write any code.

Simply use the HTTP requests listed below in your app to generate a live screenshot of any page, on a real TestingBot browser.

## Example

    curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com"}' > screenshot.png

This simple example will run a Puppeteer script on our service and do the following:

- Start a Headless Browser (latest version) on our cloud
- Connect with Puppeteer to the Browser and navigate to the URL you specified
- Take a screenshot of the page
- Return the `PNG data` back to you
- The `PNG data` is saved in a file called `screenshot.png`

## Specifying browser and version

See the example below to specify on which platform configuration you'd like to take your screenshot on. You can specify a `browserName`, `version` and `platform`.

  ![OS selected](https://testingbot.com/assets/environments/svg/windows11-0e1b28bc0fdd5034d3e4d3dc8d346c500a8c6522facf4b45d0da56537c1f1c6d.svg) Windows 11 › ![Browser selected](https://testingbot.com/assets/environments/svg/chrome-c4081ff447d2d898d4afcb8f074a907c960e6f007716c1a1d119eee6803c4042.svg) Chrome 139 

Loading environments...

Please wait while we load the available browsers and platforms.

    

## Screenshot Options

You can specify additional options with this function call to customize the screenshot taking.

This function call can use any of the Puppeteer [page.screenshot](https://pptr.dev/api/puppeteer.screenshotoptions/) options.

    curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "options":{"fullPage":true}}' > screenshot.png

### Authenticate options

You can specify the [page.authenticate](https://pptr.dev/api/puppeteer.page.authenticate/) credentials.

    curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "authenticate":{ "username": "user", "password": "passwd" }}' > screenshot.png

### Goto options

You can specify the [page.goto](https://pptr.dev/api/puppeteer.page.goto/) options and add `timeout` and `waitUntil` settings.

    curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "gotoOptions":{ "waitUntil": "networkidle2" }}' > screenshot.png

### Extra Headers

You can specify the [page.setExtraHTTPHeaders](https://pptr.dev/api/puppeteer.page.setextrahttpheaders/) options to add extra HTTP headers to the request our Headless Browser makes.

    curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "extraHeaders":{ "foo": "bar" }}' > screenshot.png

### Disable Javascript

You can disable Javascript with the [page.setJavaScriptEnabled](https://pptr.dev/api/puppeteer.page.setjavascriptenabled/) option.

    curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "javascriptEnabled":false}' > screenshot.png

### Add Tags

- You can add additional `style tags` with the [page.addStyleTag](https://pptr.dev/api/puppeteer.page.addstyletag) option. 

- You can add additional `script tags` with the [page.addScriptTag](https://pptr.dev/api/puppeteer.page.addscripttag/) option. 

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
