Skip to Content
Engineering11 Documentation 🔥

Browser Client API

Client SDK for remote headless browser server with PDF generation capabilities.

What It Does

The Browser Client API provides integration with a remote headless browser server for generating PDFs from URLs. It handles API key authentication, configuration management, and PDF generation requests with comprehensive rendering control via Puppeteer options.

Key Capabilities

  • PDF Generation: Convert any URL to PDF with fine-grained rendering control
  • API Key Authentication: Automatic Bearer token injection via Axios interceptors
  • Configuration Management: Environment-based browser server configuration
  • Rendering Options: Control page size, format, element selection, delays, timeouts
  • Paper Formats: Support for letter, legal, A0-A6, tabloid, ledger formats
  • Custom Dimensions: Set custom page width and height
  • Element Selection: Render specific page elements via CSS selectors
  • Single Page Mode: Render content as single page without breaks

Main Components

BrowserClient

Main service for PDF generation:

generatePdf(model: GeneratePDFModel): Promise<AxiosResponse>

GeneratePDFModel (DTO)

Request parameters based on Puppeteer PDFOptions:

  • url: URL to render (required)
  • format: Paper format (letter, legal, a4, etc.)
  • delay, timeout: Rendering control in milliseconds
  • elementSelector: CSS selector for specific element
  • width, height: Custom dimensions
  • isSinglePage: Single page rendering
  • browserHeight, browserWidth: Browser window size
  • preferCSSPageSize: Use CSS page size

BrowserConfig

Environment configuration service:

  • baseURL: Browser server endpoint
  • fqdn: API key lookup domain
  • generatePDFPath: PDF generation endpoint

Security

  • ApiKeyConfig: Manages API keys from secrets and environment
  • ApiKeyInterceptorFactory: Creates Axios interceptors for auth
  • BearerAuthorization: Utilities for Bearer token creation
  • ApiKeyMiddleware: NestJS middleware for validating incoming requests

Configuration

Environment Variables

  • BROWSER_BASE_URL: Browser server URL (default: https://browser.engineering11.com )
  • BROWSER_FQDN: Domain for API key lookup (default: browser.engineering11.com)
  • BROWSER_GENERATE_PDF_PATH: PDF endpoint path (default: /generate-pdf)
  • API_KEY_{ENVAR_FQDN}: API key for authentication

Common Use Cases

  • Document generation from HTML templates
  • Invoice and receipt PDFs
  • Report generation from web pages
  • Certificate and badge generation
  • Dynamic PDF creation from web apps

What Customers Don’t Have to Build

  • Headless browser infrastructure
  • PDF generation from URLs
  • API key authentication system
  • Axios request interceptors
  • Bearer token management
  • Configuration reflection from environment
  • Absolute path validation
  • Base64 encoding utilities
  • SHA256 hashing for API keys
Last updated on