Przejdź do treści

CLI

Shutterstock provides a command-line client to make it easier to use the API from the terminal of many different operating systems. The CLI includes methods for all endpoints in the API, so you can do anything with the CLI that you can do with the API by itself. The CLI has the same prerequisites and uses the same authentication as the API, so you can use the same application and authentication methods that you use with the API.

Using the SDK can be more readable than direct REST calls to the API because the SDK provides commands like search-images and license-videos to use instead of URLs to the API.

Installation

The CLI requires Python version 3 and the pip package manager.

To install the CLI, run pip install shutterstock-cli.

Authentication

As with the API, to use the CLI you must create an application at https://www.shutterstock.com/account/developers/apps and note the client ID and client secret. Then, you can use that client ID and client secret for basic authentication or to request a token for OAuth authentication.

Basic authentication

To use basic authentication with the CLI, put your application's client ID and client secret in the SHUTTERSTOCK_KEY and SHUTTERSTOCK_SECRET environment variables.

OAuth authentication

You cannot request an OAuth token directly through the CLI. Instead, you must get a token as described in OAuth authentication and put it in the SHUTTERSTOCK_API_TOKEN environment variable.

Using the CLI

After you have installed the CLI and authenticated to the API, you can use its commands to access the Shutterstock public API. For example, to search for images with OAuth authentication, pass your search parameters to the shutterstock images search-images command. The API returns the results in a JSON string that has the same information as the GET /v2/images/search endpoint API response.

export SHUTTERSTOCK_API_TOKEN=v2/ODYwYmRlNzBiYjMzNTE2M2UyZTQvMTc4NzI2OTM4L2N1c3RvbWVyLzIvWEtXR01HQ1FaVHRLOG85a

shutterstock images search-images --query sunrise

Each command is in a command group. For example, image commands are in the image group, so all image-related commands start with shutterstock images. To get a list of command groups, run the command shutterstock --help.

To get a list of the commands in a group, use --help. For example, the command shutterstock images --help lists the image commands and a short description of what each command does.

Similarly, you can get help for each command, including a list of parameters, by adding --help to the command, such as shutterstock images search-images --help. For detailed information about the parameters for each command, see the API reference.

Sending JSON data

For POST requests that require JSON data, put the data in a JSON file and refer to the file in the command. For example, this command puts licensing information in the file data.json and uses it to license an image:

echo '{
  "images": [
    {
      "image_id": "59656357",
      "subscription_id": "s12345678",
      "price": 12.50,
      "metadata": {
        "customer_id": "12345"
      }
    }
  ]
}' > data.json

shutterstock images license-images data.json

For more examples of the CLI, see the API reference.

W serwisie Shutterstock.com dostępnych jest ponad 475 000 000 materiałów (stan na 30 listopada 2023 roku).

© 2003-2024 Shutterstock, Inc.