Resources
Resources (wood, stone, food, …) are the currency of the game: buildings and units cost them, and your towns produce them over time. The exact set of resources, their starting amounts, storage caps, and any terrain bonuses are defined per realm in the world config; on the shipped realms production bonuses come from held valleys, not from the tile a town stands on.
Rather than hard-coding resource ids in your client, fetch them from the catalog. The ids returned here are the canonical resource ids used everywhere else in the API — building and unit costs, trade offers, and the resource balances on your towns.
List Resource Types
GET /api/v1/resources/
Requires a realm token. Returns every resource in the current realm.
Supports limit and offset query parameters for pagination (limit defaults to 50, max 200; offset defaults to 0).
import httpx
resources = httpx.get( "http://localhost:8731/api/v1/resources/", headers={"Authorization": f"Bearer {realm_token}"},).json()curl http://localhost:8731/api/v1/resources/ \ -H "Authorization: Bearer $REALM_TOKEN"const res = await fetch("http://localhost:8731/api/v1/resources/", { headers: { Authorization: `Bearer ${realmToken}` },});const resources = await res.json();Response: the standard pagination envelope { "count", "limit", "offset", "results" }, where count is the total number of resources in the realm and results holds the resource catalog for the requested page.
{ "count": 2, "limit": 50, "offset": 0, "results": [ { "id": "wood", "starter_amount": 500, "max_storage": 100000, "tile_bonuses": {} }, { "id": "food", "starter_amount": 300, "max_storage": null, "tile_bonuses": {} } ]}| Field | Meaning |
|---|---|
id | Canonical resource id, used in all other endpoints |
starter_amount | Amount a newly founded town begins with |
max_storage | Per-resource storage cap; null means unlimited. Production beyond the cap is discarded |
tile_bonuses | Map of tile-type id → production multiplier a town standing on that terrain gets for this resource (e.g. 1.5 = +50%). Empty for every resource on the shipped realms: a town’s own ground grants nothing, and terrain only decides where valleys are seeded. Where a realm does set one, it multiplies with the town’s held valleys |
Production bonuses on the shipped realms come from held valleys, research that boosts that town’s production, and an appointed Mayor (+1% per point of Politics on every resource while they are idle in the town). The three are one additive sum off the buildings’ rate — own_ground × (1 + research + Politics + Σ held valley bonuses), with own_ground 1 unless tile_bonuses says otherwise — see The bonus on your production, the per-type table on GET /api/v1/valleys/types and the production formula. See the glossary for how that and storage caps interact with production.
starter_amount and max_storage above are not affected by a realm’s pace — only how fast a resource accrues changes with time_scale, not the amounts themselves. The production period behind that rate — revenue_seconds on each entry in the building catalog — is reported already scaled, so you can compute a resource’s rate directly without knowing the realm’s time_scale.
Whole units, and the part in progress
Balances are always whole units. Production accrues continuously, and every settle — a collect, a build, a march, any action on the town, or a job finishing — banks the whole units completed since the last one and carries the part of a unit still in progress to the next settle. Upkeep works the same way: a unit of food leaves the larder once it has been fully eaten, and the part being eaten is carried over and paid first. Tax gold, which arrives on the tick, carries the same way. So how often a town is read, collected or otherwise touched never changes what it earns, nor what a garrison its food can feed eats: a level-1 Farm settled every few seconds makes exactly the 100 food an hour it makes when nobody touches it for a day, a town paying a third of a gold a tick collects a gold every three ticks however often it is read, and a small garrison polled often pays every crumb it eats. A garrison that runs out of food is the one exception — how many units desert at once does depend on the settles. The carried part is not shown — it is always less than one unit — and it never counts toward a cost.
Production boosters
Eight items raise one resource’s production in one town for a fixed window — +25% each, 24 hours or 7 days:
| Resource | 24 hours | 7 days |
|---|---|---|
| Food | Plowshares | Iron Rake |
| Wood | Arch Saw | Double Saw |
| Stone | Quarrying Tools | Adv Quarrying Tools |
| Iron | Blower | Blast Furnace |
The boost is summed with every other production bonus that town has — research, an active mayor’s Politics, the valleys it holds — never compounded on top of them, which is the same rule those three already follow between themselves. A town with +50% from research and a Plowshares running produces at +75% of base, not +87.5%.
Two boosters on the same resource do not add up: the larger applies and the second extends the window (see Timed buffs). Two boosters on different resources are independent and both count.
It never reaches backwards, and it stops paying the moment it lapses, prorated. Both halves of that matter:
- Using one settles the town first, so the hours that had already accrued are paid at the old rate. A booster cannot reward you for the week before you used it.
- A window is only ever credited for the part of it the booster actually covered. Use a Plowshares and then leave the town alone for 25 hours and you are paid +25% on the first 24 and nothing on the 25th — you do not have to log in at the right moment to collect, and you are not paid for time after it ran out either.
The production rate on GET /api/v1/state/ is a
rate — “per second, right now” — so it shows the booster’s full +25% while
the window is open and drops to base the moment it closes. The resources
on the same response are what has already accrued, so they carry the
prorated share. Those are two different questions with two different
honest answers, not a disagreement.
Wealthy Society: the production-rate quests
The wealthy quest line reads exactly this rate —
one town’s production for the resource, as shown above, boosters
included. Sixteen quests ask for 1,000/5,000/10,000/50,000 food, wood,
stone or iron per realm hour in one town; four more ask for 500/1,000/
5,000/10,000 gold in tax per realm hour. “Per realm hour” matters on a
faster realm: the target is the same number of resource units per the
realm’s own hour (its time_scale-adjusted hour), not a real-world hour,
so a faster realm’s quest is no easier to reach than a normal-paced one’s —
production itself is correspondingly faster there too. Each resource’s
first rung also pays that resource’s 24-hour booster item (Plowshares,
Arch Saw, Quarrying Tools, or Blower) — the same item that can help a town
reach a later rung’s target while it’s active. Completion follows the
ordinary quest rule: the first time your quest list or a claim observes the
boosted rate, it is recorded for good, even after the boost ends — open the
quest list while the booster is running to lock it in.
Food upkeep & desertion
Food is not a one-way accrual. Every unit sitting in a town’s garrison continuously eats food, hourly, for as long as it stays there — including allied Support hosted through an Embassy, which adds its upkeep to the host town, not the town that sent it. A town’s food balance always reflects farm production net of that upkeep, not gross production alone.
Each unit type has its own food_upkeep_per_hour in the realm’s unit catalog — heavier, more capable units generally cost more to feed. A town’s total hourly upkeep is the sum of food_upkeep_per_hour × count across every unit in its garrison. That total is published directly, per town, as food_upkeep_per_hour on TownResponse and TownStateResponse — see TownResponse fields for where it appears (GET /api/v1/towns/, GET /api/v1/towns/{id}, and GET /api/v1/state/).
Desertion is what happens when a garrison can’t be fed. Food never goes negative to cover upkeep — instead, if the food available for an elapsed stretch of time can’t cover what the garrison would eat over that same stretch, whole units leave the garrison until it can. An empty larder still feeds a garrison until the town owes a whole unit of food: the part of a unit it has started eating is carried as a debt (the balance shows 0), paid first from the next food the town makes, and the garrison deserts once that debt reaches one food, however often the town is settled in between. How many units leave at that moment does depend on the settles. Desertion covers the stretch being settled: a short stretch that starts already owing most of a food leaves almost no room, so a town settled often can shed up to the whole deficit’s worth of units at once, while one settle across a long stretch counts its deserters as gone from the stretch’s start, forgives their upkeep and sheds fewer. Either way the garrison settles at what the town’s food can sustain:
- Units desert one at a time, cheapest-to-feed first (ascending
food_upkeep_per_hour, ties broken byunit_type_id) — protecting your most valuable troops the longest. - Desertion is deterministic: no randomness is involved, ever.
- It stops the instant the remaining garrison’s upkeep is affordable again for the stretch being settled — never more units than that stretch strictly needs.
- A unit type with
food_upkeep_per_hourof0(for example a dedicated scout) never deserts for food — it can’t reduce the shortfall. - A town that somehow already carries a negative stored food balance (an edge case from before desertion shipped) never loses more than the elapsed stretch’s own upkeep: desertion is judged against the food actually available for that stretch (the stored balance floored at
0, plus the carried part of a unit, plus what the town produced during it), and the old deficit is simply written off to0. - Losing units this way is logged to your town’s event log as a
desertionevent, naming which units left and how many.
A well-supplied town — enough Farms, a low enough garrison, or both — never sees desertion; it is purely a consequence of running a garrison your food production can’t sustain.
Upkeep follows the garrison hour by hour. Whenever a town’s garrison changes because units march — an attack, a scouting party or a reinforcement leaving, a party coming home, allied support landing at or leaving a host town, a founding party bounced back — the town is settled first, at the garrison it had until that moment. So the hours before a party left are charged for it and the hours it was away are not, whoever collects and whenever: a march never makes a collect pay or forgive upkeep for units that were out of the garrison at the time. (The same settle is what banks a mayor’s bonus only for the hours the mayor was actually home.)
A battle settles the town it lands on first. Every battle at a player’s town, win or lose, settles the town before it is fought, so any desertion accrued since the last settle happens first: the units that left for hunger do not fight, and the upkeep for the stretch since the last settle is charged to the garrison that stood through it, including the units the battle then kills. The raid’s loot comes from that settled balance (see Raiding).
Marching a starving army out does not save it. Because a dispatch settles its origin before it counts the troops you asked to send, any desertion the town has accrued since it was last settled happens first, and the dispatch is checked against what is left. A town that has run out of food can therefore show more troops than it can send: sending all of them is refused with 400 Insufficient units: need N, have M, where M is the garrison after that desertion. The number of troops shown for a town (/state, GET /api/v1/towns/) is the garrison as of its last settle, not a projection, so it does not reflect desertion that has accrued but not yet been settled — feed the town (or send fewer troops) rather than retrying.
Levels change at the finish instant
Every queued job that changes what a town produces or eats — a building upgrade or construction, a research level, a training order, a healing order — takes effect at its own finished_at, not at the moment the server applies it and not at your next collect. When the resolver (or the lazy completion in a build, research or GET /api/v1/units/ request) applies a finished job, it first settles the town up to the finish time at the state the town had until then, and only then changes the level or the garrison. So:
- an upgrade or research level finishing an hour into a three-hour stretch you never collected pays the old rate for the first hour and the new rate for the two after it — never the new rate for all three;
- trained or healed units are charged upkeep from the instant they joined the garrison, never for the hours before;
- several jobs finishing at different times inside one stretch each close their own segment, in the order they finished, whichever of them the server happens to apply first.
The settle at the finish time is a real settle: it banks the whole resources completed by that instant like any collect does (the part of a unit in progress carries on into the next segment, so the split itself costs nothing), and it applies any desertion the town had accrued by then. If a collect (or a march, or any other settle) happened between a job’s finish and the moment it is applied, the stretch between the two was already settled at the old state and stays that way. That gap is the server’s lag: normally under one resolver tick (5 seconds), longer only when your town happened to be busy with another request at the moment the resolver looked (it skips a busy town and comes back on the next tick) or when a large backlog of finished jobs is being worked through. For an upgrade or a research level the old state is the old rate, so you lose that stretch’s extra production. For trained or healed units it runs the other way: the stretch is settled without them, so their upkeep over it is never charged — a small gain, at most a few seconds of their food. A job that finishes never pays its new state backwards over the time before it finished.
If one of a town’s finished jobs cannot be applied because of a server-side error, the resolver sets that town aside and retries it every few minutes. Other towns’ jobs keep completing on time. When the job is finally applied, it still takes effect at its own finish time.