Pageshot
Launchpad

First Capture

Understanding binary responses and formats.

Pageshot returns binary image data by default. This is the simplest and most efficient way to get your screenshots.

Binary Response

The API returns the image bytes directly in the response body:

curl -X POST https://api.pageshot.com/v1/capture \
  -H "Content-Type: application/json" \
  -H "X-Access-Key: your_api_key" \
  -d '{
    "url": "https://example.com",
    "format": "png"
  }' \
  --output capture.png

Response:

HTTP/1.1 200 OK
Content-Type: image/png
Content-Length: 245678
X-Request-Id: req_abc123

<binary PNG data>

Save to File

const fs = require('fs');
const https = require('https');

const options = {
  hostname: 'api.pageshot.com',
  path: '/v1/capture',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Access-Key': process.env.PAGESHOT_KEY
  }
};

const req = https.request(options, (res) => {
  const file = fs.createWriteStream('capture.png');
  res.pipe(file);
  file.on('finish', () => {
    console.log('Capture saved!');
  });
});

req.write(JSON.stringify({
  url: 'https://example.com',
  format: 'png'
}));
req.end();
import requests
import os

response = requests.post(
    'https://api.pageshot.com/v1/capture',
    headers={'X-Access-Key': os.environ['PAGESHOT_KEY']},
    json={'url': 'https://example.com', 'format': 'png'}
)

with open('capture.png', 'wb') as f:
    f.write(response.content)
package main

import (
    "bytes"
    "encoding/json"
    "io"
    "net/http"
    "os"
)

func main() {
    body := map[string]interface{}{
        "url":    "https://example.com",
        "format": "png",
    }
    jsonBody, _ := json.Marshal(body)

    req, _ := http.NewRequest("POST", "https://api.pageshot.com/v1/capture", bytes.NewBuffer(jsonBody))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("X-Access-Key", os.Getenv("PAGESHOT_KEY"))

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    file, _ := os.Create("capture.png")
    defer file.Close()
    
    io.Copy(file, resp.Body)
}

Stream to Memory

If you need to process the image in memory:

const response = await fetch('https://api.pageshot.com/v1/capture', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Access-Key': process.env.PAGESHOT_KEY
  },
  body: JSON.stringify({
    url: 'https://example.com',
    format: 'png'
  })
});

const buffer = await response.arrayBuffer();
// Process buffer...

Response Headers

Every response includes useful headers:

HeaderDescription
Content-TypeImage MIME type (image/png, image/jpeg, etc.)
Content-LengthSize of the image in bytes
X-Request-IdUnique request identifier for debugging
X-RateLimit-LimitYour rate limit
X-RateLimit-RemainingRequests remaining
X-RateLimit-ResetWhen the limit resets (Unix timestamp)

Request ID

Always save the X-Request-Id header for troubleshooting and support requests.