Skip to main content
Use the official Screenshothis SDK for JavaScript and TypeScript applications to capture screenshots with full type safety and IDE support. The SDK provides a clean interface, comprehensive error handling, and optimized bundle sizes through tree-shaking.

Installation

TypeScript support: The SDK includes complete TypeScript definitions out of the box. For optimal support, ensure your tsconfig.json targets ES2020 or higher.

Quick start

Get up and running in three simple steps:
1

Import the SDK

2

Initialize client

3

Capture your first screenshot

Basic usage

Simple screenshot

Capture a basic screenshot with minimal configuration:

Advanced screenshot with options

Configure your screenshot with full control over the output:

Tree-shaking optimization

Reduce your bundle size by up to 80% using tree-shakable standalone functions:
Bundle size benefit: Tree-shaking can reduce your bundle size by up to 80% compared to the full SDK import, making it perfect for client-side applications.

Comprehensive error handling

The SDK provides specific error types for different failure scenarios:

Basic error handling

Handle common errors with try-catch blocks:

Error types reference

Always implement error handling in production applications. Use the requestId from error responses when contacting support.

Advanced configuration

Custom server URL

Override the default API endpoint for self-hosted instances:

Retry configuration

Configure automatic retries for transient failures:

Custom HTTP client

Add request hooks and custom behavior:

Real-world examples

React component for screenshot capture

Create a reusable React component for screenshot functionality:

Node.js batch processing

Process multiple URLs efficiently with concurrency control:

Express.js API integration

Build a screenshot service with Express.js:

Vue.js composable

Create a Vue composable for screenshot functionality:

Best practices

  • Use tree-shaking imports to reduce bundle size
  • Implement proper caching strategies for screenshots
  • Consider using WebP format for smaller file sizes
  • Batch multiple requests to optimize rate limit usage
  • Use appropriate quality settings based on use case
  • Always wrap API calls in try-catch blocks
  • Implement retry logic for transient failures
  • Use specific error types for different handling strategies
  • Log request IDs for debugging and support
  • Provide fallback options when screenshots fail
  • API keys use domain whitelisting—safe to commit to version control
  • Configure allowed domains in your dashboard to control key usage
  • Validate URLs before sending to the API
  • Implement rate limiting in your own applications
  • Use HTTPS for all API requests in production
  • Clean up blob URLs when no longer needed
  • Use streaming for large images when possible
  • Implement proper garbage collection in long-running processes
  • Monitor memory usage in batch processing scenarios
  • Consider using file streams instead of keeping images in memory

TypeScript support

The SDK provides comprehensive TypeScript support with:
  • Full type definitions for all API parameters and responses
  • IntelliSense support in VS Code and other editors
  • Compile-time validation for API parameters
  • Type-safe error handling with specific error classes
  • Generic types for custom configurations

Next steps

API Reference

Explore all available API parameters and response formats

Quickstart Guide

Get started with basic screenshot capture in minutes

Self-hosting

Run Screenshothis on your own infrastructure

GitHub Repository

View source code, report issues, or contribute