The Shutterstock API Explorer SDK for Python provides access to the Shutterstock API Explorer REST APIs from Python applications.
Tip
Looking for a specific signature, model, enum, or error type? This SDK ships a generated SDK map -- a lookup index of the SDK's entire Python surface. Consult it before scanning the source tree; details under SDK map.
The Shutterstock API provides access to Shutterstock's library of media, as well as information about customers' accounts and the contributors that provide the media.
Install the Python SDK from PyPI, with whichever package manager your project uses:
pip install shutterstock-api-exploreruv add shutterstock-api-explorerpoetry add shutterstock-api-explorerConstruct ShutterstockApiExplorerClient with keyword arguments, and call close() when you are done. Every argument is optional; the full list is in the SDK map.
from shutterstock_api_explorer import ShutterstockApiExplorerClient
from shutterstock_api_explorer.auth import CustomerAccessCodeScope
from shutterstock_api_explorer.core import AuthorizationCodeCredentials, BasicAuthCredentials
def prompt(url: str) -> str:
return input(f"Open {url}, then paste the code: ")
client = ShutterstockApiExplorerClient(
basic=BasicAuthCredentials(username="YOUR_USERNAME", password="YOUR_PASSWORD"),
customer_access_code=AuthorizationCodeCredentials[CustomerAccessCodeScope](
client_id="YOUR_CLIENT_ID", redirect_uri="YOUR_REDIRECT_URI", prompt_for_authorization_code=prompt
),
environment="production",
)
# TODO: call endpoints here -- see api-reference.md
client.close()Alternatively, scope it -- with ShutterstockApiExplorerClient(...) as client: closes the pool on exit; see Best Practices.
Client is exported as an alias of ShutterstockApiExplorerClient, so from shutterstock_api_explorer import Client also works.
The SDK accepts every model-typed input in two interchangeable spellings, both type-checked: the typed model, or a plain dict with the same keys -- the OrDict and Model | ModelDict unions in the SDK map. Pick whichever suits the call site: the dict form needs no import, while the model form adds a keyword-checked constructor and editor completion.
AsyncShutterstockApiExplorerClient mirrors ShutterstockApiExplorerClient with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences -- for example, the transport argument is custom_async_http_client.
from asyncio import run, to_thread
from shutterstock_api_explorer import AsyncShutterstockApiExplorerClient
from shutterstock_api_explorer.auth import CustomerAccessCodeScope
from shutterstock_api_explorer.core import AsyncAuthorizationCodeCredentials, BasicAuthCredentials
async def prompt(url: str) -> str:
print(f"Open {url}")
return await to_thread(input, "Paste the code: ")
async def main() -> None:
client = AsyncShutterstockApiExplorerClient(
basic=BasicAuthCredentials(username="YOUR_USERNAME", password="YOUR_PASSWORD"),
customer_access_code=AsyncAuthorizationCodeCredentials[CustomerAccessCodeScope](
client_id="YOUR_CLIENT_ID", redirect_uri="YOUR_REDIRECT_URI", prompt_for_authorization_code=prompt
),
environment="production",
)
# TODO: call endpoints here, awaiting each -- see api-reference.md
await client.aclose()
run(main())Alternatively, scope it -- async with AsyncShutterstockApiExplorerClient(...) as client: closes the pool on exit. Only the async spelling is aclose, matching httpx; see Best Practices.
AsyncClient is the exported alias. Each client accepts only its own transport argument and its own prompt flavour; passing the other's is a TypeError at runtime and an error under mypy.
Two generated references cover the SDK; each answers a different question:
| Reference | For |
|---|---|
| API Reference | Usage guidance for a single parsed operation: client.<group>.<operation>(...) returns the typed payload and raises ApiError on any non-2xx, with .error the typed error body, or RawError for a status the operation does not document. |
| Raw API Reference | The same for the raw variant: client.<group>.with_raw_response.<operation>(...) returns ApiResult[T, E] and never raises for an API error. |
Both API references carry every one of the 109 operations, with a sync and an async sample and a parameter table each.
This SDK ships a generated SDK map -- sdk-map.md -- a deterministic, lookup-oriented table of contents of the SDK's Python surface, generated by APIMatic alongside this SDK.
Consult the map before scanning or grepping the source: it answers call-level contract questions by lookup, and for anything it does not carry -- model shapes, enum values, an endpoint's route or behavioural prose -- it names the one source file to read. How to read the map itself, including the SDK-wide defaults its rows rely on, is stated at the top of sdk-map.md.
Tip
Use a single ShutterstockApiExplorerClient instance for the lifetime of your application and reuse it across
all requests. Each instance owns its own connection pool, so an instance per request forfeits
connection reuse and leaks pools that are never closed.
Match the disposal to the client's lifetime: an application-lifetime client is closed once at shutdown with close() / aclose(); where the lifetime fits a block, with ShutterstockApiExplorerClient() as client: / async with AsyncShutterstockApiExplorerClient() as client: releases it automatically. Both are idempotent, but a closed client is not reusable: the next call raises. The client closes whatever transport it holds, including one you supplied via custom_http_client / custom_async_http_client; if you intend to reuse your own transport across clients, don't hand its lifetime to a with block.
This SDK is distributed under the MIT License.
Refer to the API reference for detailed information on available operations with code samples.