package pxshot

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module PxshotSource

Pxshot - Official OCaml SDK for the Pxshot screenshot API

Types

Sourcetype format =
  1. | Png
  2. | Jpeg
  3. | Webp

Image format for screenshots

Sourcetype wait_until =
  1. | Load
  2. | Domcontentloaded
  3. | Networkidle

Wait condition for page loading

Sourcetype screenshot_options = {
  1. url : string;
  2. format : format option;
  3. quality : int option;
  4. width : int option;
  5. height : int option;
  6. full_page : bool option;
  7. wait_until : wait_until option;
  8. wait_for_selector : string option;
  9. wait_for_timeout : int option;
  10. device_scale_factor : float option;
  11. store : bool option;
  12. block_ads : bool option;
}

Screenshot options

Sourcetype stored_screenshot = {
  1. url : string;
  2. expires_at : string;
  3. width : int;
  4. height : int;
  5. size_bytes : int;
}

Result when store=true

Sourcetype screenshot_response =
  1. | Bytes of bytes
  2. | Stored of stored_screenshot

Screenshot response - either raw bytes or stored URL

Sourcetype usage = {
  1. screenshots_taken : int;
  2. screenshots_limit : int;
  3. bytes_used : int;
  4. bytes_limit : int;
  5. period_start : string;
  6. period_end : string;
}

Usage statistics

Sourcetype error =
  1. | Unauthorized of string
  2. | BadRequest of string
  3. | RateLimited of string
  4. | ServerError of string
  5. | NetworkError of string
  6. | ParseError of string

Error types

Client

Sourcetype t

The Pxshot client

Sourceval create : ?base_url:string -> string -> t

Create a new Pxshot client with the given API key.

  • parameter base_url

    Optional custom API base URL (defaults to https://api.pxshot.com)

Screenshot

Sourceval screenshot : t -> url:string -> ?format:format -> ?quality:int -> ?width:int -> ?height:int -> ?full_page:bool -> ?wait_until:wait_until -> ?wait_for_selector:string -> ?wait_for_timeout:int -> ?device_scale_factor:float -> ?store:bool -> ?block_ads:bool -> unit -> (screenshot_response, error) result Lwt.t

Capture a screenshot of the given URL.

  • parameter url

    The URL to capture

  • parameter format

    Image format (default: Png)

  • parameter quality

    JPEG/WebP quality 1-100 (default: 80)

  • parameter width

    Viewport width in pixels (default: 1280)

  • parameter height

    Viewport height in pixels (default: 720)

  • parameter full_page

    Capture the full scrollable page (default: false)

  • parameter wait_until

    Wait condition (default: Load)

  • parameter wait_for_selector

    CSS selector to wait for before capture

  • parameter wait_for_timeout

    Additional wait time in milliseconds

  • parameter device_scale_factor

    Device scale factor for retina displays (default: 1.0)

  • parameter store

    Store screenshot and return URL instead of bytes (default: false)

  • parameter block_ads

    Block ads and trackers (default: false)

  • returns

    Screenshot bytes or stored URL info

Usage

Sourceval get_usage : t -> (usage, error) result Lwt.t

Get current usage statistics

Helpers

Sourceval format_to_string : format -> string

Convert format to string

Sourceval wait_until_to_string : wait_until -> string

Convert wait_until to string

Sourceval error_to_string : error -> string

Convert error to human-readable string