Pageshot
Ecosystem

SDKs and Code Examples

Use Pageshot from your language of choice.

Use the same JSON body across languages. Replace the API key and URL.

const res = 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',
    response_type: 'json',
    storage: { store: true },
  }),
});

const data = await res.json();
console.log(data.data.images.full);
import os
import requests

response = requests.post(
    "https://api.pageshot.com/v1/capture",
    headers={
        "Content-Type": "application/json",
        "X-Access-Key": os.environ["PAGESHOT_KEY"],
    },
    json={
        "url": "https://example.com",
        "format": "png",
        "response_type": "json",
        "storage": {"store": True},
    },
)

data = response.json()
print(data["data"]["images"]["full"])
package main

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

func main() {
    body := map[string]interface{}{
        "url":           "https://example.com",
        "format":        "png",
        "response_type": "json",
        "storage":       map[string]bool{"store": true},
    }
    
    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()
}
require 'net/http'
require 'json'

uri = URI('https://api.pageshot.com/v1/capture')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.path)
request['Content-Type'] = 'application/json'
request['X-Access-Key'] = ENV['PAGESHOT_KEY']
request.body = {
  url: 'https://example.com',
  format: 'png',
  response_type: 'json',
  storage: { store: true }
}.to_json

response = http.request(request)
data = JSON.parse(response.body)
puts data['data']['images']['full']