SDKs overview

Blitapp offers Software Development Kits (SDKs) and client libraries designed to simplify programmatic interaction with its core services: the website screenshot API and the PDF generation API. These SDKs encapsulate the complexities of HTTP request construction, parameter handling, and response parsing, allowing developers to focus on application logic rather than low-level API communication. The primary interaction model involves constructing a URL with specific parameters that dictate the screenshot or PDF generation options, which the SDKs assist in building and executing.

Integrating with the Blitapp API typically involves sending a GET request to a specific endpoint with a series of query parameters. For instance, to capture a screenshot, developers specify the target URL, desired image format, and various rendering options such as viewport size and delay. The API then returns the generated image or PDF. The official SDKs are built to streamline this process across different programming environments, providing idiomatic interfaces for each language.

While Blitapp primarily utilizes a URL-based API, which can be accessed directly via any HTTP client, SDKs provide convenience functions and object-oriented abstractions. This approach is common for APIs that follow a RESTful architecture, where resources are manipulated via standard HTTP methods and often represented by URLs, as described by W3C architectural principles for the web.

Official SDKs by language

Blitapp maintains official SDKs for several popular programming languages. These libraries are developed and supported by Blitapp to ensure compatibility with the latest API features and to provide a consistent developer experience. Each SDK aims to map the API's functionality to language-specific conventions, offering classes, methods, and data structures that align with the respective language's ecosystem.

Language Package/Module Install Command Maturity
Python blitapp-python pip install blitapp-python Stable
Node.js blitapp-node npm install blitapp-node Stable
PHP blitapp/php-client composer require blitapp/php-client Stable
Ruby blitapp-ruby gem install blitapp-ruby Stable

Installation

Installation of Blitapp's official SDKs typically involves using the package manager specific to the chosen programming language. The following sections provide common installation steps for each supported language. Developers should refer to the Blitapp SDK installation guides for the most up-to-date and detailed instructions.

Python

To install the Python SDK, use pip, the Python package installer:

pip install blitapp-python

Ensure you have a compatible Python version installed. Python's official download page provides installers for various operating systems.

Node.js

For Node.js projects, the SDK can be installed via npm (Node Package Manager) or yarn:

npm install blitapp-node
# or
yarn add blitapp-node

Node.js environments require a package.json file for dependency management. Refer to the npm install documentation for more information.

PHP

PHP projects typically use Composer for dependency management. To install the PHP client library:

composer require blitapp/php-client

Ensure Composer is installed and configured in your PHP development environment. The Composer installation guide provides platform-specific instructions.

Ruby

For Ruby applications, the SDK is available as a gem and can be installed using the gem command:

gem install blitapp-ruby

After installation, you can include the gem in your project's Gemfile for Bundler-managed dependencies.

Quickstart example

This quickstart example demonstrates how to use the Blitapp Node.js SDK to generate a screenshot of a website. The process involves initializing the client with your API key and then calling a method to specify the target URL and desired output format. For a full list of available parameters and options, consult the Blitapp API reference documentation.

First, ensure you have your Blitapp API key, which can be found in your Blitapp account dashboard.

Node.js Screenshot Example

const Blitapp = require('blitapp-node');

const API_KEY = 'YOUR_BLITAPP_API_KEY'; // Replace with your actual API key
const blitapp = new Blitapp(API_KEY);

async function captureScreenshot() {
  try {
    const screenshotUrl = await blitapp.createScreenshot({
      url: 'https://example.com',
      format: 'png',
      viewport: '1280x800',
      fullpage: true,
      delay: 2000 // Wait 2 seconds for page to load
    });
    console.log('Screenshot URL:', screenshotUrl);
    // You can now download the screenshot from this URL
  } catch (error) {
    console.error('Error capturing screenshot:', error);
  }
}

captureScreenshot();

This code snippet initializes the Blitapp client with an API key. It then calls the createScreenshot method, passing an object with configuration options such as the target URL, image format (PNG), viewport dimensions, and a flag for full-page capture. The method returns a URL from which the generated screenshot can be downloaded. Similar methods exist for PDF generation, allowing developers to convert web pages into PDF documents with various customization options.

For more advanced use cases, such as custom headers, cookies, or JavaScript execution, refer to the advanced options section in the Blitapp documentation.

Community libraries

In addition to the official SDKs, the Blitapp API can be integrated using generic HTTP client libraries available in virtually every programming language. Since the API is primarily accessed via standard HTTP GET requests, developers are not strictly limited to official SDKs. Community-contributed libraries or direct HTTP calls offer flexibility, particularly for languages or frameworks not officially supported.

Developers can use popular HTTP client libraries such as:

  • Python: requests library for making HTTP requests (Requests documentation).
  • Node.js: axios or the built-in http/https modules.
  • PHP: Guzzle HTTP client.
  • Ruby: Net::HTTP or faraday.

While these generic clients provide the means to interact with the Blitapp API, they require manual construction of request URLs and parameter handling. This means developers would need to string together API endpoints, parameters, and their API key directly, as opposed to using the more abstract methods provided by the official SDKs. For example, a direct API call for a screenshot might look like this:

GET https://api.blitapp.com/screenshot?api_key=YOUR_API_KEY&url=https://example.com&format=png&viewport=1280x800

Community libraries often emerge to fill gaps or provide alternative interfaces, sometimes offering features or language patterns that align more closely with specific project requirements. However, official SDKs generally receive direct support and updates from Blitapp, making them the recommended choice for most integrations.