Skip to main content

A command-line utility that allows you to interact with the Shutterstock public API.

Project description

shutterstock-cli

License: MIT Code style: black

A command-line utility that allows you to interact with the Shutterstock public API. For more information about the CLI and the API, see the Shutterstock API reference.

Installation

The Shutterstock CLI is available on the Python Package Index (PyPI). You can install it using pip.

pip install shutterstock-cli

Authentication

Basic authentication

All endpoints in the Shutterstock API require authentication. The API accepts HTTP basic authentication for some endpoints and OAuth authentication for all endpoints.

The API accepts HTTP basic authentication (also known as basic authentication) for some endpoints that do not access specific customer information. Follow these steps to use basic authentication:

  1. Create an account at https://www.shutterstock.com if you don't already have one.
  2. Set up an application at https://www.shutterstock.com/account/developers/apps and get the consumer key and consumer secret from the application.
  3. Export the consumer key and consumer secret as environment variables:
export SHUTTERSTOCK_KEY='YOUR_KEY'
export SHUTTERSTOCK_SECRET='YOUR_SECRET'

OAuth authentication

Most endpoints require OAuth 2.0 authentication. In this type of authentication, you use an application and an individual user's login credentials to obtain a token. Then you can use that token as credentials for API requests in place of a user name and password.

Some endpoints require one or more scopes, or permissions, which let the user control what the application can do with the token. For example, to edit a user's collections, the token must include the collections.edit scope. Applications can request multiple tokens with different scopes or a single token with multiple scopes.

Getting tokens from your account page

As a shortcut, you can get a token directly from an application on your account page:

  1. Create an account at https://www.shutterstock.com if you don't already have one.
  2. Set up an application at https://www.shutterstock.com/account/developers/apps.
  3. On the application details page, under Token, click Generate token.
  4. On the Select scopes page, select the scopes for the token. The token automatically has scopes that allow it to run basic tasks. You can add scopes that allow it to access your licenses and collections.
  5. Click Continue.
  6. In the popup window, sign in to your shutterstock.com account.

The popup window shows the token. Copy it immediately, because it is shown only once. The token is valid until the user account that you logged in with changes its password or email address.

Keep this token private, because other people could use it to access the account's subscriptions and media.

To use this token to authenticate your CLI commands, set it as the value of the SHUTTERSTOCK_API_TOKEN environment variable:

export SHUTTERSTOCK_API_TOKEN='YOUR_BEARER_TOKEN'

Usage

Run shutterstock --help to see the available commands. You can also run shutterstock groupName --help or shutterstock groupName commandName --help to get help on a group of commands or on an individual command.

Usage: shutterstock [OPTIONS] COMMAND [ARGS]

Options:
  --help  Show this message and exit.

Commands are organized into these groups. To get a list of commands in a group, run shutterstock groupName --help.

Groups:
  ai
  audio
  contributors
  cv
  editorial
  images
  test
  user
  videos

Formatting JSON Output

If you would like to colorize the JSON response output you can set the SHUTTERSTOCK_CLI_COLORIZE_OUTPUT environment variable:

export SHUTTERSTOCK_CLI_COLORIZE_OUTPUT='true'

Sandbox

To make requests to the licensing sandbox API instead of the main API, set the SHUTTERSTOCK_SANDBOX environment variable to true.

For more information about the sandbox, see https://api-reference.shutterstock.com/#licensing-and-downloading-licensing-sandbox.

export SHUTTERSTOCK_SANDBOX='true'

Examples

Search for images of boats with an aspect ratio of 1.6.

shutterstock images search-images --query boats --aspect-ratio 1.6

Get information about an image, including a URL to a preview image and the sizes that it is available in.

shutterstock images get-image 1269188995

Get a list of existing image licenses for a specified time period.

shutterstock images get-image-license-list --start-date 2020-03-03T12:00:00Z --end-date 2020-03-04T12:00:00Z

Get images that are visually similar to an image that you specify.

shutterstock images get-similar-images 1269188995 --language en --per-page 200 --view minimal

License an image.

shutterstock images license-images path/to/payload.json --subscription-id s123abc

Get your image license history over a specified time period.

shutterstock images get-image-license-list --start-date 2021-01-01T12:00:00Z --end-date 2021-03-01T12:00:00Z

Get the public URL of the image that you have already received a license for.

shutterstock images download-image license-id-123 payload.json

For more examples, see the Shutterstock API reference.

Development

Creating virtual environment

python3 -m venv [NAME_FOR_YOUR_VIRTUAL_ENV]

Activating virtual environment

source [NAME_FOR_YOUR_VIRTUAL_ENV]/bin/activate

Install app in virtual environment

python setup.py install

Install the requirements

pip3 install -r requirements.txt

Utilize installed app

shutterstock --help

Deactivating virtual environment

You can deactivate the virtual environment by simply running the command below.

deactivate

Running Tests

coverage run --omit 'env/*' -m unittest tests/*.py && coverage report -m

Contributing

  • Fork the project and clone locally.
  • Create a new branch for what you're going to work on.
  • Push to your origin repository.
  • Create a new pull request in GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shutterstock-cli-1.1.7.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

shutterstock_cli-1.1.7-py2.py3-none-any.whl (21.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file shutterstock-cli-1.1.7.tar.gz.

File metadata

  • Download URL: shutterstock-cli-1.1.7.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.2

File hashes

Hashes for shutterstock-cli-1.1.7.tar.gz
Algorithm Hash digest
SHA256 c67c36346745c74158465f652095c335d9688dcdb0d572c10db91a6c44f0e0d0
MD5 882d161b388efb0164daa90ea498adf3
BLAKE2b-256 ad5298416bde374096450c60dec37fef86f634e44f6d9ff3e0a14a3a8718edac

See more details on using hashes here.

File details

Details for the file shutterstock_cli-1.1.7-py2.py3-none-any.whl.

File metadata

  • Download URL: shutterstock_cli-1.1.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.2

File hashes

Hashes for shutterstock_cli-1.1.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7130863c3dedb91bf8b389f8918f896b9de609752cdd027cd1c12494ce9d8cac
MD5 d30bf98c75f98a154547beb7cdb6134a
BLAKE2b-256 8182d86083986670ae79914b2d83d1554d7b473e436b24ed9d5501c2b817a598

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page