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 loginstores 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
Install the package:
npm install startup-builderSet the key in the environment:
export STARTUP_BUILDER_API_KEY=sk_test_... $reads its key fromSTARTUP_BUILDER_API_KEY. The key selects the namespace, and itstestprefix keeps every call in the test environment.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
aftercursor.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/.
Next steps
- What a write returns: one Action per call.
- The SDK overview: Modes, failures, and Events.
- SDK methods: every method, by Noun.