Web / JavaScript SDK
@revenexx/sdk is the typed client for the revenexx API. It runs in the browser, in Node, and in edge runtimes. You configure the endpoint, your tenant, and a credential once, then call methods on a service instead of building HTTP requests by hand. This is the recommended way to talk to the API from JavaScript or TypeScript.
Status: shipped.
Install
npm install @revenexx/sdk
Configure the client
Create a Client, point it at the API, set your tenant, and add a credential.
import { Client } from "@revenexx/sdk";
const client = new Client()
.setEndpoint("https://api.revenexx.com")
.setTenant("<TENANT_SLUG>")
.setApiKeyAuth("rvxk_...");
The client supports the full public auth contract. Pick the one that fits where your code runs:
| Method | Header it sets | When to use it |
|---|---|---|
setApiKeyAuth(key) | X-Revenexx-Api-Key | Server-to-server. Created in the customer console. Keep it off the browser. |
setBearerAuth("Bearer <token>") | Authorization | A user token from ID or a personal access token. Pass the value including the Bearer prefix. |
setTenant(slug) | X-Revenexx-Tenant | Always — selects which tenant the request applies to. |
Use an API key only on a server. In a browser, authenticate the user through ID and call setBearerAuth with their token.
Make a call
Construct a service with the client, then call its methods. Each call returns a typed result and rejects with a RevenexxException on error.
import { Client, Products } from "@revenexx/sdk";
const client = new Client()
.setEndpoint("https://api.revenexx.com")
.setTenant("<TENANT_SLUG>")
.setApiKeyAuth("rvxk_...");
const products = new Products(client);
const result = await products.productsList();
const product = await products.productsGet({ id: "<PRODUCT_ID>" });
Handle errors
Failed calls throw a RevenexxException carrying the message, an error code, and the raw response.
import { RevenexxException } from "@revenexx/sdk";
try {
await products.productsGet({ id: "missing" });
} catch (error) {
if (error instanceof RevenexxException) {
console.error(error.code, error.message);
}
}
Response types live in the Models namespace and are fully typed, including nullable fields (typed as | null). Import a model when you want to annotate a value:
import { Client, Customers, type Models } from "@revenexx/sdk";
const customers = new Customers(client);
const address: Models.Address = await customers.customersAddressesGet({
id: "<ADDRESS_ID>",
});
What's available
The client exposes a service per API area, including Customers, Products, Orders, Carts, Payments, Shipping, Prices, Inventories, and Storage. The exact set of services and methods is generated from your tenant's API, so it tracks what your tenant exposes. Browse the typed methods in your editor's autocomplete after installing, or read the per-tenant API at /v1/openapi.json.
Where to go next
- Node SDK — the same client, packaged for server-side JavaScript.
- PHP SDK — the same client, from PHP.
- API Explorer — browse and try every endpoint in the browser.
- Authentication — get a user token to pass to
setBearerAuth.