APIs
SDKs
Basta ships a lightweight TypeScript React SDK as an alternative to talking to the GraphQL APIs directly — a clean abstraction layer that leans on TypeScript to simplify integration.
You can always call the Management API and Client API over raw GraphQL. The SDK is there when you want type safety and less boilerplate.
Why use the SDK
- Type safety— TypeScript's built-in type protection for dependable code.
- Abstraction of complexity — streamlined GraphQL queries behind an intuitive interface.
- Enhanced productivity — reduced boilerplate and IDE autocompletion support.
- React-first — a
BastaProviderplus hooks (useClientApi,useManagementApi) to reach the APIs from your components.
Installation
@bastaai/basta-js is a single package that covers both the Client API and the Management API.
npm install @bastaai/basta-js@1.0.1Package on npm: @bastaai/basta-js
Setup
Wrap your app in BastaProvider, configure whichever API you need, and reach it through the hooks.
import { BastaProvider, useClientApi } from "@bastaai/basta-js";
function App() {
return (
<BastaProvider clientApi={{ headers: {} }}>
<YourApp />
</BastaProvider>
);
}
function Sale() {
const clientApi = useClientApi();
const fetchSale = async () => {
const response = await clientApi.query({
sale: {
__args: { id: "your-sale-id" },
id: true,
title: true,
},
});
console.log(response.sale);
};
return null;
}Only configure the Management API on the server — its API key is account-wide and must never reach the browser. In the browser, use the Client API with short-lived bidder tokens for anything user-facing.
Support
Questions about the SDK? Email us at hi@basta.app.