Methods
ApiExceptionHandle(respJson, throwError) → {Object.<string, *>}
Inspect a decoded API response and optionally raise on an error payload.
Parameters:
| Name | Type | Description |
|---|---|---|
respJson |
Object.<string, *> | The decoded JSON response body. |
throwError |
boolean | If `true` and the response contains an `error` object, an APIError is thrown instead of returning the response. |
Throws:
-
If `throwError` is `true` and the response contains an error.
- Type
- APIError
Returns:
The original response object (when not throwing).
- Type
- Object.<string, *>
GetEndpoint(uri) → {string}
Resolve a request URI into a fully-qualified URL. Absolute URLs are returned
unchanged. Otherwise the URI is resolved against the override endpoint set by
SetEndpoint, or, if none is set, against the base URL for the region
given by the `IDANALYZER_REGION` environment variable (defaults to "us").
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | An absolute URL, or a path relative to the API base URL. |
Throws:
-
If `IDANALYZER_REGION` is set to an unsupported region.
Returns:
The fully-qualified request URL.
- Type
- string
ParseInput(str, allowCacheopt) → {string}
Normalize an image/file input into the value expected by the API. The input
may be a cache reference ("ref:..."), a URL, a local file path (which is read
and base64-encoded), or an already-base64-encoded/long string.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
str |
string | Input value: a "ref:" cache reference, a URL, a local file path, or a base64-encoded image string. | ||
allowCache |
boolean |
<optional> |
false | If `true`, a value starting with "ref:" is returned unchanged as a cache reference. |
Throws:
-
If the input is neither a valid URL, an existing file, nor a sufficiently long string to be treated as inline data.
Returns:
The URL, cache reference, or base64-encoded file contents.
- Type
- string
SetEndpoint(endpointopt) → {void}
Override the API base endpoint for all subsequent requests, bypassing the
region-based default. Pass an empty string to clear the override and revert
to region-based resolution.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
endpoint |
string |
<optional> |
'' | Fully-qualified base URL to use as the API endpoint. |
Throws:
-
If `endpoint` is not a valid URL.
- Type
- TypeError
Returns:
- Type
- void
Type Definitions
ApiResponse
A decoded JSON object returned by the ID Analyzer API. The exact shape
depends on the endpoint; see the API reference at
https://developer.idanalyzer.com for per-endpoint response schemas.
Type:
- Object.<string, *>
- Source: