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/sdkimport { 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 snapsharpfrom 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-gopackage 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 snapsharprequire "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 class | Cause | What to do |
|---|---|---|
AuthError | Invalid or missing API key | Check your key in the Dashboard |
RateLimitError | Per-minute rate limit hit | Wait retryAfter seconds, then retry |
TimeoutError | Screenshot took > 30 seconds | Use wait_until: 'domcontentloaded' for slow pages |
SnapSharpError / APIError | Other API error | Check 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:
| Option | Default | Description |
|---|---|---|
apiKey | — | Your API key (required) |
baseUrl | https://api.snapsharp.dev | API base URL |
timeout | 30000 | Request timeout in milliseconds |
Source code
| Language | Package | Repository |
|---|---|---|
| Node.js | @snapsharp/sdk | packages/sdk-node |
| Python | snapsharp | packages/sdk-python |
| Go | snapsharp-go | packages/sdk-go |
| PHP | snapsharp/sdk | packages/sdk-php |
| Ruby | snapsharp | packages/sdk-ruby |
Also available: a CLI tool for terminal workflows and CI/CD pipelines.