Skip to content

Install the SDK

Install the startup-builder package, set one key in the environment, and make a first typed call from code to a Startup's test environment.

The startup-builder package exports $, the typed client for one Startup. Setup is one install and one key: there is no client to construct and no base URL to set.

Prerequisites

  • A project that installs packages with npm. The same package runs on a server, at the edge, and inside a Startup's own Functions.
  • A test Secret key, sk_test_..., for the Startup. npx startup-builder login stores one, and the key guide covers every kind.

The examples use leaseline.app, which tracks lease renewals for small property managers at $29 a month.

Steps

Terminal4 steps
  1. Install the package:

    npm install startup-builder
  2. Set the key in the environment:

    export STARTUP_BUILDER_API_KEY=sk_test_...

    $ reads its key from STARTUP_BUILDER_API_KEY. The key selects the namespace, and its test prefix keeps every call in the test environment.

  3. Import $ and make a first call:

    TypeScript
    import { $ } from 'startup-builder'
    
    const offers = await $.Offer.list({ limit: 5 })
    
    console.log(offers.map((offer) => offer.$id)) // https://api.sb/leaseline.app/offers/offer_1

    A list resolves to one page, an array with an after cursor.

  4. To try a write without storing anything, prefix it with try:

    TypeScript
    await $.try.Offer.subscribe({ offer: 'offer_1', quantity: 1 })

Result

$ holds a typed method for every Verb the key may run, and the editor completes each one's input. $.Offer.subscribe(input) is the same operation as POST /offers/{offer}/subscribe.

Next steps