SDKs overview

ScreenshotAPI.net provides a RESTful API for generating website screenshots programmatically. To facilitate integration, it offers official SDKs in multiple programming languages, abstracting the complexities of HTTP requests and response parsing. These SDKs are designed to help developers quickly incorporate screenshot functionality into their applications without needing to manage raw API calls directly. The API itself follows standard HTTP methods for interaction, primarily using GET requests for screenshot generation.

The SDKs are maintained by ScreenshotAPI.net and are intended to provide a stable and consistent interface for accessing the service's features. This includes options for setting various parameters such as target URL, full-page capture, viewport dimensions, and delayed rendering, as detailed in the ScreenshotAPI.net documentation. Beyond official support, the straightforward nature of the API also allows for community-driven libraries, though developers often prefer official SDKs due to guaranteed compatibility and support.

Official SDKs by language

ScreenshotAPI.net offers official client libraries for several popular programming languages, ensuring direct support and up-to-date compatibility with the API. These SDKs simplify common tasks such as authentication and parameter serialization, making it easier to integrate screenshot generation capabilities into various applications. Each SDK is typically distributed via its language's standard package manager.

The following table outlines the official SDKs, their respective package names, and typical installation commands:

Language Package Manager Package Name Installation Command Maturity
Node.js npm screenshotapi-client npm install screenshotapi-client Stable
Python pip screenshotapi pip install screenshotapi Stable
PHP Composer screenshotapi/screenshotapi-php composer require screenshotapi/screenshotapi-php Stable
Ruby RubyGems screenshotapi gem install screenshotapi Stable

These official SDKs are designed to provide a consistent developer experience, abstracting the underlying HTTP requests and handling API responses. Developers can refer to the ScreenshotAPI.net documentation for detailed usage instructions and available methods for each language.

Installation

Installing the ScreenshotAPI.net SDKs involves using the package manager specific to your chosen programming language. This process typically fetches the necessary files and dependencies, making the library available for use in your project. Ensure you have the respective package manager (npm for Node.js, pip for Python, Composer for PHP, RubyGems for Ruby) installed and configured in your development environment.

Node.js

To install the Node.js SDK, open your terminal or command prompt and run:

npm install screenshotapi-client

This command adds the screenshotapi-client package to your project's dependencies.

Python

For Python projects, use pip to install the SDK:

pip install screenshotapi

This will install the screenshotapi package, allowing you to import it into your Python scripts.

PHP

PHP developers can install the SDK using Composer:

composer require screenshotapi/screenshotapi-php

After running this command, Composer will add the necessary files and generate an autoloader for your project.

Ruby

To integrate the SDK into a Ruby application, use RubyGems:

gem install screenshotapi

This command installs the screenshotapi gem, which can then be required in your Ruby code.

Once installed, you can proceed to use the SDK in your code by importing or requiring the library, as demonstrated in the quickstart examples.

Quickstart example

The following quickstart example demonstrates how to generate a basic screenshot using the Node.js SDK. This snippet illustrates initializing the client, specifying the target URL, and retrieving the screenshot. Developers can adapt this pattern for other languages by referring to the ScreenshotAPI.net documentation for language-specific syntax and available options.

Node.js Quickstart

First, ensure you have the screenshotapi-client installed:

npm install screenshotapi-client

Then, create a JavaScript file (e.g., capture.js) and add the following code:

const ScreenshotAPIClient = require('screenshotapi-client');

const client = new ScreenshotAPIClient('YOUR_API_KEY'); // Replace with your actual API key

async function captureScreenshot() {
  try {
    const screenshotUrl = await client.screenshot({
      url: 'https://www.example.com',
      full_page: true,
      width: 1920,
      height: 1080,
      output: 'json'
    });
    console.log('Screenshot URL:', screenshotUrl);
  } catch (error) {
    console.error('Error capturing screenshot:', error);
  }
}

captureScreenshot();

Replace 'YOUR_API_KEY' with your actual API key obtained from your ScreenshotAPI.net account. The output: 'json' parameter in this example specifies that the API should return a JSON object containing the URL of the generated image, rather than the image data directly. For more advanced options, such as setting delays, custom CSS, or specific viewport sizes, consult the ScreenshotAPI.net API reference.

Community libraries

While ScreenshotAPI.net provides official SDKs, the API's RESTful nature allows for the creation of community-contributed libraries in various programming languages. These libraries are typically developed and maintained independently by developers who find the official offerings do not meet specific project requirements or wish to support additional languages or frameworks. Community libraries can vary in their level of completeness, maintenance, and adherence to the latest API features.

Developers exploring community options should verify the library's active development, documentation, and community support before integrating it into production systems. Key considerations include checking the project's repository for recent commits, issue activity, and compatibility with the current ScreenshotAPI.net API version. Platforms like GitHub are common places to discover such projects, where developers often share their integrations and utility wrappers for public APIs.

For official support and guaranteed compatibility, it is generally recommended to use the ScreenshotAPI.net official SDKs. However, community libraries can offer valuable alternatives or specialized functionalities not found in the official releases, particularly for less common programming environments or niche use cases. Always review the source code and licensing of any third-party library before use.