@liqpro/liq-api-client
v0.28.0
Published
Typed REST + SSE client for the Liq order-gateway API.
Readme
@liq/api-client
Typed REST + SSE client for the Liq order-gateway API.
Overview
@liq/api-client provides a fully-typed HTTP client for interacting with the order-gateway service. It wraps up-fetch with automatic JWT bearer token management, response envelope unwrapping ({ data: T } → T), and structured error handling via LiqApiError. The top-level LiqClient exposes namespaced service objects for auth, orders, markets, positions, accounts, and SSE streaming.
Key Exports
LiqClient
Main entry point. Constructed with { baseUrl, chainId? }.
const client = new LiqClient({ baseUrl: 'http://localhost:4000' });
client.setToken(jwt); // set or clear auth token| Property | Type | Description |
| ------------------ | --------------------- | ------------------------------------- |
| client.auth | AuthService | SIWE nonce + verify, dev-login |
| client.orders | OrdersService | Submit, cancel, list, get orders |
| client.markets | MarketsService | List markets |
| client.positions | PositionsService | List open positions |
| client.accounts | AccountsRestService | Register + get account |
| client.sse | SSEService | Subscribe to real-time event channels |
Other exports
AuthService,AuthTokens— standalone auth service + token typeOrdersService— order CRUDMarketsService— market listPositionsService,PositionResponse— positionsAccountsRestService,RegisterAccountParams,RegisterAccountResponse— account managementSSEService,SSEEventHandler— SSE subscription helpersLiqApiError— typed API error (status code + error code + body)
Install
pnpm add @liq/api-clientDependencies
@liq/core— shared types and enumsup-fetch— lightweight fetch wrapper with base URL + interceptors
Build
moon run liq-api-client:build # tsup → dist/