The Realm engine exposes a REST API built with FastAPI. Every client interaction — claiming a plot, placing a market order, proposing a contract, or advancing the simulation — goes through this API. The engine validates every request and either commits the action to world state or returns an error; it never applies partial changes.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/at6132/econ/llms.txt
Use this file to discover all available pages before exploring further.
All endpoints are served at
http://localhost:8000 in development. The engine runs on FastAPI with CORS allowed for localhost:3000.World & Tick
GET /health
Returns engine liveness. Use this to confirm the server is running before making other requests.Always
"ok" when the engine is running.GET /world
Returns the full public world state as a single JSON object. This is the primary data source for the web client — it includes plots, balances, inventory, market order books, contracts, event log, and more.The seed used to generate this world.
Current simulation tick (starts at 0, increments with each
POST /tick).The active scenario name (e.g.
frontier, genesis).All plots in the world grid.
Map of party ID → cash balance in cents.
Nested map of party ID → material ID → quantity.
Open sell orders, grouped by material ID.
Open buy orders, grouped by material ID.
All active contracts with their current state.
Last 120 engine events (most recent last).
Recent market price history snapshots (up to 160 entries, or full history if market intel is active).
Map of party ID →
{ chars, lines } for any deployed Lua sources (Phase 4 staging).POST /tick
Advances the simulation by one tick. Runs the full tick pipeline: transit delivery, building decay, production, spoilage, employment, Tier 1 agents, Tier 2 agents, Tier 3 LLM agents, clock advance, contract breach checks, financial contract processing, and market snapshot.true on success.The new tick number after advancing.
Plots
POST /plots//claim
Claims an unclaimed plot for a party.The plot ID to claim (e.g.
p-3-5).The party claiming the plot. Defaults to
"player".true on success. false with a reason field on failure (already claimed, unknown plot, etc.).POST /plots//survey
Reveals the subsurface composition of a plot the party owns. After surveying,GET /world will include subsurface grades and available recipe_ids for that plot.
The plot ID to survey.
The surveying party. Defaults to
"player".true on success.The plot’s terrain type.
Production recipe IDs now available on this plot.
POST /plots//produce
Starts a production run on a surveyed, owned plot using a specific recipe. The run completes after the recipe’sticks_required ticks.
The plot to produce on.
The recipe ID to run (must be valid for this plot’s terrain and subsurface).
The party initiating production. Defaults to
"player".true on success.ID of the active production run; appears in
world.active_production.POST /plots//build
Constructs a building on a plot. Thebuilding_id must be valid for the plot’s terrain. Use world.building_catalog from GET /world for available buildings.
The plot to build on.
The ID of the building to construct.
The party building. Defaults to
"player".Optional build mode modifier.
true on success.POST /plots//maintain
Resets the decay counter on a building instance, keeping it operational.The plot containing the building.
The building instance ID (from
world.plot_buildings).The maintaining party. Defaults to
"player".true on success.POST /plots//schematic/validate
Validates a proposed linear recipe chain against engine recipes and the party’s inventory. Returns whether the chain is feasible without executing it.The plot the chain would run on (must be owned and surveyed by the party).
The party proposing the chain. Defaults to
"player".true if the chain is valid and feasible.Present when
ok is false — explains why validation failed.Market
POST /market/sell
Places a limit sell order (ask) on the order book for a material.The selling party.
Material ID to sell (e.g.
iron_ore, grain, timber).Quantity to offer.
Ask price per unit in cents.
If set, only this quantity is visible on the book; the rest is hidden.
Minimum reputation score required for a buyer to fill this order. Defaults to
0.true on success.The new order’s ID.
POST /market/bid
Places a limit buy order (bid) on the order book for a material.The buying party.
Material ID to bid for.
Quantity to bid for.
Maximum price per unit in cents.
If set, only this quantity is visible on the book.
Minimum reputation score required for a seller to fill this order. Defaults to
0.true on success.The new bid order’s ID.
POST /market/buy
Market buy: immediately fills against the cheapest available asks up tomax_qty. Does not place a resting order.
The buying party.
Material ID to buy.
Maximum quantity to buy.
Minimum reputation score required for sellers. Defaults to
0.true on success.Total quantity filled across all matched asks.
POST /market/sell_fill
Market sell: immediately fills against the highest available bids up tomax_qty. Does not place a resting order.
The selling party.
Material ID to sell.
Maximum quantity to sell.
Minimum reputation score required for buyers. Defaults to
0.true on success.POST /market/cancel
Cancels an open sell (ask) order by order ID.The party that placed the order.
The order ID to cancel.
true on success.POST /market/cancel_bid
Cancels an open buy (bid) order by order ID.The party that placed the bid.
The bid order ID to cancel.
true on success.POST /market/intel
Purchases market intelligence for the requesting party. When active,GET /world returns the full market_history instead of the short free window.
The party purchasing intel. Defaults to
"player".true on success.The tick at which the intel subscription expires.
Trade
POST /trade/p2p
Executes a direct party-to-party trade: transfers materials from seller to buyer and cash from buyer to seller atomically.The selling party.
The buying party.
Material ID to transfer.
Quantity to transfer.
Total price for the entire quantity in cents.
Optional key to prevent duplicate trades on retry.
true on success. On failure, also returns reason and code.Contracts
POST /contracts/supply/propose
Proposes a supply contract: the supplier agrees to deliverqty of material to the buyer by due_in_ticks ticks from now, at total_price_cents.
The party supplying the material.
The party receiving the material.
Material ID to deliver.
Quantity to deliver.
Total contract price in cents.
Number of ticks from now until delivery is due.
Upfront deposit from the buyer. Defaults to
0.Penalty owed to the buyer if the supplier breaches. Defaults to
0.true on success.ID of the newly proposed contract.
POST /contracts/supply/accept
Accepts a pending supply contract. Must be called by the buyer.The buying party accepting the contract.
The contract ID to accept.
true on success.POST /contracts/supply/fulfill
Fulfills an accepted supply contract by delivering the material. Must be called by the supplier.The supplying party fulfilling the contract.
The contract ID to fulfill.
true on success.POST /contracts/loan/propose
Proposes a loan contract: the lender transfersprincipal_cents to the borrower, who must repay repay_cents within due_in_ticks ticks.
The lending party.
The borrowing party.
Loan amount in cents.
Total repayment amount (principal + interest) in cents.
Number of ticks until the loan is due.
true on success.ID of the new loan contract.
POST /contracts/loan/accept
Accepts a pending loan contract and transfers the principal to the borrower.The borrowing party accepting the loan.
The loan contract ID to accept.
true on success.POST /contracts/loan/repay
Repays an accepted loan contract.The borrowing party making the repayment.
The loan contract ID to repay.
true on success.POST /contracts/equity/propose
Proposes an equity-style contract: the investor paysinvestment_cents upfront and receives dividend_per_tick_cents per tick for dividend_ticks ticks.
The party issuing equity (receives the investment).
The investing party (receives dividends).
Upfront investment amount in cents.
Dividend paid per tick in cents.
Number of ticks over which dividends are paid.
true on success.ID of the new equity contract.
POST /contracts/equity/accept
Accepts an equity contract proposal. The investor’s payment transfers to the issuer.The investing party accepting the contract.
The equity contract ID to accept.
true on success.POST /contracts/service/propose
Proposes a service subscription contract: the provider offers access forfee_cents over duration_ticks ticks.
The party providing the service.
The subscribing party.
Total subscription fee in cents.
Subscription duration in ticks.
true on success.ID of the new service subscription contract.
POST /contracts/service/accept
Accepts a pending service subscription contract.The subscribing party accepting the contract.
The service contract ID to accept.
true on success.POST /contracts//honor
Marks a contract as honored by its ID. This is a general stub for contract resolution outside the type-specific endpoints.The contract to honor.
true on success.POST /contracts/propose
Generic contract proposal stub. Useful for proposing contracts by kind without the type-specific endpoints.The proposing party.
The counterparty.
Contract kind:
supply, loan, equity, or service. Defaults to "supply".Labor
GET /hire/catalog
Returns the public catalog of available hire-able roles and labor types.List of available labor roles.
POST /hire
Hires a worker (employee) for an employer, with a signing bonus and optional recurring wage.The hiring party.
The party being hired.
One-time signing bonus in cents paid immediately.
Recurring wage paid per tick. Defaults to
0.How often the wage is paid (in ticks). Defaults to
1.true on success.Movement
POST /ship
Dispatches a shipment of materials from one plot to another. The shipment entersworld.in_transit and arrives after a transit delay.
The party dispatching the shipment.
Material ID to ship.
Quantity to ship.
Origin plot ID.
Destination plot ID.
true on success.ID of the in-transit shipment; visible in
world.in_transit.Persistence
POST /persistence/save
Saves the current world state to a SQLite file. Defaults tosaves/realm_dev.sqlite in the repo root.
Absolute or repo-relative path for the save file. Omit to use the default.
true on success.The absolute path where the save was written.
POST /persistence/load
Replaces the current in-memory world with one loaded from a SQLite save file.Absolute or repo-relative path of the save file to load. Omit to use the default path.
true on success.The path the save was loaded from.
The tick number from the loaded save.
User Code
GET /code/status
Returns the user-code layer capability advertisement. Use this to check whether Lua is available, what the size limits are, and what phase the sandbox is in."stub" until the Phase 4 sandbox ships.Whether a Lua runtime (lupa) is available.
Maximum deploy source size: 256,000 UTF-8 bytes.
The environment variable required to enable eval:
"REALM_LUA_EVAL=1".Maximum eval chunk size: 8,192 bytes.
POST /code/validate
Statically validates a Lua source string — checks size and shape only, does not execute the code.true if the source passes static validation.UTF-8 byte count of the source.
Line count of the source.
Character count of the source.
POST /code/deploy
Deploys a Lua source string for a party. Validates size first, then stores the source inworld.deployed_lua_sources. This is a Phase 4 staging endpoint; execution is separate and gated.
true on success.The party the source was deployed for.
POST /code/eval
Runs a Lua chunk and returns the result. RequiresREALM_LUA_EVAL=1 environment variable and the lupa Python package.
true on success. false if the env var is missing, lupa is not installed, or the chunk errors.The return value of the Lua chunk (present when
ok is true).Error message (present when
ok is false).LLM Agents
GET /llm/status
Returns the LLM agent session status: model, spend, token counts, and per-agent summaries.Whether an Anthropic API client is configured.
The default model in use (e.g.
claude-haiku-4-5).Session spend cap in micro-dollars (1 = $0.000001).
Cumulative session spend in micro-dollars.
Remaining budget in micro-dollars, or
null if no cap is set.Per-agent summaries:
party, display_name, last_plan_tick, memory_preview.POST /llm/step
Runs one planning step for a named Tier 3 LLM agent. The agent reads the current world state, decides on actions, and executes them. RequiresANTHROPIC_API_KEY to be set.
The party ID of the LLM agent to step.
true on success. Returns HTTP 503 if no Anthropic client is configured.Dev
POST /dev/reset
Destroys the current in-memory world and bootstraps a fresh one from a named scenario and seed. For development use only — this is irreversible for the current session.Scenario name. One of:
frontier, cartel, bootstrapper, speculator, millrace, archive, genesis. Defaults to "frontier".RNG seed for world generation. Defaults to
42.true on success.The seed used to generate the new world.
The active scenario name after reset.