Overview
IMG Processing API SDK is a set of tools that allow you to interact with the IMG Processing API from your application. The SDK provides three basic elements, theIMGProcessingClient
, the ImageObject
, and the APIError
classes.
Soon we will talk more about each of these elements, but first, let’s see how to install the SDK in your project.
Available SDKs
Currently, the SDK is available for the following languages:Installation
You can install the SDK using a package manager:node-sdk
Authentication
After installing the SDK, you need to authenticate your requests using your API key. Check out the Authentication section for more information about how to get an API key. After getting your API key, use it as an environment variable or application argument to prevent hardcoding it in your code, and keep it secure.Using the SDK
To start using the SDK, you need to import the client and create an instance of it.node-sdk
node-sdk
Handling errors
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass ofAPIError
will be thrown:
node-sdk
Status Code | Error Type |
---|---|
400 | BadRequestError |
401 | AuthenticationError |
403 | PermissionDeniedError |
404 | NotFoundError |
422 | UnprocessableEntityError |
429 | RateLimitError |
>=500 | InternalServerError |
N/A | APIConnectionError |
Retries
Certain errors will be automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. You can use themaxRetries
option to configure or disable this:
node-sdk
Timeouts
Requests time out after 1 minute by default. You can configure this with atimeout
option:
node-sdk
APIConnectionTimeoutError
is thrown.
Note that requests which time out will be retried twice by default.