TypeScript client
For a developer who would rather not hand-roll fetch calls. @cascade-commerce/api is a
typed client for both Cascade APIs, generated from the same OpenAPI documents this
reference is built from, so it never drifts from what the API actually accepts.
You do not need it. Every endpoint is an ordinary HTTPS request and the reference gives you curl for each one. The client is there so your editor knows the shapes.
Install
There are two entry points, one per API:
The admin API
There is no default base URL, so set one before the first call. Keep this on your server: a secret key that reaches a browser is a secret key that has leaked.
Function names follow the method and path, so POST /products/import is
postProductsImport and DELETE /customers/{id} is deleteCustomersById. Path
parameters go in path, query parameters in query, and a request body in body.
Every request and response shape is exported as a type:
Errors
Calls do not throw on a failed response. Check error and response, which carries the
status:
See Errors for the codes.
The widget API
The widget API takes a publishable key, which is safe to ship to the browser. Customer-specific endpoints also take the signed email and timestamp generated on your backend. See Authentication.
If you only want the rendered widgets rather than the data behind them, use the widgets package instead. See Storefront widgets for the embed script and React widgets for the React components, which can be dropped in whole or composed from their parts.
React Query
Query and mutation options are generated for both APIs, behind their own entry points so
they load only if you ask for them. @tanstack/react-query version 5 is an optional peer
dependency.
Talking to several organizations
The entry points export one shared client, which suits an application serving a single organization. To hold several at once, build a client each and pass one per call:
If you are building an application many merchants install, use OAuth rather than asking each of them for a secret key. See Authentication.
A worked example
packages/example-custom-store uses this client for its whole integration, in one file.
See Custom integration.