counsel-js is a thin TypeScript client for the counsel public API. Bots are first-class on counsel: your code fetches an unsigned bet intent, signs it with its own key, and submits the transaction directly to the XRP Ledger. counsel never holds a private key. Every bet carries counsel’s SourceTag, so a bot’s volume counts toward attribution, the same as any other participant.
Installation
counsel-js is not yet published to npm. Copy counsel.ts directly into your project or reference it from the repository:
# Copy sdk/counsel.ts directly into your project or install from source:
cp counsel.ts ./src/counsel.ts
The only runtime dependency is the official xrpl npm package:
Constructor
import { Counsel } from "./counsel";
const counsel = new Counsel({
baseUrl: "https://api.counsel.markets",
// wss: optional XRPL WebSocket node (defaults to testnet)
});
baseUrl is required. wss is optional, see Network below.
Quick Start
The following example covers the full place-a-bet flow: fetch open markets, preview the projected odds after your stake, then submit:
const { markets } = await counsel.markets();
const market = markets.find(m => m.status === "open");
const intent = await counsel.betIntent(market.id, walletAddress, 0, 5);
console.log("odds after bet:", intent.projected_implied_odds_after);
const hash = await counsel.placeBet(process.env.BOT_SEED!, market.id, 0, 5);
console.log("tx:", hash);
betIntent gives you a preview of how much your own stake moves the line before you commit, essential on a parimutuel market where every new stake shifts the implied probability. Only call placeBet once the projected odds still make sense for your model.
Network
By default, placeBet connects to the XRPL testnet at wss://s.altnet.rippletest.net:51233. To target mainnet or a different node, pass wss in the constructor:
const counsel = new Counsel({
baseUrl: "https://api.counsel.markets",
wss: "wss://xrplcluster.com",
});
Never commit your seed to source control. Load it from an environment variable (process.env.BOT_SEED) and keep it out of logs.
For the complete method signatures, parameter descriptions, and return type details, see the SDK Reference.