Menu
Docs/CLI

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-cli

Or run without installing:

npx snapsharp-cli screenshot https://example.com

Authentication

The CLI resolves your API key in this order:

  1. --key <key> flag on any command
  2. SNAPSHARP_API_KEY environment variable
  3. .snapsharprc file in the current directory or home directory
echo "sk_live_your_api_key" > ~/.snapsharprc

Commands

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
FlagDescription
-o, --outputOutput file path (default: screenshot.png)
-f, --formatOutput format: png, jpeg, webp
--widthViewport width in pixels, 100–3840 (default: 1280)
--heightViewport height in pixels, 100–2160 (default: 720)
--full-pageCapture full scrollable page
--dark-modeEmulate dark mode
--block-adsBlock ads and cookie banners
--deviceDevice preset (e.g. "iPhone 14")
--delayWait N ms after page load
--retina2× pixel density
--wait-forCSS selector to wait for
--hideCSS selectors to hide
--stealthEnable stealth mode (Growth+)
--proxyProxy 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.png

html

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 webp

templates

List available OG image templates.

snapsharp templates          # pretty-printed list
snapsharp templates --json   # JSON output

usage

Check your current usage and limits.

snapsharp usage             # visual progress bar
snapsharp usage --json      # JSON output

ci

Screenshot with exit codes for CI/CD pipelines. Exits 0 on success, 1 on failure.

snapsharp ci --url https://staging.example.com --output screenshot.png

CI/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.png

The CLI uses the official Node.js SDK under the hood. All SDK features are available via CLI flags.