TypeScript SDK

The Goomzo API for TypeScript and JavaScript.

@goomzo/sdk is the Goomzo API for TypeScript and JavaScript. It types every request and answer, retries safely, and pages through lists for you. It has no dependencies, and runs anywhere with fetch.

Requirements

  • Node 20 or later, Bun, Deno, Cloudflare Workers or Vercel Edge.
  • An API key. See Authentication.

Install

npm install @goomzo/sdk

Make your first request

Set your API key's secret as GOOMZO_API_KEY, then send a message:

import { Goomzo } from '@goomzo/sdk'

const goomzo = new Goomzo()

const message = await goomzo.messages.sendOne({
  to: '+255712345678',
  channel: 'sms',
  content: { text: 'Amina, order #1042 is ready.' },
})

console.log(message.id, message.status)

What it does for you

  • Types: every request and answer is typed, made from the API's own description.
  • A fixed version: it pins the API version it was written for, so a new version never changes what your code gets.
  • Safe retries: network errors, 429 and 5xx are tried again, twice by default. Every POST carries an Idempotency-Key, the same on each try, so nothing is done twice.
  • Lists: await a list for one page, or loop over it with for await for every item.
  • Errors you can act on: a GoomzoError has the status, the code, the fields that were wrong and the requestId.

Next steps

Last updated