This library provides convenient access to the Gumlet REST API from TypeScript or JavaScript.
The REST API documentation can be found on docs.gumlet.com. The full API of this library can be found in api.md.
- Installation
- Usage
- API Reference
- Authentication
- Errors
- Client Options
- Request Options
- Retries and Timeouts
- Webhooks
- Helpers
- Logging
- Requirements
npm install @gumlet/nodejs-sdkimport Gumlet from '@gumlet/nodejs-sdk';
const client = new Gumlet({
apiKey: process.env['API_KEY'], // defaults to the API_KEY env var
});
const videoAsset = await client.videoAssets.create({
format: 'ABR',
workspace_id: '<your workspace id>',
title: 'Example Title',
input: 'http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8',
});
console.log(videoAsset);The examples in the following sections assume a client configured as shown above.
See the API reference for every available operation.
Pass credentials to the generated client constructor. Environment variables are read automatically when supported by the target runtime.
| Option | Type | Default | Description |
|---|---|---|---|
apiKey |
string | AuthTokenProvider |
- | Credential for the API_KEY scheme. Defaults to API_KEY. |
Declared schemes:
API_KEYbearer token
Non-success responses throw generated API errors. Error objects expose status, headers, response body, and request metadata where the target runtime supports it.
import { APIError } from '@gumlet/nodejs-sdk';
try {
const videoAsset = await client.videoAssets.create({
format: 'ABR',
workspace_id: '<your workspace id>',
title: 'Example Title',
input: 'http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8',
});
} catch (err) {
if (err instanceof APIError) {
console.log(err.status, err.name, err.headers);
}
throw err;
}Documented error statuses: 400, 401, 402, 403, 404, 413, 422, 500.
Configure the generated client by setting any of these options when you create it.
import Gumlet from '@gumlet/nodejs-sdk';
const client = new Gumlet({
timeout: 60000,
maxRetries: 2,
logLevel: 'debug',
});| Option | Type | Default | Description |
|---|---|---|---|
apiKey |
string | AuthTokenProvider |
process.env["API_KEY"] |
Credential for the API_KEY scheme. |
baseURL |
string | null |
process.env["GUMLET_BASE_URL"] |
Override the default API base URL. Pass null when selecting a configured environment. |
timeout |
number |
60000 |
Maximum time in milliseconds to wait for a response before aborting a request. |
maxRetries |
number |
2 |
Number of retries for temporary failures. |
defaultHeaders |
HeadersInit |
- | Headers sent with every request. |
defaultQuery |
Record<string, string | undefined> |
- | Query parameters sent with every request. |
fetchOptions |
RequestInit |
- | Additional fetch options sent with every request. |
fetch |
Fetch |
- | Custom fetch implementation. A file upload to a pre-signed URL uses it only when wrapped in signedUploadTransport(fetch), which declares that it adds no credentials or headers of its own except for the API's own origin. |
logLevel |
"off" | "error" | "warn" | "info" | "debug" |
process.env["GUMLET_LOG"] ?? "warn" |
Controls request and retry debug logging. "off" turns logging off. |
logger |
Logger |
console |
Custom logger implementation. |
| Option | Type | Default | Description |
|---|---|---|---|
headers |
HeadersInit |
- | Per-request headers. |
query |
Record<string, unknown> |
- | Per-request query parameters. |
body |
unknown |
- | Override the generated request body. |
timeout |
number |
- | Per-request timeout in milliseconds. |
maxRetries |
number |
- | Per-request retry count. |
signal |
AbortSignal |
- | Abort an in-flight request. |
fetchOptions |
RequestInit |
- | Per-request fetch options. |
idempotencyKey |
string |
- | Idempotency key for retry-safe operations. Applies to this request and its retries. |
Generated clients support request timeouts and retry temporary failures such as network errors, 408, 409, 429, and 5xx responses. Retry delays honor Retry-After headers when present. Tune the retry and timeout client options shown above, or override them per request.
The webhook helper verifies the signature of each delivery your server receives, then decodes its body into a typed event. Pass it the request body exactly as it arrived, before any JSON parsing, together with the request headers: the signature covers the raw body, so one that was parsed and re-serialized fails verification. A delivery whose signature does not verify is rejected before it is decoded.
// `body` is the raw request body as a string; `headers` holds the request headers.
const event = client.webhooks.unwrap(body, { headers });The signing secret comes from the client's webhookSecret option, which defaults to the GUMLET_WEBHOOK_SECRET environment variable. Pass key to use a different secret for one call.
A delivery that fails verification throws WebhookVerificationError, exported from the package root. Check for it with isWebhookVerificationError(error), exported beside it:
import { isWebhookVerificationError } from '@gumlet/nodejs-sdk';
try {
const event = client.webhooks.unwrap(body, { headers });
} catch (error) {
if (!isWebhookVerificationError(error)) throw error;
// Not a genuine delivery: reject it, for example with a 400 response.
}The guard matches the SDK's class and its subclasses, and the standardwebhooks class of the same name from any copy of that library, in every runtime. A handler that still imports that class from standardwebhooks keeps matching the SDK's refusals with instanceof on Node and Bun when the application loads standardwebhooks from its own node_modules, and in a Jest test that loads it with Jest's default CommonJS modules. It does not match where the library is bundled into the application, or in a browser, an edge runtime, or an ES module application on a Node release without process.getBuiltinModule (before 20.16, any 21, or 22 before 22.3). Use the guard there, and in Jest tests that run as ES modules.
The same resource also has:
client.webhooks.verifySignature(body, headers)checks a delivery's signature, and fails when it does not verify.client.webhooks.parseUnsafe(body)decodes a body into a typed event without checking its signature. Use it only for a body verified elsewhere, or in tests.
- Use
.withResponse()on a request to inspect both parsed data and the rawResponseobject. - Every operation returns an
APIPromise, so you canawaitit directly or chain.withResponse()— except a method that uploads a file to a pre-signed URL (a signed upload), which resolves to a plainPromiseof its result.
- Set
logLevel: "debug"to log request URLs, options, response status, response headers, and retry attempts. - Pass a custom
loggerto route logs into your own observability pipeline. - Set
logLevel: "off"to turn logging off, whateverGUMLET_LOGsays. WithoutlogLevel, the client reads that environment variable, then defaults to"warn".
- Node.js 20+, a modern browser, or any runtime with
fetchsupport