Menu
Docs/SDKs & Libraries

SDKs & Libraries

Official client libraries for SnapSharp in 5 languages. All SDKs cover the full API: screenshots, OG images, HTML-to-image, templates, and usage.

Don't see your language? The API is a simple REST interface — any HTTP client works. See the Quick Start for raw curl examples.

Node.js / TypeScript

npm install @snapsharp/sdk
import { SnapSharp } from '@snapsharp/sdk';
import fs from 'fs';

const snap = new SnapSharp('sk_live_your_api_key');

const screenshot = await snap.screenshot('https://example.com', {
  width: 1920,
  height: 1080,
  format: 'webp',
  fullPage: true,
  darkMode: true,
  blockAds: true,
});
fs.writeFileSync('screenshot.webp', screenshot);

const og = await snap.ogImage('blog-post', {
  title: 'My Article',
  author: 'John Doe',
  date: '2026-03-25',
});
fs.writeFileSync('og.png', og);

const card = await snap.htmlToImage(
  '<div style="padding:40px;background:#1a1a2e;color:white;font-size:48px">Hello</div>',
  { width: 1200, height: 630 }
);
fs.writeFileSync('card.png', card);

Python

pip install snapsharp
from snapsharp import SnapSharp
import os

snap = SnapSharp(os.environ["SNAPSHARP_API_KEY"])

image = snap.screenshot("https://example.com", width=1920, format="webp", full_page=True)
with open("screenshot.webp", "wb") as f:
    f.write(image)

og = snap.og_image("blog-post", {"title": "My Article", "author": "Jane Doe"})
with open("og.png", "wb") as f:
    f.write(og)

card = snap.html_to_image(
    '<div style="padding:40px;background:#1a1a2e;color:white;font-size:48px">Hello</div>',
    width=1200, height=630
)
with open("card.png", "wb") as f:
    f.write(card)

Supports context managers:

with SnapSharp("sk_live_...") as snap:
    image = snap.screenshot("https://example.com")

Go

go get github.com/bogdanov-igor/snapsharp/sdk-go
package main

import (
    "os"
    snapsharp "github.com/bogdanov-igor/snapsharp/sdk-go"
)

func main() {
    client := snapsharp.New(os.Getenv("SNAPSHARP_API_KEY"))

    data, err := client.Screenshot("https://example.com", &snapsharp.ScreenshotParams{
        Width:    1920,
        Height:   1080,
        Format:   "webp",
        FullPage: true,
        DarkMode: true,
        BlockAds: true,
    })
    if err != nil {
        panic(err)
    }
    os.WriteFile("screenshot.webp", data, 0644)
}

PHP

composer require snapsharp/sdk
<?php
require 'vendor/autoload.php';

use SnapSharp\SnapSharp;

$snap = new SnapSharp($_ENV['SNAPSHARP_API_KEY']);

$image = $snap->screenshot('https://example.com', [
    'width'     => 1920,
    'height'    => 1080,
    'format'    => 'webp',
    'full_page' => true,
    'dark_mode' => true,
]);
file_put_contents('screenshot.webp', $image);

Ruby

gem install snapsharp
require "snapsharp"

snap = SnapSharp.new(ENV["SNAPSHARP_API_KEY"])

image = snap.screenshot("https://example.com",
  width: 1920, height: 1080, format: "webp", full_page: true
)
File.binwrite("screenshot.webp", image)

Error handling

All SDKs throw typed errors for common API failures:

Error classCauseWhat to do
AuthErrorInvalid or missing API keyCheck your key in the Dashboard
RateLimitErrorPer-minute rate limit hitWait retryAfter seconds, then retry
TimeoutErrorScreenshot took > 30 secondsUse wait_until: 'domcontentloaded' for slow pages
SnapSharpError / APIErrorOther API errorCheck status and message for details

Node.js example:

import { SnapSharp, AuthError, RateLimitError, TimeoutError } from '@snapsharp/sdk';

try {
  const buffer = await snap.screenshot('https://example.com');
} catch (err) {
  if (err instanceof AuthError) {
    console.error('Invalid API key');
  } else if (err instanceof RateLimitError) {
    console.error(`Rate limited. Retry after ${err.retryAfter}s`);
  } else if (err instanceof TimeoutError) {
    console.error('Screenshot timed out');
  }
}

Configuration

All SDKs accept these constructor options:

OptionDefaultDescription
apiKeyYour API key (required)
baseUrlhttps://api.snapsharp.devAPI base URL
timeout30000Request timeout in milliseconds

Source code

LanguagePackageRepository
Node.js@snapsharp/sdkpackages/sdk-node
Pythonsnapsharppackages/sdk-python
Gosnapsharp-gopackages/sdk-go
PHPsnapsharp/sdkpackages/sdk-php
Rubysnapsharppackages/sdk-ruby

Also available: a CLI tool for terminal workflows and CI/CD pipelines.