Quickstart
Install @bento.fun/sdk and make your first markets and tournaments API calls.
Install
npm install @bento.fun/sdkRequires Node.js 18+.
Environment
| Variable | Purpose |
|---|---|
BENTO_URL / baseUrl | Markets host (e.g. https://mainnet-server.bento.fun) |
PARLAY_TOURNMENT_URL / tournamentsBaseUrl | Tournaments host (parlay, bracket, fantasy) |
Minimal client
import { createBentoSdk, walletAuthProvider } from '@bento.fun/sdk';
const sdk = createBentoSdk({
baseUrl: process.env.BENTO_URL!,
tournamentsBaseUrl: process.env.PARLAY_TOURNMENT_URL,
auth: walletAuthProvider(() => ({
'x-wallet-address': '0xYourAddress',
'x-signature': '0x…',
'x-timestamp': String(Date.now()),
})),
});Public reads (no auth required)
// Markets catalog
const duels = await sdk.public.listDuels({ page: 1, limit: 20 });
// Use duelId (on-chain id), not id (database row id)
const duel = await sdk.public.getDuelById({ duelId: duels.data[0].duelId });
// Platform analytics
const report = await sdk.public.analytics.getPlatformReport();
// Parlay markets (tournaments host) — response is { markets: [...] }
const { markets: parlayMarkets } = (await sdk.tournaments?.parlay.listMarkets()) as {
markets: unknown[];
};See Common patterns for duelId vs id, auth, and response shapes.
Authenticated flows
Login (markets host)
const session = await sdk.public.auth.eoaLogin({
address: '0x…',
signature: '0x…',
timestamp: Date.now(),
});
// Use session token with jwtAuthProvider for subsequent callsPlace a bet
const estimate = await sdk.user.bets.estimateBuy({
duelId: '…',
option: 'YES',
amount: '10',
});
await sdk.user.placeBet(
{ duelId: '…', option: 'YES', amount: '10' },
{ idempotencyKey: `bet-${Date.now()}` },
);See Place a bet for reconciliation after HTTP acceptance.
Parlay quote (tournaments host)
import { jwtAuthProvider } from '@bento.fun/sdk';
const sdk = createBentoSdk({
baseUrl: process.env.BENTO_URL!,
tournamentsBaseUrl: process.env.PARLAY_TOURNMENT_URL,
auth: walletAuthProvider(() => ({ /* … */ })),
tournamentsAuth: jwtAuthProvider({
getAccessToken: () => localStorage.getItem('bento_jwt') ?? '',
}),
});
const quote = await sdk.tournaments!.parlay.createQuote({
legs: [/* … */],
stake: '25',
});See Place a parlay for on-chain placement.
Read-only mode
Omit wallet signing for public endpoints only:
const sdk = createBentoSdk({
baseUrl: process.env.BENTO_URL!,
tournamentsBaseUrl: process.env.PARLAY_TOURNMENT_URL,
auth: walletAuthProvider(() => ({})),
});
await sdk.public.listDuels({ page: 1 });
await sdk.tournaments?.parlay.listMarkets();Some tournaments reads still expect wallet headers — check the specific method.
Next
- TypeScript SDK — clients, auth, on-chain
- SDK API reference — every method + route
- Common patterns — pitfalls and tips
- Place a bet · Create a market · Create a tournament
- Test the SDK — npm integration sandbox
- Two API hosts — when to use which host
- Authentication — auth providers