@agavadex/sdk
v0.1.2
Published
TypeScript SDK for the AgavaDEX exchange API (REST + WebSocket)
Maintainers
Readme
AgavaDEX TypeScript SDK
TypeScript / JavaScript client for the AgavaDEX exchange API — a thin, typed wrapper over the public REST + WebSocket interface.
Install
npm install @agavadex/sdkRequires Node.js 18+. Ships ESM and CommonJS builds with type declarations.
Quick start
Public market data — no key needed
import { Client } from "@agavadex/sdk";
const client = new Client();
for (const s of await client.getSymbols()) {
console.log(s.symbol, s.tick_size);
}
const book = await client.getOrderBook("AGAVAUSDT");
console.log(book.bids[0]?.price, book.asks[0]?.price);Private account & trading
API keys are created in the AgavaDEX web app (Account → API keys). Read them from the environment — never hard-code them.
import { Client } from "@agavadex/sdk";
const client = new Client({
apiKey: process.env.AGAVADEX_API_KEY,
apiSecret: process.env.AGAVADEX_API_SECRET,
});
for (const balance of await client.getBalances()) {
console.log(balance.asset, balance.available);
}
const { order } = await client.placeOrder("AGAVAUSDT", {
side: "buy",
type: "limit",
price: "100.00",
qty: "1",
});
console.log(order.id, order.status);WebSocket streams
import { MarketDataStream } from "@agavadex/sdk";
const stream = new MarketDataStream({ channels: ["trades@AGAVAUSDT"] });
for await (const msg of stream) {
console.log(msg.channel, msg.type, msg.data);
}The private UserStream takes apiKey / apiSecret and authenticates
in-band with a signed first frame. Subscribe to any of orders,
trades, balances:
import { UserStream } from "@agavadex/sdk";
const stream = new UserStream({
apiKey: process.env.AGAVADEX_API_KEY!,
apiSecret: process.env.AGAVADEX_API_SECRET!,
channels: ["orders", "balances"],
});
for await (const msg of stream) {
console.log(msg.channel, msg.type, msg.data);
}Both streams auto-reconnect and re-subscribe on a dropped socket.
The decimal contract
Every monetary value — price, qty, volume, fee amounts — is a
JSON string ("3500.55"), never a number. This SDK keeps those
fields as string: that is lossless and leaves the choice of
big-decimal library to you. Never Number() them blindly.
Errors
Non-2xx responses throw a typed error — BadRequestError,
AuthenticationError, PermissionDeniedError, NotFoundError,
RateLimitError, ServerError — all subclasses of ApiError. Each
carries statusCode and the API's requestId; RateLimitError adds
retryAfter. Pass maxRetries to Client to auto-retry 429s.
What this SDK does not do
Withdrawals are not part of the AgavaDEX API and not in this SDK — they require a wallet signature and happen only in the web app.
Development
npm install
npm run typecheck
npm test # offline tests run with no credentials
npm run buildIntegration tests run only when AGAVADEX_API_KEY / AGAVADEX_API_SECRET
are set, and are read-only — they never place orders.
Links
- Docs: https://docs.agavadex.com
- API reference: https://docs.agavadex.com/api/reference/
- Security policy: SECURITY.md
