SDK reference
Every public @agg-build/sdk method, the HTTP operation it calls, and its API reference page
@agg-build/sdk is a thin client over the REST API. Each method below calls one HTTP operation.
Follow the link for the full request and response schema.
import { createAggClient } from "@agg-build/sdk";
const client = createAggClient({
baseUrl: "https://api.t.sufwankhalid.com",
appId: "your-app-id",
});createAggClient() returns an AggClient. It adds the x-app-id and Authorization headers for
you and keeps the user's session. See Base URL, app IDs & API keys for the base URL and
Quickstart: REST for a full trade.
Auth
| Method | HTTP | Reference |
|---|---|---|
authStart() | POST /auth/start | Start authentication |
startAuth() | Alias of authStart() | Start authentication |
buildSiweMessage() | None. Builds the EIP-4361 message locally | Quickstart: REST |
buildSiwsMessage() | None. Builds the Solana sign-in message locally | Quickstart: REST |
verify() | POST /auth/verify | Verify sign-in |
verifySignIn() | Alias of verify() | Verify sign-in |
exchangeAuthCode() | POST /auth/token/exchange | Complete redirect sign-in |
refreshAccessToken() | POST /auth/token/refresh | Refresh access token |
signOut() | POST /auth/sign-out | Sign out |
setSession() | None. Stores tokens from a redirect callback | Authentication |
setAccessToken() | None. Replaces the stored access token | Authentication |
clearAccessToken() | None. Clears the local session | Authentication |
onAuthStateChange() | None. Subscribes to sign-in and sign-out | Authentication |
Read-only session properties: isAuthenticated, authStatus, user, address, appId.
Users
| Method | HTTP | Reference |
|---|---|---|
getCurrentUser() | GET /users/me | Get current user |
updateUser() | PATCH /users/me | Update username |
linkExternalId() | POST /users/me/external-id | Link partner external user ID |
createAvatarUploadUrl() | POST /users/me/avatar | Get avatar upload URL |
linkAccount() | POST /users/me/link-account/start | Start account linking |
linkAccountConfirm() | POST /users/me/link-account/confirm | Confirm account linking |
disconnectAccount() | DELETE /users/me/accounts/{provider} | Disconnect auth provider |
getSharedKycStatus() | GET /kyc/status | Get shared KYC status |
initiateKyc() | POST /kyc/{venue} | Initiate KYC |
upsertVenueKey() | PUT /venue-keys | Upsert a venue API key |
listVenueKeys() | GET /venue-keys | List venue keys |
getVenueKeyStatus() | GET /venue-keys/{venue}/status | Get venue key connection status |
deleteVenueKey() | DELETE /venue-keys/{venue} | Delete a venue key |
Markets
| Method | HTTP | Reference |
|---|---|---|
search() | GET /search | Search events or markets |
getVenueEvents() | GET /venue-events | List venue events |
getVenueEventById() | GET /venue-events/{id} | Get venue event |
getEventBootstrap() | GET /venue-events/{id}/bootstrap | Get the first useful event view |
getVenueMarkets() | GET /venue-markets | List venue markets |
getCategories() | GET /categories | List categories |
getCatalogChanges() | GET /catalog/changes. One page; pass nextCursor back until hasMore is false. A 410 is isCatalogResyncRequired(err) | List catalog changes |
listRecurringCryptoMarkets() | GET /crypto/recurring-markets | List recurring crypto window markets |
getAppConfig() | GET /app/config. Public UI config for this app | Get the per-app UI config |
getNewsFeeds() | GET /news-feed | List available news feeds |
getNewsFeed() | GET /news-feed/{category} | Article-centric news feed |
getNewsFeedMarkets() | GET /news-feed/{category}/markets | Market-centric news feed |
getMarketNews() | POST /news-feed/market-news | News for markets |
getMarketCorrelatedSignals() | GET /correlated-markets/{venueMarketId} | Correlated market signals |
queryCorrelatedMarkets() | POST /correlated-markets/query | Find correlated markets |
getCorrelatedMarketCascade() | GET /correlated-markets/cascade/{venueMarketId} | Ripple effect of a resolution |
resolveCorrelatedMarkets() | POST /correlated-markets/resolve | Resolve a market and return cascade |
GET /venue-market-outcomes has no dedicated method. Call it with request(). See
Look up venue market outcomes by external identifier.
Market data
| Method | HTTP | Reference |
|---|---|---|
getOutcomeOrderbooks() | GET /orderbooks/outcomes | Get bounded outcome snapshots |
getOrderbooks() | GET /orderbooks | Get live orderbooks |
getOutcomeOrderbook() | GET /orderbook/outcome/{outcomeId} | Get live orderbook for one outcome |
getMidpoints() | GET /midpoints | Get live midpoints |
getChartBars() | GET /charts/bars | Get chart bars |
getChartHistoryManifest() | GET /charts/history/manifest | Get versioned chart history references |
getCryptoReferencePrices() | POST /crypto/reference-prices | Get live crypto reference prices |
getSportsLive() | GET /sports/live | Get live sports scores |
Trading
| Method | HTTP | Reference |
|---|---|---|
getSmartRoute() | GET /orderbook/{venueMarketOutcomeId}/route | Get a quote |
executeManaged() | POST /execution/fill | Execute quote |
fillSelfCustody() | POST /execution/fill, then polls status and submits signatures | Self-custody trading |
submitFillSignatures() | POST /execution/fill/{quoteId}/signatures | Submit signatures |
getExecutionStatus() | GET /execution/status | Get execution status |
placeOrder() | POST /execution/orders | Place an order directly |
placeLimitOrder() | POST /execution/limit-orders | Place limit order |
cancelManagedOrder() | POST /execution/orders/cancel with orderId | Cancel an order |
cancelVenueOrder() | POST /execution/orders/cancel for an order placed outside sufwan-local-test | Cancel an order |
redeem() | POST /execution/redeem | Redeem winnings |
redeemSelfCustody() | Sell quote on a resolved market, then fillSelfCustody() | Self-custody trading |
getVenueGeoPolicy() | GET /app/venue-geo-policy | Per-venue blocked countries |
Portfolio
| Method | HTTP | Reference |
|---|---|---|
getManagedBalances() | GET /execution/balances | Get balances |
getPositions() | GET /execution/positions | Get user positions |
getExecutionPositions() | GET /execution/positions with cursor pagination | Get user positions |
getExecutionOrders() | GET /execution/orders | Get user orders |
getUserActivity() | GET /users/activity | Get user activity feed |
getLeaderboard() | GET /leaderboard | Trader leaderboard |
getLeaderboardSeries() | GET /leaderboard/series | Trader leaderboard series |
Funding
| Method | HTTP | Reference |
|---|---|---|
getDepositAddresses() | GET /execution/deposit-addresses | Get deposit addresses |
getWithdrawalQuote() | POST /execution/withdrawable/quote | Quote withdrawable amount |
withdrawPreview() | POST /execution/withdraw/preview | Preview a withdrawal |
withdrawManaged() | POST /execution/withdraw | Withdraw funds |
getWithdrawalStatus() | GET /execution/withdrawals/{withdrawalId} | Get withdrawal status |
submitWithdrawalSignatures() | POST /execution/withdrawals/{withdrawalId}/signatures | Submit withdrawal signatures |
getBalanceRefillPolicies() | GET /execution/balance-refill-policies | List refill policies |
createBalanceRefillPolicy() | POST /execution/balance-refill-policies | Create a refill policy |
updateBalanceRefillPolicy() | PATCH /execution/balance-refill-policies/{policyId} | Update or pause a refill policy |
getBalanceRefillAttempts() | GET /execution/balance-refill-policies/{policyId}/attempts | List refill attempts |
getRampQuotes() | POST /ramp/quotes | Get crypto purchase quotes |
createRampSession() | POST /ramp/session | Create a ramp widget session |
getHostedVenueAccount() | GET /users/me/venue-accounts/{venue} | Get hosted venue account |
provisionHostedVenueAccount() | POST /users/me/venue-accounts/{venue} | Provision hosted venue account |
getHostedVenueActivity() | GET /users/me/venue-accounts/{venue}/activity | Get hosted venue account activity |
getHostedVenueDepositAddress() | GET /users/me/venue-accounts/{venue}/deposit-address | Get hosted venue deposit address |
withdrawHostedVenue() | POST /users/me/venue-accounts/{venue}/withdrawals | Withdraw hosted venue funds |
getHostedVenueWithdrawal() | GET /users/me/venue-accounts/{venue}/withdrawals/{withdrawalId} | Get hosted venue withdrawal |
Paper trading
mode: "paper" on getSmartRoute() / executeManaged() is the user path (user JWT plus x-app-id).
The methods below are the admin path. They call /apps/{appId}/paper-trading/... and need a
server-side x-app-api-key. See Paper trading.
| Method | HTTP | Reference |
|---|---|---|
createPaperTradingAccount() | POST .../accounts | Create a paper trading account |
listPaperTradingAccounts() | GET .../accounts | List paper trading accounts |
getPaperTradingAccount() | GET .../accounts/{accountId} | Get a paper trading account |
setPaperTradingBalance() | PATCH .../accounts/{accountId}/balance | Set a paper account cash balance |
resetPaperTradingAccount() | POST .../accounts/{accountId}/reset | Reset a paper trading account |
placePaperTradingOrder() | POST .../accounts/{accountId}/orders | Place a paper trading order |
listPaperTradingOrders() | GET .../accounts/{accountId}/orders | List paper trading orders |
listPaperTradingPositions() | GET .../accounts/{accountId}/positions | List paper trading positions |
getPaperTradingPortfolio() | GET .../accounts/{accountId}/portfolio | Get a paper trading portfolio |
Real-time
| Method | HTTP | Reference |
|---|---|---|
createWebSocket() | WebSocket. Needs wsUrl in the client options. Runs the 5-minute book watchdog unless bookWatchdog: false. Server-side with apiKey, authenticates the handshake with x-app-api-key; pass webSocketImpl on runtimes without a global WebSocket. Resumes user events after reconnects | Real-Time Orderbook, Server connections |
socket.subscribeAppEvents(cb) | Every user event of the app, on an API-key connection. Returns an unsubscribe function | App events |
watchCatalog() | catalog channel plus GET /catalog/changes catch-up on every (re)subscribe and interruption. Calls onChange once per newer entity state. Returns { stop(), lastChangedAt, resync(since), ready }. Needs wsUrl unless you pass socket | Catalog Sync |
socket.subscribeCatalog(filter, cb, { onSubscribed, onInterrupted }) | Live catalog_change frames only, no catch-up. onSubscribed fires on every confirmed (re)subscribe and onInterrupted on a catalog stream interruption: catch up over REST on both. Returns an unsubscribe function | Catalog feed |
Utilities
| Method | What it does |
|---|---|
request() | Calls any path with the client's headers. Retries once after a token refresh on 401 |
destroy() | Releases browser resources. Safe to call more than once |
Not in the public API reference
These methods exist in the SDK but call routes that are not part of the public API reference. They may change without notice. Do not build on them.
getOrders(), getUserHoldings(), getRpcToken(), getNewsFeedStatus(),
getCorrelatedMarketsStatus(), recordDepositIntent(), syncManagedBalances().
syncManagedBalances() is not a public route. Do not call POST /execution/sync-balances.
Server module
@agg-build/sdk/server is for your backend only. It uses your app's x-app-api-key, which must
never reach a browser.
import { AggAdminClient, verifyWebhook } from "@agg-build/sdk/server";
const admin = new AggAdminClient({
baseUrl: "https://api.t.sufwankhalid.com",
apiKey: process.env.AGG_APP_API_KEY!,
});Webhooks and partner admin (AggAdminClient)
| Method | HTTP | Reference |
|---|---|---|
listUsers() | GET /apps/{appId}/users | List users |
getUser() | GET /apps/{appId}/users/{userId} | Get user |
listOrders() | GET /apps/{appId}/orders | List orders across your app |
getAnalytics() | GET /apps/{appId}/analytics | Get analytics |
listMarketResolutionUsers() | GET /apps/{appId}/market-resolutions/{venueMarketId}/users | Users affected by a resolution |
rotateWebhookSecret() | POST /apps/{appId}/webhooks/{webhookId}/rotate-secret | Rotate webhook signing secret |
replayWebhookDeliveries() | POST /apps/{appId}/webhooks/{webhookId}/replay | Replay failed deliveries |
AggAdminClient also has request() for any other partner-admin route.
Helper functions
| Function | What it does | Guide |
|---|---|---|
verifyWebhook() | Checks a delivery's signature and timestamp. Throws if either is invalid | Verifying webhook signatures |
verifyWebhookAsync() | Same as verifyWebhook(), for edge runtimes (Web Crypto) | Verifying webhook signatures |
parseWebhookEvent() | Verifies the delivery, then returns it as a typed event | Webhook event reference |
parseWebhookEventAsync() | Same as parseWebhookEvent(), for edge runtimes (Web Crypto) | Webhook event reference |
signExternalId() | Signs your internal user ID for external ID linking | External ID linking |