SDKs overview

Software Development Kits (SDKs) for Getty Images provide a structured approach to integrating the Getty Images API into various applications. These kits typically include client libraries, documentation, and code samples, simplifying common tasks such as authenticating requests, searching for content, and retrieving asset details. By using an SDK, developers can interact with the API using native language constructs rather than directly managing HTTP requests, response parsing, and error handling Getty Images SDK documentation. This abstraction aims to reduce development time and potential implementation errors.

Getty Images offers official SDKs for several popular programming languages, ensuring direct support and compatibility with API updates. These official libraries are maintained by Getty Images, providing a reliable and recommended method for integration. Beyond the official offerings, the developer community sometimes contributes open-source libraries, which can offer alternative implementations or support for additional languages and frameworks. While community libraries can be valuable, their maintenance and compatibility may vary compared to official SDKs.

The primary use cases for Getty Images SDKs revolve around programmatic access to their extensive collection of visual content. Developers can build applications that allow users to search for images and videos, preview assets, and manage licensing workflows directly through the API. This enables custom content management systems, editorial tools, and digital asset management solutions to leverage Getty Images's library within their own platforms.

Official SDKs by language

Getty Images provides official SDKs for several programming languages, designed to streamline interaction with the API. These SDKs handle authentication, request formatting, and response parsing, enabling developers to focus on application logic rather than low-level API communication. The official SDKs are maintained to reflect the latest API versions and best practices.

Language Package Name Installation Command Maturity
Python gettyimages-api pip install gettyimages-api Stable
Node.js gettyimages-api npm install gettyimages-api Stable
PHP gettyimages/gettyimages-api composer require gettyimages/gettyimages-api Stable
.NET GettyImages.Api Install-Package GettyImages.Api Stable

Each SDK is typically available through its respective language's package manager, facilitating easy inclusion in development projects. Developers should consult the Getty Images SDK documentation for detailed setup instructions and specific version requirements.

Installation

Installing a Getty Images SDK typically involves using the standard package manager for your chosen programming language. This process fetches the library and its dependencies, making it available for use in your project. The following provides a general guide for each official SDK.

Python SDK

The Python SDK is distributed via PyPI, the Python Package Index. Installation is performed using pip, the Python package installer.

pip install gettyimages-api

After installation, you can import the library into your Python scripts.

Node.js SDK

The Node.js SDK is available on npm, the Node.js package manager. Use npm to add it to your project.

npm install gettyimages-api

This command adds the package to your node_modules directory and updates your package.json file.

PHP SDK

The PHP SDK is managed with Composer, the dependency manager for PHP. Include it in your project by adding a dependency to your composer.json file or running the command:

composer require gettyimages/gettyimages-api

Composer will download the library and generate an autoloader file.

.NET SDK

The .NET SDK is distributed as a NuGet package. You can install it using the NuGet Package Manager Console in Visual Studio or via the .NET CLI.

Install-Package GettyImages.Api

Or, using the .NET CLI:

dotnet add package GettyImages.Api

Successful installation makes the SDK classes and methods available for use in your .NET projects.

Quickstart example

This quickstart example demonstrates how to use the Getty Images Node.js SDK to perform a basic image search. Before running this code, ensure you have installed the Node.js SDK and obtained your API key and secret from the Getty Images Developer Portal.

First, create a file named search.js and add the following code:

const GettyImagesApi = require('gettyimages-api');

// Replace with your actual API Key and Secret
const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';

async function searchImages() {
  try {
    const api = new GettyImagesApi({
      apiKey: apiKey,
      apiSecret: apiSecret
    });

    const response = await api.search().images().withPhrase('cats').execute();

    console.log('Search Results:');
    if (response.images && response.images.length > 0) {
      response.images.forEach(image => {
        console.log(`  Title: ${image.title || 'N/A'}`);
        console.log(`  ID: ${image.id}`);
        console.log(`  Thumbnail URL: ${image.display_sizes[0].uri}`);
        console.log('---');
      });
    } else {
      console.log('No images found.');
    }

  } catch (error) {
    console.error('Error searching images:', error.message);
    if (error.response && error.response.data) {
      console.error('API Error Details:', error.response.data);
    }
  }
}

searchImages();

To execute the script, open your terminal in the directory where you saved search.js and run:

node search.js

This script initializes the Getty Images API client with your credentials, performs a search for images with the phrase 'cats', and then logs the title, ID, and a thumbnail URL for each returned image. Error handling is included to catch potential issues during the API call, such as invalid credentials or network problems. For more advanced search parameters and API capabilities, refer to the Getty Images API reference documentation.

Community libraries

While Getty Images maintains official SDKs for key languages, the broader developer community may create and share additional libraries or wrappers for languages not officially supported, or offer alternative implementations for existing ones. These community-contributed libraries can provide flexibility, support for specific frameworks, or cater to niche use cases.

However, community libraries often come with varying levels of support and maintenance compared to official SDKs. Developers considering using a community library should evaluate its active development, documentation quality, and community engagement. Resources like GitHub and other open-source repositories are common places to find such contributions. For instance, developers often turn to platforms like GitHub to search for open-source SDK projects and client libraries across various APIs.

When selecting a community library, it is advisable to:

  • Check the last commit date: Indicates how recently the project was updated.
  • Review issue trackers: Shows if bugs are being actively addressed.
  • Examine pull request activity: Reveals community contributions and project responsiveness.
  • Read the license: Understand usage rights and obligations (e.g., MIT, Apache 2.0).
  • Verify compatibility: Ensure the library works with the current version of the Getty Images API.

Always prioritize security when using third-party code, especially when handling API keys and sensitive data. Official documentation should always be the primary reference for API behavior, even when using community-developed tools.