API overview
Base URL, wallet sessions and read-only agent keys, which actions are wallet-signed on-chain transactions, errors, rate limits and versioning.
The JSON API under /api is the read layer of Elysium Morning: an indexer over the contracts on Elysium mainnet (chain 99901). It serves cycles, proposals, the live auction, strategies, Pulse and portfolios. Writes are on-chain transactions that you sign with a wallet or an agent key and send to the contracts yourself; the API never holds funds or signs for you.
- Base URL
- https://<your-host>/api (dev: http://localhost:3030/api)
- Format
- JSON request and response bodies, UTF-8
- Amounts
- Plain numbers in whole units (HYPE, USDC). Fractions are 0–1.
- Times
- Unix milliseconds
- Mode
live: Elysium mainnet (chain 99901), real funds.GET /api/healthreportsmode.
#Authentication
| Method | How | Use for |
|---|---|---|
| Wallet session | GET /api/auth/nonce → sign with personal_sign → POST /api/auth/verify sets em_session (httpOnly, signed, 7 days) | The app, and scripts with a cookie jar: your account, portfolio, owner=me, mine on Pulse, display name, key management |
| Agent key | Authorization: Bearer em_… | Read-only monitoring bots: GET /api/account and GET /api/portfolio; scoped, rate-limited, logged |
| None | Public reads: health, chain config and status, stats, cycle, templates, market, proposals, auction, strategies, quotes, activity, builders, stream |
State-changing requests from browsers must come from the app's own origin (CSRF guard). Requests without an Origin header (curl, servers) are accepted with a valid cookie. Sessions are wallet-only.
#On-chain actions
Everything that moves funds or changes protocol state is a contract call. The matching REST routes still exist, but they always answer 409 onchain_required (before authentication, before any state is read). Use them as a map from the app's actions to the contract functions:
| REST route (409) | Contract call from your wallet |
|---|---|
POST /api/proposals | DawnScheduler.propose(templateId, params, metadataURI) with the 25 HYPE bond as msg.value |
POST /api/proposals/:id/withdraw | DawnScheduler.withdrawProposal(id) |
POST /api/proposals/:id/vote | DawnScheduler.vote(id) |
POST /api/bids | DawnScheduler.bid(id) with the bid as msg.value (raises on repeat) |
DELETE /api/bids/:id | DawnScheduler.cancelBid(id) |
| (after the auction) | DawnScheduler.settle(dawnId), settleBid(id, bidder), then withdraw() for refunds and bonds |
POST /api/strategies/:id/swap | swapHypeForQuote(minOut, to) or swapQuoteForHype(amountIn, minOut, to) on the strategy |
POST /api/strategies/:id/join | addLiquidity(maxQuote, minShares) on the strategy |
POST /api/strategies/:id/exit | removeLiquidity(shares, minHype, minQuote) on the strategy |
POST /api/strategies/:id/mutate | ForgeFactory.mutate(strategy, data) by the owner or an agent authorised with setAgent |
POST /api/strategies/:id/sunset | ForgeFactory.sunset(strategy) by the owner |
POST /api/pulse/claim | PulseVault.claim(strategies[]) |
GET /api/chain/config. Phase rules apply on-chain exactly as in the dawn cycle.#Agent keys
| Credential | What it can do through the API |
|---|---|
em_… key | GET /api/account, GET /api/portfolio as the owning wallet. Calls count against ratePerHour. Everything else needs a wallet session or is public. |
| Agent address on-chain | ForgeFactory.mutate on strategies where the owner registered it with setAgent(strategy, agent, callsPerHour, selectors). Bounds, selector allow-list and the hourly cap are enforced by the contracts. |
propose, bid and mutate scopes on a key are recorded but give no write access in live mode. See Agent keys.#Errors
Errors use a proper HTTP status and a JSON body with a human message and a stable machine code. Branch on code, never on error text.
{ "error": "This action is an on-chain transaction; sign it with your wallet.", "code": "onchain_required" }| Status | Code | Meaning |
|---|---|---|
| 400 | bad_json · bad_request | Malformed body or invalid field |
| 401 | unauthenticated · invalid_key · bad_signature · nonce_expired | No or bad credentials; revoked key; bad or expired sign-in |
| 403 | forbidden · missing_scope | Authenticated but not allowed (cross-origin write, key used on a route it cannot read) |
| 404 | not_found | Unknown id, or no Pulse epoch yet |
| 409 | onchain_required · sunset · unsupported_template | Wallet-signed action; strategy retired; quote not available for this template |
| 422 | out_of_bounds | Valid request the rules reject (for example slippageBps outside 0–5000) |
| 429 | rate_limited | Too many calls; honour Retry-After |
| 500 / 503 | internal · market_unavailable | Server or upstream failure; retry with backoff |
#Rate limits
- Agent keys:
ratePerHourper key, chosen at creation. Every call counts, reads included. - Sessions and anonymous reads: a per-IP budget that is generous for interactive use; quotes are limited more tightly.
- On-chain mutations are rate-limited by the contracts, per agent (
callsPerHour, max 120) and in the strategy's own bounds. - Exceeding an API limit returns
429 rate_limitedwith aRetry-Afterheader in seconds.
#Freshness
REST views are built by an indexer that follows the chain. Check GET /api/chain/status (lagBlocks, degraded) before acting on a view, and read contract state directly (getProposal, scoreOf, previewWinners, claimable) when you need the authoritative value.
#Versioning
The API is unversioned. Changes are additive (new optional fields, new endpoints) and listed in the changelog. Ignore unknown fields. A breaking change will be announced and served under /api/v1.