CLI for the Shotbot screenshot API
Project description
shotbot-python-cli
A single-file Python CLI for the Shotbot screenshot API. Same flag names, exit codes, and config-file layout as the PHP and Node.js clients | scripts written for one work as-is with the others.
Documentation: https://www.shotbot.net/screenshot-cli-tools/ (English) / https://www.shotbot.fr/outil-cli-capture-ecran/ (French).
Requirements
- Python 3.8+
- Standard library only | no
pip installneeded.
Install
curl -fsSL https://api.shotbot.net/cli/python/shotbot -o shotbot \
&& chmod +x shotbot \
&& ./shotbot help
To put it on your $PATH:
sudo mv shotbot /usr/local/bin/
First run
On first use you'll be prompted for your API key. It is saved to
~/.shotbot-python-cli/config.json (chmod 600). Get a key at
https://www.shotbot.net/screenshot-api-key/.
$ shotbot capture --url=https://example.com
No Shotbot API key configured.
Get one at https://www.shotbot.net/screenshot-api-key/
API key: abc123def456
✓ Saved to /home/you/.shotbot-python-cli/config.json (chmod 600)
Usage
shotbot capture --url=https://example.com
shotbot capture --url=https://example.com --output # cwd, auto-named
shotbot capture --url=https://example.com --output=screenshots/ # into dir, auto-named
shotbot capture --url=https://example.com --output=hero.jpg # exact path
shotbot capture --url=https://example.com --full-page --dark
shotbot capture --url=https://example.com --json | jq .
Privacy: any capture saved with
--outputis never published on the CDN. The CLI requests a private capture, the worker writes the file to a non-public directory on the server, the CLI fetches it once fromapi.shotbot.net, and the server deletes it on read. There is no public URL at any point | useful for sensitive pages (intranet, dashboards, customer data). Captures without--outputkeep the existing CDN-backed flow.
Capture options
Free tier
| Option | Values | Default |
|---|---|---|
--url |
http(s) URL (required) | |
--format |
jpg, png, webp, avif, pdf |
jpg |
--viewport |
360..1920 (px) | 1280 |
--output-size |
120..1920 (resize the result, px) | viewport |
--wait |
0..120 (seconds after page load) | 5 |
--ratio |
16:9, 4:3, 1:1, 9:16, etc. |
16:9 |
--full-page |
flag | off |
--nojs |
flag (disable JavaScript before navigation) | off |
--color-scheme |
dark | light (sets prefers-color-scheme) |
off |
--hidpi |
flag (2x DPR) | off |
Pro
| Option | Values |
|---|---|
--dismiss-cookies |
accept | reject (auto-handle cookie consent banners) |
--scroll |
flag (scroll the page before capture; lazy-load trigger) |
--block-ads |
flag (block ad-network requests) |
--crop-height |
10..20000 (crops the result, overrides ratio, implies full-page) |
--selector |
CSS selector (capture only the matched DOM element) |
--http-auth-user |
string (HTTP Basic Auth user) |
--http-auth-pass |
string (HTTP Basic Auth password) |
PDF (only when --format=pdf)
| Option | Values | Default |
|---|---|---|
--pdf-page-size |
A4, A3, A5, Letter, Legal, Tabloid |
A4 |
--pdf-margin |
0..50 (page margin in mm) | 10 |
--pdf-scale |
0.10..2.00 (rendering scale) | 1.00 |
--pdf-landscape |
flag (landscape orientation) | off |
CLI ergonomics
| Option | Values | Default |
|---|---|---|
--output |
save image to disk; see below | none |
--json |
print full JSON response, no chrome | off |
--timeout |
max seconds to wait for the capture | 180 |
--output automatically requests a private capture | the file is not put
on static.shotbot.net. See the privacy note above.
--output modes
| Form | Saves to |
|---|---|
--output |
./<host>-<short_token>.<format> (cwd, auto-named) |
--output=screenshots/ |
screenshots/<host>-<short_token>.<format> (auto-named) |
--output=path/to/file.jpg |
exactly that path |
Auto filename example for https://www.example.com/:
example.com-a1b2c3d4.jpg (www. stripped, first 8 chars of the job id, format extension).
Persistent defaults
Save options once and they apply to every capture. Per-call flags always win.
shotbot set full-page # always full-page
shotbot set output ./shots/ # always save into ./shots/ (and private)
shotbot set viewport 1440 # always render at 1440 px
shotbot set format webp # always webp
shotbot defaults # show what's stored
shotbot defaults --keys # list every settable key + type
shotbot unset full-page # forget that default
Booleans accept true/false/yes/no/1/0; bare set <key> on a boolean
is shorthand for set <key> true. Defaults live in the same config.json as
the API key, under a defaults object.
Free tier
| Settable key | Type | Notes |
|---|---|---|
format |
string (enum) | jpg / png / webp / avif / pdf |
viewport |
int | 360..1920 |
output-size |
int | 120..1920 (resize the result) |
wait |
int | 0..120 |
ratio |
string | 16:9, 4:3, 1:1, etc. |
color-scheme |
string (enum) | dark | light |
full-page |
bool | |
nojs |
bool | disable JavaScript |
hidpi |
bool |
Pro
| Settable key | Type | Notes |
|---|---|---|
dismiss-cookies |
string (enum) | accept | reject |
scroll |
bool | scroll before capture |
block-ads |
bool | |
crop-height |
int | 10..20000 |
selector |
string | CSS selector |
http-auth-user |
string | HTTP Basic user |
http-auth-pass |
string | HTTP Basic password |
PDF (only when format=pdf)
| Settable key | Type | Notes |
|---|---|---|
pdf-page-size |
string (enum) | A4/A3/A5/Letter/Legal/Tabloid |
pdf-margin |
int | 0..50 (mm) |
pdf-scale |
float | 0.10..2.00 |
pdf-landscape |
bool |
CLI
| Settable key | Type | Notes |
|---|---|---|
output |
string | path or true; makes every capture private + saved locally |
timeout |
int | max polling seconds |
Other commands
| Command | What |
|---|---|
shotbot status |
Show account plan, credits, quota, captures in flight. |
shotbot set <key> [value] |
Persist a default option. |
shotbot unset <key> |
Clear a persisted default. |
shotbot defaults [--keys] |
List your defaults; --keys lists settable keys. |
shotbot config |
Print the path to the config file. |
shotbot reset |
Re-prompt for the API key. |
shotbot version |
Print the version. |
shotbot help |
Show help. |
Environment
| Variable | Effect |
|---|---|
SHOTBOT_API_KEY |
Override the stored key (useful in CI). |
SHOTBOT_API_BASE |
Override the API base URL (default https://api.shotbot.net). |
NO_COLOR |
Disable ANSI color output. |
Exit codes
| Code | Meaning |
|---|---|
0 |
Success. |
2 |
Bad invocation (missing args, bad config, etc.). |
3 |
Network error. |
4 |
API returned an error response. |
5 |
Waitlisted (quota exhausted). |
6 |
Capture failed on the server side. |
7 |
Polling timeout. |
CI example
export SHOTBOT_API_KEY=abc123def456
shotbot capture --url=https://staging.example.com --output=before.jpg
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shotbot-0.1.0.tar.gz.
File metadata
- Download URL: shotbot-0.1.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64fe86058ab647d420e8c8d871c7c7e81bf51c29b2c93b635d03f0a4a35c1c61
|
|
| MD5 |
7abe5ce85e2a5f0047a1c1c753d6568f
|
|
| BLAKE2b-256 |
685006037c322095d0a276709b7f761eca75283917edaf784935f5fb9235db80
|
File details
Details for the file shotbot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: shotbot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96141fb6805d74da1b5de1142c655cceb5199ebd7fbaa8a7db871e20f7ebdf05
|
|
| MD5 |
1140dc3c45004913e822cd7724d1aa20
|
|
| BLAKE2b-256 |
ccf3cb27199eefbcd02178ec8fbc319fed6e0b45b2b76e310215095e3c87c1bc
|