SDKs

TypeScript

The TypeScript client for typeship's own API. Generated by typeship from its own spec, so it is also a sample of what your users get.

typeship-ax on npm is the TypeScript SDK for the typeship API, generated by typeship from its own OpenAPI spec. It has the same shape as every SDK typeship generates: zero runtime dependencies, typed results, typed error unions, auto-pagination, retries. If you want to see what your users will get before you generate anything, read this package.

The package also carries the typeship CLI and the typeship MCP server.

Install

npm install typeship-ax

Node 18 or newer. ESM only.

Create a client

import { TypeshipClient } from "typeship-ax";

const client = new TypeshipClient({ bearerToken: process.env.TYPESHIP_TOKEN! });

The key comes from the console under api keys. Pass it explicitly. The typeship SDK does not read environment variables for credentials. TypeshipClient takes the same options as any generated client: baseUrl, timeoutMs, maxRetries, defaultHeaders, fetch, onRequest, onResponse, onError, debug, and validate. See Client options.

Generate a package

generate.run runs the generator on a spec and returns the files. Nothing is stored. The free plan generates the first 25 operations; paid plans generate the whole spec:

const result = await client.generate.run({
  spec: { url: "https://api.acme.example.com/openapi.json" },
  platforms: ["sdk", "cli"],
  language: "typescript",
});

if (result.ok) {
  for (const file of result.data.files) {
    await fs.writeFile(path.join("out", file.path), file.content);
  }
  console.log(result.data.meta.operation_count, "operations");
}

Work with projects

import { TypeshipClient, unwrap } from "typeship-ax";

const client = new TypeshipClient({ bearerToken: process.env.TYPESHIP_TOKEN! });

const project = unwrap(await client.projects.create({
  name: "Acme API",
  spec_url: "https://api.acme.example.com/openapi.json",
  platforms: ["sdk", "cli", "mcp"],
  languages: ["typescript", "python"],
  destinations: {
    typescript: { repo: "acme/acme-node" },
    python: { repo: "acme/acme-python" },
  },
  auto_regen: true,
}));

// Regenerate on demand and read every language's files.
const generations = unwrap(await client.projects.generate(project.id));
for (const generation of generations.data) {
  if (generation.status !== "succeeded") continue;
  console.log(generation.language, generation.meta.file_count);
}

// Walk history.
for await (const generation of client.projects.listGenerations(project.id)) {
  console.log(generation.created_at, generation.trigger, generation.status);
}

Every method

ResourceMethods
generaterun(body)
projectslist(params?), create(body), get(id), update(id, body), delete(id), generate(id), listGenerations(id, params?)
generationsget(id), getFile(id, { path })
specVersionslist(projectId, params?), get(id), getContent(id)
accountme()
usageretrieve()
apiKeyslist(params?), revoke(id)

Bodies and responses use the API's snake_case names. api.md inside the package is the complete reference, and the API reference has every schema.

Errors

Every call returns ApiResult. The error union for each operation lists exactly what the API documents for it, plus UnexpectedApiError, TransportError, and ValidationError:

import { NotFoundError, PaymentRequiredError } from "typeship-ax";

const result = await client.projects.generate("prj_...");
if (!result.ok) {
  if (result.error instanceof PaymentRequiredError) {
    // free plan allowance used up; result.error.body.errors[0].message says so
  }
  if (result.error instanceof NotFoundError) {
    // no such project on this account
  }
}

See Errors for the envelope and codes.

On this page