The Node SDK is the official JavaScript client. Its methods and typings are generated from the same API contract as the server, so they match the API. It needs Node 18 or newer and has no runtime dependencies.
Install
npm install @davixlabs/h2i-sdk
Use it
const { DavixH2I, enums } = require('@davixlabs/h2i-sdk');
const h2i = new DavixH2I({
apiKey: process.env.DAVIX_H2I_API_KEY,
baseUrl: 'https://app.h2i.davixlabs.io',
});
const res = await h2i.images.resize({
images: './photo.jpg',
width: 800,
resizeMode: enums.ResizeFit.COVER,
});
console.log(res.data, res.requestId);
What it does for you
- Key safety: the key is sent only in the
X-Api-Keyheader. - Uploads: a file can be a path, a Buffer, a Blob or File, a stream, or
{ data, filename, contentType }. - Errors: every failure is a
DavixH2IErrorwithstatus,code,requestId,hint,retryableand more. Compare codes withErrorCodes. - Retries: only retryable errors, and only for calls that cannot do the work twice. By default the SDK makes one idempotency key per call and reuses it on every retry, so a retry never charges you twice. You can pass your own
idempotencyKeyor turn the automatic key off withautoIdempotencyKey: false. - Metadata:
h2i.schema('images.resize')gives each field’s type, limits, default and allowed values.await h2i.capabilities()shows what the server offers andh2i.capabilities.account()your plan, limits and usage. - Escape hatch:
h2i.request('POST', '/v1/…', { json })reaches any public/v1/path the SDK does not know yet. - Name your app: add
app: 'My shop importer'to a call to label it in your History.
Other languages
Clients for Python, PHP, Go, Java, .NET and Ruby are published on their package registries too and are built from the same contract, so they match the API. Each guide has the install command and the package page.
Checked against the Node SDK README and the npm registry.
