Liking cljdoc? Tell your friends :D

pxshot.core

Official Clojure SDK for the Pxshot screenshot API.

Quick Start

(require '[pxshot.core :as pxshot])

;; Create a client
(def client (pxshot/client "px_your_api_key"))

;; Take a screenshot (returns bytes)
(def image (pxshot/screenshot client {:url "https://example.com"}))

;; Take a screenshot and store it (returns map with :url)
(def result (pxshot/screenshot client {:url "https://example.com" :store true}))
(:url result) ;; => "https://storage.pxshot.com/..."

;; Check API usage
(pxshot/usage client)

Configuration

The client accepts an optional configuration map:

(def client (pxshot/client "px_your_api_key"
                           {:base-url "https://api.pxshot.com"
                            :timeout 30000}))
Official Clojure SDK for the Pxshot screenshot API.

## Quick Start

```clojure
(require '[pxshot.core :as pxshot])

;; Create a client
(def client (pxshot/client "px_your_api_key"))

;; Take a screenshot (returns bytes)
(def image (pxshot/screenshot client {:url "https://example.com"}))

;; Take a screenshot and store it (returns map with :url)
(def result (pxshot/screenshot client {:url "https://example.com" :store true}))
(:url result) ;; => "https://storage.pxshot.com/..."

;; Check API usage
(pxshot/usage client)
```

## Configuration

The client accepts an optional configuration map:

```clojure
(def client (pxshot/client "px_your_api_key"
                           {:base-url "https://api.pxshot.com"
                            :timeout 30000}))
```
raw docstring

clientclj

(client api-key)
(client api-key opts)

Creates a new Pxshot client.

Arguments: api-key - Your Pxshot API key (string starting with 'px_') opts - Optional configuration map: :base-url - API base URL (default: https://api.pxshot.com) :timeout - Request timeout in milliseconds (default: 30000)

Returns: A client map to pass to other functions.

Example: (def client (pxshot/client "px_your_api_key")) (def client (pxshot/client "px_your_api_key" {:timeout 60000}))

Creates a new Pxshot client.

Arguments:
  api-key - Your Pxshot API key (string starting with 'px_')
  opts    - Optional configuration map:
            :base-url - API base URL (default: https://api.pxshot.com)
            :timeout  - Request timeout in milliseconds (default: 30000)

Returns:
  A client map to pass to other functions.

Example:
  (def client (pxshot/client "px_your_api_key"))
  (def client (pxshot/client "px_your_api_key" {:timeout 60000}))
raw docstring

save-screenshotclj

(save-screenshot client opts path)

Takes a screenshot and saves it to a file.

Arguments: client - A Pxshot client opts - Screenshot options (see screenshot) path - File path to save the image

Returns: The file path.

Example: (save-screenshot client {:url "https://example.com"} "screenshot.png")

Takes a screenshot and saves it to a file.

Arguments:
  client - A Pxshot client
  opts   - Screenshot options (see `screenshot`)
  path   - File path to save the image

Returns:
  The file path.

Example:
  (save-screenshot client {:url "https://example.com"} "screenshot.png")
raw docstring

screenshotclj

(screenshot client opts)

Takes a screenshot of a URL.

Arguments: client - A Pxshot client created with client opts - Screenshot options map: :url - URL to screenshot (required) :format - Image format: "png", "jpeg", "webp" (default: "png") :quality - JPEG/WebP quality 1-100 (default: 80) :width - Viewport width in pixels (default: 1920) :height - Viewport height in pixels (default: 1080) :full-page - Capture full scrollable page (default: false) :wait-until - Wait condition: "load", "domcontentloaded", "networkidle" :wait-for-selector - CSS selector to wait for before capture :wait-for-timeout - Additional wait time in ms after page load :device-scale-factor - Device scale factor for retina (default: 1) :store - Store image and return URL (default: false) :block-ads - Block ads and trackers (default: false)

Returns:

  • When :store is false/nil: byte array of the image
  • When :store is true: map with :url, :expires-at, :width, :height, :size-bytes

Throws: ExceptionInfo on API errors with :type :pxshot/api-error

Examples: ;; Get screenshot as bytes (def image (screenshot client {:url "https://example.com"})) (io/copy (io/input-stream image) (io/file "screenshot.png"))

;; Get screenshot as stored URL (def result (screenshot client {:url "https://example.com" :store true :full-page true})) (:url result) ;; => "https://storage.pxshot.com/..."

Takes a screenshot of a URL.

Arguments:
  client - A Pxshot client created with `client`
  opts   - Screenshot options map:
           :url                - URL to screenshot (required)
           :format             - Image format: "png", "jpeg", "webp" (default: "png")
           :quality            - JPEG/WebP quality 1-100 (default: 80)
           :width              - Viewport width in pixels (default: 1920)
           :height             - Viewport height in pixels (default: 1080)
           :full-page          - Capture full scrollable page (default: false)
           :wait-until         - Wait condition: "load", "domcontentloaded", "networkidle"
           :wait-for-selector  - CSS selector to wait for before capture
           :wait-for-timeout   - Additional wait time in ms after page load
           :device-scale-factor - Device scale factor for retina (default: 1)
           :store              - Store image and return URL (default: false)
           :block-ads          - Block ads and trackers (default: false)

Returns:
  - When :store is false/nil: byte array of the image
  - When :store is true: map with :url, :expires-at, :width, :height, :size-bytes

Throws:
  ExceptionInfo on API errors with :type :pxshot/api-error

Examples:
  ;; Get screenshot as bytes
  (def image (screenshot client {:url "https://example.com"}))
  (io/copy (io/input-stream image) (io/file "screenshot.png"))

  ;; Get screenshot as stored URL
  (def result (screenshot client {:url "https://example.com"
                                  :store true
                                  :full-page true}))
  (:url result) ;; => "https://storage.pxshot.com/..."
raw docstring

screenshot!clj

(screenshot! client opts)

Takes a screenshot, returning bytes or throwing on error.

Same as screenshot but always returns bytes (ignores :store option). Useful when you need raw image data and want to be explicit about it.

See screenshot for full documentation.

Takes a screenshot, returning bytes or throwing on error.

Same as `screenshot` but always returns bytes (ignores :store option).
Useful when you need raw image data and want to be explicit about it.

See `screenshot` for full documentation.
raw docstring

screenshot-bytesclj

(screenshot-bytes client opts)

Takes a screenshot and returns raw bytes.

Convenience function that always sets :store to false.

Arguments: client - A Pxshot client opts - Screenshot options (see screenshot)

Returns: Byte array of the image.

Example: (def image (screenshot-bytes client {:url "https://example.com"})) (io/copy (io/input-stream image) (io/file "shot.png"))

Takes a screenshot and returns raw bytes.

Convenience function that always sets :store to false.

Arguments:
  client - A Pxshot client
  opts   - Screenshot options (see `screenshot`)

Returns:
  Byte array of the image.

Example:
  (def image (screenshot-bytes client {:url "https://example.com"}))
  (io/copy (io/input-stream image) (io/file "shot.png"))
raw docstring

screenshot-urlclj

(screenshot-url client opts)

Takes a screenshot and returns a stored URL.

Convenience function that always sets :store to true.

Arguments: client - A Pxshot client opts - Screenshot options (see screenshot)

Returns: A map with :url, :expires-at, :width, :height, :size-bytes

Example: (def result (screenshot-url client {:url "https://example.com"})) (:url result) ;; => "https://storage.pxshot.com/..."

Takes a screenshot and returns a stored URL.

Convenience function that always sets :store to true.

Arguments:
  client - A Pxshot client
  opts   - Screenshot options (see `screenshot`)

Returns:
  A map with :url, :expires-at, :width, :height, :size-bytes

Example:
  (def result (screenshot-url client {:url "https://example.com"}))
  (:url result) ;; => "https://storage.pxshot.com/..."
raw docstring

usageclj

(usage client)

Gets API usage statistics.

Arguments: client - A Pxshot client created with client

Returns: A map with usage statistics (keys converted to kebab-case).

Throws: ExceptionInfo on API errors with :type :pxshot/api-error

Example: (usage client) ;; => {:screenshots-today 42 ;; :screenshots-month 1337 ;; :plan "pro" ;; ...}

Gets API usage statistics.

Arguments:
  client - A Pxshot client created with `client`

Returns:
  A map with usage statistics (keys converted to kebab-case).

Throws:
  ExceptionInfo on API errors with :type :pxshot/api-error

Example:
  (usage client)
  ;; => {:screenshots-today 42
  ;;     :screenshots-month 1337
  ;;     :plan "pro"
  ;;     ...}
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close