SDKs overview
Software Development Kits (SDKs) and client libraries for Shutterstock enable developers to integrate the platform's extensive media library and content management features into their applications. These tools provide a structured and often language-specific approach to interact with the Shutterstock API, abstracting direct HTTP requests and JSON parsing. By using an SDK, developers can access functionalities such as searching for images and videos, managing collections, and licensing content through programmatic interfaces.
Shutterstock offers official SDKs for several popular programming languages, designed to ensure compatibility and simplify the authentication process, which primarily uses OAuth 2.0. These official SDKs are maintained by Shutterstock and align with the latest API versions and best practices. In addition to official offerings, the developer community might also contribute third-party libraries, though their maintenance and feature parity can vary.
The primary benefit of using an SDK is reduced development time and effort. Instead of writing custom code to handle API requests, responses, and error handling, developers can utilize pre-built functions and objects provided by the SDK. This standardization also helps in maintaining consistency across different integrations and can simplify updates when the API evolves.
Official SDKs by language
Shutterstock provides official SDKs for several programming languages, each designed to offer a native experience for developers working within those environments. These SDKs typically encapsulate the full range of API functionalities, from searching and filtering media to managing user collections and handling licensing workflows. The official SDKs are regularly updated to reflect changes in the Shutterstock API and ensure compatibility and optimal performance.
The table below outlines the key official SDKs available, including their respective package names for installation and their general maturity status. Developers are encouraged to refer to the Shutterstock developer documentation for the most current versions and detailed usage instructions.
| Language | Package Name | Install Command Example | Maturity |
|---|---|---|---|
| Python | shutterstock-api |
pip install shutterstock-api |
Stable |
| Node.js | shutterstock-api |
npm install shutterstock-api |
Stable |
| PHP | shutterstock/api-reference |
composer require shutterstock/php-api-client |
Stable |
| Java | com.shutterstock.api |
Add to pom.xml for Maven or build.gradle for Gradle |
Stable |
| Ruby | shutterstock-api |
gem install shutterstock-api |
Stable |
Installation
Installation of Shutterstock SDKs typically follows the standard package management practices for each respective programming language. Each SDK is designed to be easily integrated into existing projects, allowing developers to quickly begin interacting with the Shutterstock API. The process generally involves using a command-line tool to add the SDK package to a project's dependencies.
Python
For Python projects, the SDK can be installed using pip, the Python package installer. This command adds the shutterstock-api package to your environment, making its modules available for import.
pip install shutterstock-api
Node.js
Node.js developers can install the SDK using npm (Node Package Manager) or yarn. This command adds the shutterstock-api package to your node_modules directory and updates your package.json file.
npm install shutterstock-api
yarn add shutterstock-api
PHP
PHP projects typically use Composer for dependency management. The Shutterstock PHP client can be added to your project with the following command, which will install the package and generate an autoloader.
composer require shutterstock/php-api-client
Java
For Java projects, the SDK artifacts are usually available through Maven Central. Developers using Maven need to add a dependency entry to their pom.xml file. For Gradle users, a similar entry is added to build.gradle.
<dependency>
<groupId>com.shutterstock.api</groupId>
<artifactId>shutterstock-api-client</artifactId>
<version>X.Y.Z</version> <!-- Replace with the latest version -->
</dependency>
implementation 'com.shutterstock.api:shutterstock-api-client:X.Y.Z' // Replace with the latest version
Ruby
Ruby projects manage dependencies using Bundler and RubyGems. The Shutterstock SDK can be installed by adding it to your Gemfile and then running bundle install.
# Gemfile
gem 'shutterstock-api'
bundle install
Quickstart example
This quickstart example demonstrates how to use the Shutterstock Python SDK to perform a basic image search. Before running this code, ensure you have installed the Python SDK and configured your API authentication credentials. Shutterstock's API uses OAuth 2.0 for authentication, requiring an access token to make authenticated requests.
import shutterstock_api
from shutterstock_api.rest import ApiException
# Configure OAuth2 access token for authorization
configuration = shutterstock_api.Configuration()
configuration.access_token = 'YOUR_ACCESS_TOKEN' # Replace with your actual access token
# Create an instance of the API class
api_client = shutterstock_api.ApiClient(configuration)
images_api = shutterstock_api.ImagesApi(api_client)
# Define search parameters
query = "nature landscape"
search_parameters = {
'query': query,
'image_type': ['photo'],
'orientation': 'horizontal',
'page': 1,
'per_page': 5
}
try:
# Perform the image search
api_response = images_api.search_images(**search_parameters)
print(f"Found {api_response.total_count} images for '{query}':")
for i, image in enumerate(api_response.data):
print(f" {i+1}. ID: {image.id}, Description: {image.description}, Preview URL: {image.assets.preview.url}")
except ApiException as e:
print(f"Exception when calling search_images: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
This Python snippet initializes the Shutterstock API client with an OAuth 2.0 access token. It then calls the search_images method with specified parameters like a query string, image type, and pagination settings. The results, including image IDs, descriptions, and preview URLs, are then printed to the console. Developers should replace 'YOUR_ACCESS_TOKEN' with a valid access token obtained through the Shutterstock authentication process.
Community libraries
While Shutterstock provides official SDKs, the broader developer community may also contribute open-source client libraries or tools that interact with the Shutterstock API. These community-driven projects can sometimes offer alternative implementations, support for less common languages, or specific functionalities not covered by official SDKs.
The existence and maintenance level of community libraries can vary significantly. Developers considering a community library should:
- Check the project's activity: Look for recent commits, issue resolution, and active contributors.
- Examine documentation: Ensure the library has clear and comprehensive documentation.
- Review the license: Understand the terms under which the library is distributed.
- Verify API compatibility: Confirm that the library is compatible with the current version of the Shutterstock API.
For the most reliable and up-to-date integration, Shutterstock generally recommends using their official SDKs and documentation. However, community libraries can sometimes offer specialized features or convenience for niche use cases. Developers can often find such projects on platforms like GitHub by searching for "shutterstock api client" or "shutterstock sdk" in their preferred programming language.