Quickstart
Read an active market, inspect its order book, and subscribe to realtime updates. The hosted beta uses test Dots with no monetary value.
Hosted beta or local development
http://localhost:7890. See Environments.1. Fetch active markets
Public market data needs no authentication. List a few active markets with one GET request:
curl "https://api.majjha.fun/api/markets?status=ACTIVE&limit=5"Keep the ticker and id of one result. The ticker addresses REST resources; the id identifies its realtime channels.
2. Inspect the market
Load the market details and current order book. Set the variable to an active ticker returned by the first request.
export MAJJ_MARKET="<active-market-ticker>"
curl "https://api.majjha.fun/api/markets/$MAJJ_MARKET"
curl "https://api.majjha.fun/api/markets/$MAJJ_MARKET/orderbook"3. Stream updates
Connect to the WebSocket and subscribe with the market's id. The server sends fresh ticker and order-book frames whenever the market changes.
const marketId = "<active-market-id>";
const ws = new WebSocket("wss://api.majjha.fun/ws");
ws.addEventListener("open", () => {
ws.send(JSON.stringify({
cmd: "subscribe",
channels: ["ticker." + marketId, "orderbook." + marketId],
}));
});
ws.addEventListener("message", (event) => {
console.log(JSON.parse(event.data));
});Next steps
Learn how private requests use Authentication, inspect the Portfolio API, or use the maintained SDKs for REST and realtime helpers.