Skip to content
GigadriveDocs

SDK

The official TypeScript client for the Gigadrive Network API, running on Node.js, in browsers, and on edge runtimes.

@gigadrive/sdk is the TypeScript client for the Gigadrive Network API. Use it when your code has to call that API: a deployed Function reading its own bucket, a CI job triggering a deployment, or a browser sending a file straight to storage.

Install

npm install @gigadrive/sdk

The package ships CommonJS and ESM builds with bundled type declarations, so require and import both work and there is no separate @types package to add. It pulls in tus-js-client, which drives resumable uploads.

Supported runtimes

Anything with a global fetch: Node.js 18 or newer, browsers, and edge runtimes.

Two upload sources are Node-only, because they read from the filesystem:

SourceOutside Node
upload({ path })throws Uploading from a file path is only supported in Node.js.
upload({ stream })there is no Node stream to pass; send a File or Blob as data

Everything else works the same in every runtime, including the SHA-256 the storage API requires on each upload, which the SDK computes with crypto.subtle.

Outside Node the SDK cannot read process.env. A browser or edge client therefore takes its credentials from the constructor, and a client built without any credential throws AuthenticationError on the spot.

Your first call

import { GigadriveClient } from '@gigadrive/sdk';

const client = new GigadriveClient({
  clientId: process.env.GIGADRIVE_CLIENT_ID,
  clientSecret: process.env.GIGADRIVE_CLIENT_SECRET,
});

const { items: applications, total } = await client.applications.list();

console.log(`${total} applications`);
for (const application of applications) {
  console.log(application.id, application.name);
}

The client id is an API key ID and the secret is the gdnet_secret_ value that key returned once, when it was created. The client exchanges the pair for an access token on the first request and caches it. Almost every list call answers with { items, total }, so destructuring items is the pattern you will write most.

Inside a deployed Function, drop the arguments entirely. new GigadriveClient() picks up the credential and the application context the platform injects, which is covered in OIDC federation.