@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.agg.market",
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 | Authentication |
buildSiwsMessage() | None. Builds the Solana sign-in message locally | Authentication |
verify() | POST /auth/verify | Verify a wallet signature |
verifySignIn() | Alias of verify() | Verify a wallet signature |
exchangeAuthCode() | POST /auth/token/exchange | Exchange auth code for tokens |
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 |
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 | Avatar upload |
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 | Market-data API |
getVenueMarkets() | GET /venue-markets | List venue markets |
getCategories() | GET /categories | List categories |
listRecurringCryptoMarkets() | GET /crypto/recurring-markets | List recurring crypto window markets |
getAppConfig() | GET /app/config. Returns your app’s disabled venues and categories | Base URL, app IDs & API keys |
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 |
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 | Market-data API |
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 AGG | Cancel an order |
redeem() | POST /execution/redeem | Redeem winnings |
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 |
Funding
| Method | HTTP | Reference |
|---|---|---|
getDepositAddresses() | GET /execution/deposit-addresses | Get deposit addresses |
syncManagedBalances() | POST /execution/sync-balances | Funding |
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 |
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
These 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 | WebSocket protocol |
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().
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.agg.market",
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 |