@convertrilo/sdk 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/src/index.d.ts +5 -2
- package/dist/src/index.js +8 -2
- package/dist/src/types.d.ts +14 -3
- package/docs/API-INTEGRATION-GUIDE.md +7 -0
- package/openapi.yaml +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,6 +54,8 @@ const job = await client.onDemandEncode({
|
|
|
54
54
|
codec: "h264",
|
|
55
55
|
resolution: "1080p",
|
|
56
56
|
quality: "better",
|
|
57
|
+
}, {
|
|
58
|
+
idempotencyKey: "encode-customer-video-123",
|
|
57
59
|
});
|
|
58
60
|
|
|
59
61
|
let finalStatus;
|
|
@@ -144,6 +146,8 @@ const batch = await client.onDemandIngestFolder({
|
|
|
144
146
|
},
|
|
145
147
|
codec: "h264",
|
|
146
148
|
resolution: "1080p",
|
|
149
|
+
}, {
|
|
150
|
+
idempotencyKey: "folder-batch-2026-06-09",
|
|
147
151
|
});
|
|
148
152
|
|
|
149
153
|
for (const job of batch.jobs || []) {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export type ClientConfig = {
|
|
|
15
15
|
apiKey?: string;
|
|
16
16
|
fetchImpl?: typeof fetch;
|
|
17
17
|
};
|
|
18
|
+
export type RequestOptions = {
|
|
19
|
+
idempotencyKey?: string;
|
|
20
|
+
};
|
|
18
21
|
export declare class ConvertriloClient {
|
|
19
22
|
private baseUrl;
|
|
20
23
|
private getToken?;
|
|
@@ -143,7 +146,7 @@ export declare class ConvertriloClient {
|
|
|
143
146
|
};
|
|
144
147
|
} ? B : any): Promise<unknown>;
|
|
145
148
|
abortStream(id: string): Promise<unknown>;
|
|
146
|
-
onDemandEncode(body: paths["/ondemand/encode"]["post"]["requestBody"]["content"]["application/json"]): Promise<{
|
|
149
|
+
onDemandEncode(body: paths["/ondemand/encode"]["post"]["requestBody"]["content"]["application/json"], options?: RequestOptions): Promise<{
|
|
147
150
|
jobId: string;
|
|
148
151
|
externalId?: string | null;
|
|
149
152
|
metadata?: {
|
|
@@ -161,7 +164,7 @@ export declare class ConvertriloClient {
|
|
|
161
164
|
statusUrl: string;
|
|
162
165
|
webhook?: string | null;
|
|
163
166
|
}>;
|
|
164
|
-
onDemandIngestFolder(body: paths["/ondemand/ingest/folder"]["post"]["requestBody"]["content"]["application/json"]): Promise<{
|
|
167
|
+
onDemandIngestFolder(body: paths["/ondemand/ingest/folder"]["post"]["requestBody"]["content"]["application/json"], options?: RequestOptions): Promise<{
|
|
165
168
|
message?: string;
|
|
166
169
|
jobs?: {
|
|
167
170
|
jobId?: string;
|
package/dist/src/index.js
CHANGED
|
@@ -170,16 +170,22 @@ export class ConvertriloClient {
|
|
|
170
170
|
return this.request(`/jobs/${id}/stream/abort`, { method: "POST" });
|
|
171
171
|
}
|
|
172
172
|
// On-Demand Encoding
|
|
173
|
-
async onDemandEncode(body) {
|
|
173
|
+
async onDemandEncode(body, options = {}) {
|
|
174
174
|
return this.request(`/ondemand/encode`, {
|
|
175
175
|
method: "POST",
|
|
176
176
|
body: JSON.stringify(body),
|
|
177
|
+
headers: options.idempotencyKey
|
|
178
|
+
? { "Idempotency-Key": options.idempotencyKey }
|
|
179
|
+
: undefined,
|
|
177
180
|
});
|
|
178
181
|
}
|
|
179
|
-
async onDemandIngestFolder(body) {
|
|
182
|
+
async onDemandIngestFolder(body, options = {}) {
|
|
180
183
|
return this.request(`/ondemand/ingest/folder`, {
|
|
181
184
|
method: "POST",
|
|
182
185
|
body: JSON.stringify(body),
|
|
186
|
+
headers: options.idempotencyKey
|
|
187
|
+
? { "Idempotency-Key": options.idempotencyKey }
|
|
188
|
+
: undefined,
|
|
183
189
|
});
|
|
184
190
|
}
|
|
185
191
|
async onDemandStatus(jobId) {
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1224,11 +1224,15 @@ export interface paths {
|
|
|
1224
1224
|
* Submit video for immediate on-demand encoding
|
|
1225
1225
|
* @description Simplified API for immediate video encoding. Automatically probes, reserves tokens,
|
|
1226
1226
|
* and starts encoding. Premium pricing (1.5x-2x) for on-demand convenience.
|
|
1227
|
+
* Send `Idempotency-Key` when retrying from your backend to avoid duplicate jobs.
|
|
1227
1228
|
*/
|
|
1228
1229
|
post: {
|
|
1229
1230
|
parameters: {
|
|
1230
1231
|
query?: never;
|
|
1231
|
-
header?:
|
|
1232
|
+
header?: {
|
|
1233
|
+
/** @description Optional key for safely retrying job creation requests. Reusing the same key with the same request body replays the original response; reusing it with a different body returns 409. */
|
|
1234
|
+
"Idempotency-Key"?: components["parameters"]["IdempotencyKey"];
|
|
1235
|
+
};
|
|
1232
1236
|
path?: never;
|
|
1233
1237
|
cookie?: never;
|
|
1234
1238
|
};
|
|
@@ -1311,11 +1315,15 @@ export interface paths {
|
|
|
1311
1315
|
* - Include `refreshToken` when jobs may outlive a short access token.
|
|
1312
1316
|
*
|
|
1313
1317
|
* Your users do not need to connect Google Drive inside the Convertrilo dashboard for API usage.
|
|
1318
|
+
* Send `Idempotency-Key` when retrying from your backend to avoid duplicate folder batches.
|
|
1314
1319
|
*/
|
|
1315
1320
|
post: {
|
|
1316
1321
|
parameters: {
|
|
1317
1322
|
query?: never;
|
|
1318
|
-
header?:
|
|
1323
|
+
header?: {
|
|
1324
|
+
/** @description Optional key for safely retrying job creation requests. Reusing the same key with the same request body replays the original response; reusing it with a different body returns 409. */
|
|
1325
|
+
"Idempotency-Key"?: components["parameters"]["IdempotencyKey"];
|
|
1326
|
+
};
|
|
1319
1327
|
path?: never;
|
|
1320
1328
|
cookie?: never;
|
|
1321
1329
|
};
|
|
@@ -2025,7 +2033,10 @@ export interface components {
|
|
|
2025
2033
|
};
|
|
2026
2034
|
};
|
|
2027
2035
|
responses: never;
|
|
2028
|
-
parameters:
|
|
2036
|
+
parameters: {
|
|
2037
|
+
/** @description Optional key for safely retrying job creation requests. Reusing the same key with the same request body replays the original response; reusing it with a different body returns 409. */
|
|
2038
|
+
IdempotencyKey: string;
|
|
2039
|
+
};
|
|
2029
2040
|
requestBodies: never;
|
|
2030
2041
|
headers: never;
|
|
2031
2042
|
pathItems: never;
|
|
@@ -61,6 +61,8 @@ const job = await client.onDemandEncode({
|
|
|
61
61
|
codec: "h264",
|
|
62
62
|
resolution: "1080p",
|
|
63
63
|
quality: "better",
|
|
64
|
+
}, {
|
|
65
|
+
idempotencyKey: "encode-customer-video-123",
|
|
64
66
|
});
|
|
65
67
|
|
|
66
68
|
console.log(job.jobId);
|
|
@@ -72,6 +74,7 @@ Equivalent curl:
|
|
|
72
74
|
curl https://api.convertrilo.com/ondemand/encode \
|
|
73
75
|
-H "Content-Type: application/json" \
|
|
74
76
|
-H "X-API-Key: $CONVERTRILO_API_KEY" \
|
|
77
|
+
-H "Idempotency-Key: encode-customer-video-123" \
|
|
75
78
|
-d '{
|
|
76
79
|
"sourceUrl": "https://example.com/input.mp4",
|
|
77
80
|
"externalId": "customer-video-123",
|
|
@@ -89,6 +92,8 @@ Poll `/ondemand/status/{jobId}` until the job reaches `success`, then read `down
|
|
|
89
92
|
|
|
90
93
|
Use `externalId` and `metadata` to reconcile Convertrilo jobs with your own database. They are returned by status responses and managed webhook payloads.
|
|
91
94
|
|
|
95
|
+
Use `Idempotency-Key` on creation requests that your backend may retry. If the same key and request body are received again, Convertrilo returns the original response instead of queuing another job. If the same key is reused with a different body, the API returns `409`.
|
|
96
|
+
|
|
92
97
|
## Flow 2: URL Source To S3 Output
|
|
93
98
|
|
|
94
99
|
Use this when your customer wants the encoded output in their own S3-compatible bucket.
|
|
@@ -148,6 +153,8 @@ const batch = await client.onDemandIngestFolder({
|
|
|
148
153
|
},
|
|
149
154
|
codec: "h264",
|
|
150
155
|
resolution: "1080p",
|
|
156
|
+
}, {
|
|
157
|
+
idempotencyKey: "folder-batch-2026-06-09",
|
|
151
158
|
});
|
|
152
159
|
|
|
153
160
|
for (const job of batch.jobs || []) {
|
package/openapi.yaml
CHANGED
|
@@ -37,6 +37,15 @@ components:
|
|
|
37
37
|
type: apiKey
|
|
38
38
|
in: header
|
|
39
39
|
name: X-API-Key
|
|
40
|
+
parameters:
|
|
41
|
+
IdempotencyKey:
|
|
42
|
+
in: header
|
|
43
|
+
name: Idempotency-Key
|
|
44
|
+
required: false
|
|
45
|
+
schema:
|
|
46
|
+
type: string
|
|
47
|
+
maxLength: 255
|
|
48
|
+
description: Optional key for safely retrying job creation requests. Reusing the same key with the same request body replays the original response; reusing it with a different body returns 409.
|
|
40
49
|
schemas:
|
|
41
50
|
AuthLoginRequest:
|
|
42
51
|
type: object
|
|
@@ -1189,6 +1198,9 @@ paths:
|
|
|
1189
1198
|
description: |
|
|
1190
1199
|
Simplified API for immediate video encoding. Automatically probes, reserves tokens,
|
|
1191
1200
|
and starts encoding. Premium pricing (1.5x-2x) for on-demand convenience.
|
|
1201
|
+
Send `Idempotency-Key` when retrying from your backend to avoid duplicate jobs.
|
|
1202
|
+
parameters:
|
|
1203
|
+
- $ref: "#/components/parameters/IdempotencyKey"
|
|
1192
1204
|
requestBody:
|
|
1193
1205
|
required: true
|
|
1194
1206
|
content:
|
|
@@ -1275,6 +1287,9 @@ paths:
|
|
|
1275
1287
|
- Include `refreshToken` when jobs may outlive a short access token.
|
|
1276
1288
|
|
|
1277
1289
|
Your users do not need to connect Google Drive inside the Convertrilo dashboard for API usage.
|
|
1290
|
+
Send `Idempotency-Key` when retrying from your backend to avoid duplicate folder batches.
|
|
1291
|
+
parameters:
|
|
1292
|
+
- $ref: "#/components/parameters/IdempotencyKey"
|
|
1278
1293
|
requestBody:
|
|
1279
1294
|
required: true
|
|
1280
1295
|
content:
|