This example code points to an older version of the Shutterstock API that is no longer publicly supported. For a newer example, please see https://github.com/shutterstock/php-shutterstock-api.
Sample PHP client implementation of Shutterstock API
NOTE: This is currently a work in progress and is designed as just one example on how to interact with the Shutterstock API using PHP.
PHP Client is a single file library which provides an easy way to interact with the Shutterstock Inc. API https://developers.shutterstock.com. You will need an API username and key from Shutterstock with the appropriate permissions in order to use this client.
Include "ShutterstockApiClient.php" in your PHP script and initialize class.
require_once('ShutterstockApiClient.php');
$sapi = new ShutterstockApiClient();
**Note:** Make sure to replace below values in the class with your credentials.
//customer credentials
private static $customer_username = 'XXXXXX';
private static $customer_password = 'XXXXX';
//basic auth info
private static $auth_username = 'XXXXX';
private static $auth_key = 'XXXXX';
Below are some examples of how to use this client to interact with Shutterstock Inc. API:
$categories = $sapi->getCategories();
$search_result = $sapi->search('dog', $filters);
There are many filters supported while searching for Shutterstock images catalog. You need to pass these filters in $filters array as key-value pair.
all | boolean | A flag indicating that all search results should be returned. Accepted values are 1 for true and 0 for false. |
category_id | int | An integer category id to search within. Required when searchterm, photographer_name, submitter_id, and color are not provided. |
color | html color | A color to search for. Required when searchterm, category_id, photographer_name, and submitter_id are not provided. Accepted values are 6-character HTML hex colors from '000000' to 'FFFFFF', with or without number sign. |
commercial_only | boolean | A flag indicating that only images which are available for commercial use should be returned; no images for editorial use only. Accepted values are 1 for true and 0 for false. |
enhanced_only | boolean | A flag indicating that only images with enhanced licenses available should be returned. Accepted values are 1 for true and 0 for false. |
exclude_keywords | str | A string of space-separated keywords to exclude from your search. |
language | language | The 2-letter language code that the query and desired results should be in. If not specified, use an eligible language from the Accept-Language header. Otherwise, defaults to "en". Accepted values are: 'en', 'zh', 'nl', 'fr', 'de', 'it', 'jp', 'pt', 'ru', 'es', 'cs', 'hu', 'tr', 'pl'. Default is 'en'. |
model_released | boolean | A flag indicating that only model-released photos should be returned. Accepted values are 1 for true and 0 for false. |
orientation | enum | Whether a photograph is wider than it is tall, or taller than it is wide. Accepted values are: 'all', 'horizontal', 'vertical'. Default is 'all'. |
page_number | nonnegative integer | Which page of results is wanted Accepted values are nonnegative integers. |
photographer_name | str | The username of a specific submitter whose work you want to search within. Required when searchterm, category_id, submitter_id, and color are not provided. |
safesearch | boolean | A flag indicating that only images suitable for all ages should be returned. Accepted values are 1 for true and 0 for false. Default is '1'. |
search_group | enum | A media type to search within. Accepted values are: 'photos', 'illustrations', 'vectors', 'all'. Default is 'all'. |
searchterm | str | A string of space-separated keywords to search for. Required when category_id, photographer_name, submitter_id, and color are not provided. Example: 'cat'. |
sort_method | enum | How the results should be sorted. Accepted values are: 'newest', 'oldest', 'popular', 'random', 'relevance'. Default is 'popular'. |
submitter_id | int | The integer id of a specific submitter whose work you want to search within. Required when searchterm, category_id, photographer_name, and color are not provided. |
$customer_info = $sapi->getCustomerUserInfo();
$lightboxes = $sapi->getLightboxes();
$add_lightbox = $sapi->addLightbox(lightbox_name);
$add_lightbox_image = $sapi->addImageToLightbox(lightbox_id, image_id);
$remove_lightbox_image = $sapi->deleteImageFromLightbox(lightbox_id, image_id);
$lightbox_details = $sapi->getLightbox(lightbox_id);
$delete_lightbox = $sapi->deleteLightbox(lightbox_id);
$subscription = $sapi->getSubscriptions();
$downloads = $sapi->getDownloads();
$download = $sapi->downloadImage(image_id, subscription_id, size, format, meta_data);
Please do! Check out our Contributing guide.
MIT © 2017 Shutterstock Images, Inc.