CLI
The official command-line tool for SnapSharp. Take screenshots, generate OG images, and check usage — all from your terminal or CI/CD pipeline.
Install
npm install -g snapsharp-cliOr run without installing:
npx snapsharp-cli screenshot https://example.comAuthentication
The CLI resolves your API key in this order:
--key <key>flag on any commandSNAPSHARP_API_KEYenvironment variable.snapsharprcfile in the current directory or home directory
echo "sk_live_your_api_key" > ~/.snapsharprcCommands
screenshot
Capture a screenshot of any URL.
snapsharp screenshot https://example.com
snapsharp screenshot https://example.com -o out.webp -f webp --full-page --dark-mode
snapsharp screenshot https://example.com --width 1920 --height 1080 --block-ads
snapsharp screenshot https://example.com --device "iPhone 14" -o mobile.png
snapsharp screenshot https://example.com --hide "#cookie-banner,.modal" -o clean.png
snapsharp screenshot https://example.com --stealth --proxy socks5://user:pass@host:port| Flag | Description |
|---|---|
-o, --output | Output file path (default: screenshot.png) |
-f, --format | Output format: png, jpeg, webp |
--width | Viewport width in pixels, 100–3840 (default: 1280) |
--height | Viewport height in pixels, 100–2160 (default: 720) |
--full-page | Capture full scrollable page |
--dark-mode | Emulate dark mode |
--block-ads | Block ads and cookie banners |
--device | Device preset (e.g. "iPhone 14") |
--delay | Wait N ms after page load |
--retina | 2× pixel density |
--wait-for | CSS selector to wait for |
--hide | CSS selectors to hide |
--stealth | Enable stealth mode (Growth+) |
--proxy | Proxy URL (Growth+) |
og
Generate an OG image from a built-in or custom template.
snapsharp og blog-post --data '{"title":"My Article","author":"Jane Doe"}' -o og.pnghtml
Render HTML to an image. Accepts inline HTML or a file path.
snapsharp html '<div style="padding:40px;color:white;background:#1a1a2e">Hello</div>' -o card.png
snapsharp html ./template.html --width 1200 --height 630 -f webptemplates
List available OG image templates.
snapsharp templates # pretty-printed list
snapsharp templates --json # JSON outputusage
Check your current usage and limits.
snapsharp usage # visual progress bar
snapsharp usage --json # JSON outputci
Screenshot with exit codes for CI/CD pipelines. Exits 0 on success, 1 on failure.
snapsharp ci --url https://staging.example.com --output screenshot.pngCI/CD integration
Use the ci command in GitHub Actions, GitLab CI, or any pipeline:
- name: Capture staging screenshot
env:
SNAPSHARP_API_KEY: ${{ secrets.SNAPSHARP_API_KEY }}
run: npx snapsharp-cli ci --url https://staging.example.com --output screenshot.png
- uses: actions/upload-artifact@v4
with:
name: screenshot
path: screenshot.pngThe CLI uses the official Node.js SDK under the hood. All SDK features are available via CLI flags.