Reference

Build on the Lucra API.

Drag a sticker to move it, or use the arrow keys while focused.

SDKs

Typed methods for every endpoint.

@lucra/sdk has a typed method for every endpoint. It runs anywhere fetch does.

Terminal
npm install @lucra/sdk

Use it

TypeScript
import { Lucra } from "@lucra/sdk"

const lucra = new Lucra(process.env.LUCRA_API_KEY)

const { data: program } = await lucra.programs.retrieve({
  path: { id: "prog_00lhuAJjQgdtNt5WnqTBc95" },
})
const { data: page } = await lucra.submissions.list({
  query: { program: program.id, status: "pending" },
})
await lucra.programs.update({
  path: { id: program.id },
  body: { status: "paused", version: program.version },
})

Path parameters go in path, filters in query, and the body in body. Every resource is exported as a type, like Program or Creator.

Act for an account

TypeScript
const brand = lucra.as("acct_07RodMW6bE7BBO6e1I3UzSi")
const { data: programs } = await brand.programs.list()

Every page

TypeScript
import { paginate } from "@lucra/sdk"

for await (const payment of paginate((options) =>
  lucra.payments.list(options)
)) {
  console.log(payment.id)
}

Errors and retries

Failed requests throw a LucraError with the API's code and fix. Pass an Idempotency-Key header on writes you might retry:

TypeScript
await lucra.payments.create({
  body: { creator: "crtr_026UYfiw1Y6OvUpuKWiOpeL", net: 5000 },
  headers: { "Idempotency-Key": order.id },
})

Other languages

Generate a client from the OpenAPI document.