SDKs overview
Screenshotlayer offers client libraries (SDKs) to facilitate interaction with its REST-based Website Screenshot API. These SDKs abstract the HTTP request and response handling, allowing developers to integrate screenshot capture functionality using familiar programming language constructs. The primary function of the Screenshotlayer API is to convert a given URL into an image file, with options for customizing output formats, dimensions, and other parameters relevant to web page rendering.
Developers can use these SDKs to programmatically request screenshots, specifying target URLs, desired image dimensions, full-page capture, delay before capture, and other parameters. The API then processes the request and returns the screenshot image, typically as a direct file download or a URL to the generated image. The provided SDKs aim to reduce the boilerplate code required for making direct HTTP requests, managing API keys, and parsing responses, thereby streamlining development workflows.
The SDKs are designed to support various programming environments, making the Screenshotlayer API accessible across different technology stacks. While the core functionality remains consistent, the implementation details and package names vary by language. Screenshotlayer recommends using official client libraries for stability and feature compatibility, though community-contributed libraries may also exist.
Official SDKs by language
Screenshotlayer provides official support for several popular programming languages, allowing developers to integrate the API into their applications with language-specific libraries. These official SDKs are maintained to ensure compatibility with the latest API features and provide a consistent developer experience. Each SDK handles the underlying API communication, including constructing requests, managing API keys, and processing responses.
Below is a summary of the officially supported SDKs and their associated package information:
| Language | Package/Module | Install Command Example | Maturity |
|---|---|---|---|
| PHP | screenshotlayer/screenshotlayer-php |
composer require screenshotlayer/screenshotlayer-php |
Stable |
| Python | screenshotlayer-python |
pip install screenshotlayer-python |
Stable |
| Ruby | screenshotlayer-ruby |
gem install screenshotlayer-ruby |
Stable |
| Node.js | screenshotlayer-node |
npm install screenshotlayer-node |
Stable |
| Go | github.com/screenshotlayer/screenshotlayer-go |
go get github.com/screenshotlayer/screenshotlayer-go |
Stable |
This table lists the primary official SDKs. For detailed documentation on each SDK, including advanced usage and configuration options, developers should refer to the Screenshotlayer API documentation.
Installation
Installing Screenshotlayer SDKs typically involves using the package manager specific to the programming language or environment. The installation process ensures that the necessary library files and dependencies are available for your project. Below are common installation commands for the officially supported languages:
- PHP: Using Composer, the PHP dependency manager.
composer require screenshotlayer/screenshotlayer-php - Python: Using pip, the Python package installer.
pip install screenshotlayer-python - Ruby: Using RubyGems, the standard package manager for Ruby.
gem install screenshotlayer-ruby - Node.js: Using npm, the Node.js package manager.
npm install screenshotlayer-node - Go: Using the
go getcommand to fetch and install the module.go get github.com/screenshotlayer/screenshotlayer-go
After installation, the SDK can be imported and initialized within your application code to start making API requests. Each SDK provides specific methods for configuration, such as setting the API access key, which is essential for authenticating requests to the Screenshotlayer API. For developers using HTTP clients directly, the HTTP/1.1 Semantics and Content specification defines the underlying protocol guidelines that the API adheres to, along with the OAuth 2.0 Authorization Framework for secure access where applicable, though Screenshotlayer primarily uses API keys for authentication.
Quickstart example
This quickstart guide provides a basic example of how to use the Node.js SDK to capture a screenshot. The example demonstrates authenticating with your API key and making a simple request to capture a website. Replace YOUR_API_KEY with your actual API access key obtained from your Screenshotlayer account dashboard.
Node.js Example:
const screenshotlayer = require('screenshotlayer-node');
const client = new screenshotlayer.Client({
apiKey: 'YOUR_API_KEY'
});
async function captureScreenshot() {
try {
const response = await client.capture({
url: 'https://example.com',
viewport: '1280x768',
full_page: 1,
format: 'png'
});
console.log('Screenshot URL:', response.url);
// You can download the screenshot from response.url
} catch (error) {
console.error('Error capturing screenshot:', error.message);
}
}
captureScreenshot();
This example initializes the Screenshotlayer client with an API key, then calls the capture method with parameters specifying the target URL, viewport dimensions, and requesting a full-page PNG screenshot. The API returns a URL where the generated screenshot can be accessed. Similar quickstart examples and detailed parameter explanations are available for other languages within the official Screenshotlayer documentation.
Community libraries
While Screenshotlayer maintains official SDKs for several programming languages, the broader developer community may contribute unofficial libraries or wrappers. These community-driven projects can offer alternative implementations, support for less common languages, or different approaches to integrating with the Screenshotlayer API.
Community libraries are typically found on platforms like GitHub, npm, PyPI, or RubyGems by searching for "screenshotlayer" along with the programming language. Developers considering community libraries should evaluate their active maintenance, documentation quality, and compatibility with the latest API version, as these projects may not receive the same level of support or updates as official SDKs.
It is important to note that community libraries are not officially endorsed or supported by Screenshotlayer. While they can be valuable, their reliability and security are dependent on their respective maintainers. For mission-critical applications, relying on the official SDKs or direct API integration is generally recommended to ensure ongoing support and access to new features.
Developers who create or maintain community libraries are encouraged to document their projects thoroughly, including installation instructions, usage examples, and any known limitations or differences from the official API behavior. This helps other developers make informed decisions about their integration choices. For a general understanding of how API clients are developed, independent resources like MDN Web Docs on the Fetch API provide insights into web-based API interaction principles, though SDKs abstract much of this detail.