Open the app

API

The Agora HTTP API, its conventions, types, errors, every route and the fixture mode.

The API reads the register and builds every transaction the app signs. It speaks JSON over HTTP, with one stream of live settlements over server-sent events. Its address on Mainnet is https://api-production-98ed7929.up.railway.app; the samples call it AGORA_API. The API serves its OpenAPI 3.1 document at GET /openapi.json, generated from the same zod schemas it validates with, and the program's Anchor IDL at GET /idl.json. The schemas also ship in the TypeScript client.

Conventions

  • Every u64 is a decimal string, so no amount loses precision in JavaScript; do arithmetic in BigInt. Units are whole, cash is in atoms with 6 decimals, and prices are cash atoms per unit.
  • Times are UTC, as ISO 8601 strings.
  • Enumerations are open: a field such as a settlement's kind may gain values. Treat a value you don't know as valid and show it as it is.
  • Responses may gain fields. Requests are strict, and an unknown field is a VALIDATION_ERROR.
  • No route moves funds by itself. A build route returns an unsigned transaction that the wallet signs, and POST /v1/transactions/submit sends it: see API: transactions.

Types

TypeWhat it is
AddressA base58 string encoding 32 bytes: a wallet, account or mint.
SignatureA base58 string encoding a 64-byte transaction signature.
U64An unsigned integer as a decimal string, at most 18446744073709551615. Do arithmetic in BigInt.
PositiveU64A U64 greater than zero.
BaseUnitsAn unsigned integer as a decimal string of up to 78 digits, for totals that can pass the u64 range.
Base64Standard base64.
TimestampAn ISO 8601 date and time in UTC.
CodeAn instrument code: 1 to 12 uppercase letters or digits.
TransactionIdThe id a build route returns, 1 to 128 characters.

Errors

Every failed response, whatever its status, carries one envelope, { "error": { … } }:

FieldTypeRequiredDescription
error.code"VALIDATION_ERROR" | "UNAUTHORIZED" | "ORIGIN_NOT_ALLOWED" | "NOT_FOUND" | "PROGRAM_UNAVAILABLE" | "CONFIGURATION_REQUIRED" | "IDEMPOTENCY_CONFLICT" | "TRANSACTION_EXPIRED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "SIMULATION_FAILED" | "CHAIN_REFUSED" | "RATE_LIMITED" | "INTERNAL_ERROR" | "UPSTREAM_UNAVAILABLE"yesA stable code to branch on (see API errors).
error.messagestringyesA sentence the app can show.
error.retryablebooleanyestrue when the same request can succeed later.
error.stage"validation" | "auth" | "read" | "upload" | "build" | "wallet" | "co_sign" | "simulation" | "send" | "confirmation"yesvalidation, auth, read, upload, build, wallet, co_sign, simulation, send or confirmation.
error.fieldErrorsRecord<string, string[]>noFor VALIDATION_ERROR: messages per request field.
error.programErrorobjectnoFor a program refusal: which program and error.
error.programError.programIdAddressyesThe refusing program's address.
error.programError.namestringyesIts error name.
error.programError.numberintegernoIts custom error code.
error.retryAfterSecondsintegernoFor RATE_LIMITED: seconds to wait.
error.requestIdstringnoThe request's id in the API's logs.

Branch on error.code. Each code has one HTTP status:

CodeStatusWhen
VALIDATION_ERROR400A path, query or body field failed the contract. fieldErrors names each one.
UNAUTHORIZED401A signed request was signed by another key than the wallet it names (POST /v1/admissions).
ORIGIN_NOT_ALLOWED403A browser request came from an origin the API doesn't allow.
NOT_FOUND404The instrument, account, build or route doesn't exist.
PROGRAM_UNAVAILABLE409The program isn't serving the ledger yet. Builds and submissions wait; retry later.
CONFIGURATION_REQUIRED409The API lacks a configuration value this request needs.
IDEMPOTENCY_CONFLICT409The idempotency key was used with a different build or different details.
TRANSACTION_EXPIRED409The build's blockhash expired before it landed. Build again.
PAYLOAD_TOO_LARGE413The body is larger than the API accepts.
UNSUPPORTED_MEDIA_TYPE415The body isn't application/json.
SIMULATION_FAILED422The transaction failed simulation. programError names the program error.
CHAIN_REFUSED422The ledger refuses the action as asked. programError names the reason.
RATE_LIMITED429Too many requests. Wait retryAfterSeconds.
INTERNAL_ERROR500The API failed. requestId identifies the request.
UPSTREAM_UNAVAILABLE502The RPC node or database didn't answer. Retry.

A program refusal names the program error from Errors in programError.name.

Routes

MethodPathClient methodWhat it does
GET/idl.jsonidlAgora program interface
GET/healthhealthService readiness
GET/v1/configconfigLedger configuration
GET/v1/accounts/{wallet}accountAccount balances, admission and activity
GET/v1/instrumentsinstrumentsAll instruments
GET/v1/instruments/{code}instrumentInstrument terms and market statistics
GET/v1/instruments/{code}/bookbookOpen bids and asks
GET/v1/instruments/{code}/registerregisterUnits registered to each owner
GET/v1/instruments/{code}/incomeincomeDistributions paid by the issuer
GET/v1/instruments/{code}/candlescandlesOHLC candles folded from fills
GET/v1/repo-offersrepoOffersOpen repo offers
GET/v1/reposreposRepos as borrower or lender
GET/v1/issuers/{wallet}/instrumentsissuerInstrumentsInstruments listed by an issuer
GET/v1/settlementssettlementsPage of settlements, newest first
GET/v1/transactions/{id}txStatusTransaction status
GET/v1/eventseventsUrlLive settlements and resync notices
POST/v1/admissionsrequestAdmissionRequest operator approval
POST/v1/faucetfaucetGet test USD and SOL on localnet
POST/v1/transactions/submitsubmitSubmit a wallet-signed transaction or signature
POST/v1/build/admitbuildAdmitBuild admit
POST/v1/build/depositbuildDepositBuild deposit
POST/v1/build/withdrawbuildWithdrawBuild withdraw
POST/v1/build/list-instrumentbuildListInstrumentBuild list instrument
POST/v1/build/issuebuildIssueBuild issue
POST/v1/build/post-offerbuildPostOfferBuild post offer
POST/v1/build/cancel-offerbuildCancelOfferBuild cancel offer
POST/v1/build/take-offerbuildTakeOfferBuild take offer
POST/v1/build/post-repo-offerbuildPostRepoOfferBuild post repo offer
POST/v1/build/cancel-repo-offerbuildCancelRepoOfferBuild cancel repo offer
POST/v1/build/take-repobuildTakeRepoBuild take repo
POST/v1/build/repaybuildRepayBuild repay
POST/v1/build/settle-defaultbuildSettleDefaultBuild settle default
POST/v1/build/pay-incomebuildPayIncomeBuild pay income
POST/v1/build/claim-incomebuildClaimIncomeBuild claim income

Reads are in API: reading the ledger; builds, submission, status, admission requests and the faucet in API: transactions.

Fixtures

Every route is also served under /fixture, against fixture data instead of the chain, with the same schemas. A client built against the fixtures works unchanged against the ledger. Choose a scenario with the X-Fixture header or the fixture query parameter (the header wins), and keep one fixture session per tab with X-Fixture-Session, so admission and submitted transactions persist within it. Naming an error code as the scenario returns that error with its status.

ScenarioWhat it serves
livelyFive instruments with two-sided books, registers, income, candles, repos and settlement history.
emptyAn empty ledger.
admission-noneThe wallet has never asked for admission.
admission-pendingThe wallet's request waits for the operator.
admitted-holderThe wallet is an admitted holder.
admitted-issuerThe wallet is an admitted issuer.
admission-rejectedThe operator rejected the wallet's request, with a reason.
account-emptyAdmitted, holding nothing.
account-fullAdmitted, with balances, offers, repos and activity.
waitingThe program waits for deployment. Builds answer PROGRAM_UNAVAILABLE.
tx-settlesSubmitted transactions confirm after a few status reads.
tx-failsSubmitted transactions fail with a named program error.

In fixture mode a build's transactionBase64 encodes a label, not a real transaction: relay it back unchanged to simulate a submission.