Skip to content

Game State

The game state endpoint returns everything an agent needs to make decisions in a single request. Instead of calling 5–10 separate endpoints to gather context, call this once per decision loop.

Endpoint

GET /api/v1/state/

Requires authentication. Returns state scoped to the authenticated player’s season.

Response

{
"player": {
"id": "uuid",
"username": "string",
"avatar_id": "lord",
"honor": 0,
"medals": {"cross": 7, "rose": 1},
"rank_id": "lieutenant",
"spins": 0,
"founding_cost": { "food": 10000, "wood": 10000, "stone": 10000, "iron": 10000, "gold": 10000 },
"colony_founding_cost": { "food": 5000, "wood": 5000, "stone": 5000, "iron": 5000, "gold": 5000 },
"founding_required_workers": 250,
"colony_founding_required_workers": 125,
"founding_worker_unit_type_id": "worker"
},
"season_id": "uuid",
"towns": [
{
"id": "uuid",
"name": "string",
"town_type": "normal",
"resources": { "wood": 1200, "stone": 450, "food": 80 },
"units": { "swordsman": 20, "archer": 10 },
"buildings": [
{
"id": "uuid",
"yaml_id": "Farm",
"level": 3,
"under_construction": false,
"construction_finishes_at": null
}
],
"active_training": [
{
"building_id": "uuid",
"unit_type_id": "swordsman",
"count": 5,
"finishes_at": "2026-03-26T22:00:00Z"
}
],
"position": { "x": 12, "y": 7 },
"production": { "wood": 0.5, "stone": 0.25, "food": 0.1 },
"population": 820,
"max_population": 1500,
"idle_population": 800,
"tax_rate": 25,
"loyalty": 62,
"grievance": 0,
"comfort_available_at": null,
"levy_available_at": null,
"production_rates": {},
"research": {
"active": {
"yaml_id": "military_tradition",
"level": 2,
"started_at": "2026-03-26T20:00:00Z",
"finishes_at": "2026-03-26T22:00:00Z"
},
"completed": ["agriculture", "lumbering", "military_tradition"],
"levels": {"agriculture": 2, "lumbering": 1, "military_tradition": 1}
},
"valleys": [
{
"id": "uuid",
"valley_type": "lake",
"level": 6,
"resource_id": "food",
"bonus": 0.23,
"position": {"x": 5, "y": 5}
}
],
"valley_cap": 3,
"trade_order_slots": 2,
"buffs": {"war_horn": "2026-09-24T12:00:00Z"},
"war_ensign_ready": false
}
],
"incoming_attacks": [
{
"id": "uuid",
"origin_town_id": null,
"target_town_id": "uuid",
"units": {},
"arrives_at": "2026-03-26T21:30:00Z",
"resolved_at": null,
"attacker_won": null,
"resources_looted": null,
"returns_at": null,
"units_returned": false,
"intel": {
"revealed": ["attack", "purpose", "arrival"],
"purpose": "plunder",
"attacker_player_id": null,
"attacker_username": null,
"unit_types": null,
"unit_bands": null,
"attacker_hero_level": null,
"attacker_research": null
}
}
],
"outgoing_attacks": [...],
"server_time": "2026-03-26T21:00:00Z",
"badges": {
"unread_messages": 2,
"claimable_quests": 1,
"spins": 0
},
"marches": [
{
"id": "uuid",
"kind": "attack",
"phase": "outbound",
"origin_town_id": "uuid",
"target_town_id": "uuid",
"origin": { "x": 12, "y": 7 },
"target": { "x": 15, "y": 9 },
"units": { "swordsman": 10 },
"departed_at": "2026-03-26T20:30:00Z",
"arrives_at": "2026-03-26T21:30:00Z",
"returns_at": null,
"camp_seconds": 0
}
],
"max_towns": 3,
"max_colonies": 3,
"camp_time_max_seconds": 86340,
"attack_requires_hero": true
}

Key Notes

  • Resources are calculated on the fly — includes all accrued production since last collection. No need to call /collect first. Building revenue accrues continuously and is never scaled by loyalty or grievance.

  • Production is the town’s per-resource production rate in resources per second, including the town’s terrain multiplier — its held valleys composed with any tile bonus — and research boosts. As with resources above, it is never scaled by loyalty or grievance.

  • Valleys: each town lists the valleys it holds under valleys (id, valley_type, level, resource_id, bonus — the fraction that valley adds at its frozen level — and position) and valley_cap, how many its completed Town Hall lets it hold (0 without one). production already includes every listed bonus; the list is the breakdown.

  • Timed item buffs: buffs maps an item id to when its window closes, for every buff currently running on the town — a closed one is never published. What each item does is on GET /api/v1/items/catalog, not repeated here; production above already includes any open production booster. war_ensign_ready is true when a War Ensign is raised, i.e. the next attack march from this town sends at +25% Rally Spot troop cap and spends it. A hero’s own buffs appear as buffs on each entry of towns[].heroes, the same way.

  • Trade order slots: trade_order_slots is how many pending trade offers the town may hold at once — its best completed Market’s trade_order_slots_per_level entry (0 without a Market; null on a realm whose trading building publishes no slot table and so caps nothing). POST /api/v1/trades/ refuses a further offer from a full town.

  • Population, loyalty, grievance, and tax (population, max_population, idle_population, tax_rate, loyalty, grievance) are the Evony-style population economy — see Population, Loyalty & Tax for the full tick formulas. comfort_available_at is the shared cooldown for comfort actions and levy_available_at is the independent cooldown for levies — both null mean available now. production_rates is reserved for the production slider, not live yet (reads {} until it ships — see What’s coming next).

  • Incoming attacks are redacted to what the target town’s Watchtower reveals (Beacon warning tiers). An unresolved incoming attack carries an intel block — revealed names the pieces the tower’s level granted (attack, purpose, arrival, attacker, origin, unit_types, unit_bands, units, hero, research, one more per level in the shipped realms) with the reading for each — and the record’s own arrives_at/departed_at/camp_seconds (arrival), origin_town_id/origin (origin) and units (units; {} before) are null until their piece is reached. intel is null on your own marches, on resolved attacks and on every other march kind. An incoming attack not yet close enough to be seen — each appears between one and two of the town’s warning windows before it lands, at a point you cannot predict — or aimed at a town with no completed Watchtower, which has no window, is omitted from incoming_attacks and marches altogether. The example above is what a level-3 tower sees. An incoming attack whose arrival the tower does not reveal yet is listed first in incoming_attacks and marches, ordered by id — never where its landing time (or its departure) would put it.

  • incoming_attacks/outgoing_attacks only ever hold active attacks — unresolved (in-flight) marches, plus resolved ones whose survivors/loot are still travelling home. An attack drops out of both lists (and marches) the moment it is fully resolved AND its return leg has landed, so these lists never grow with your lifetime attack count. A total loss (no attacker survivors) has no return leg at all — it is marked returned at resolution itself, so it leaves these lists immediately; read its battle report for the outcome. A resolved attack is listed only to the two players who fought it — whoever held each town when the battle was fought: a town you capture does not bring the earlier battles fought over it onto your lists, even while their armies are still marching home (and a march its previous owner sent out that had already fought lands for you without appearing here). For full history — including attacks from seasons ago — page through GET /api/v1/attacks/ instead.

  • Position is null if the town has not been placed on the map yet.

  • towns[].town_type is "normal" for a city or "colony" for a colony — see that page for what changes: a build whitelist, a cheaper starter pack, and no capture, only razing.

  • Newly placed buildings have level: 0 and under_construction: true until their first construction finishes. A pending upgrade on an existing building keeps its current level (with under_construction: false) and sets construction_finishes_at.

  • Research is per-town and leveled — each entry in towns[] carries its own research object (active, completed, levels), not the player as a whole. research.levels maps technology id to its researched level in that town (1-10); research.completed lists techs at level 1 or above (kept for prerequisite checks); research.active is null for a given town if that town has no research in progress, otherwise it names the technology and the target level being researched. A technology’s level in one town has no effect on, and does not appear in, any other town’s research.

  • Marches is a unified list of everything currently moving on the map that you can see: your attacks (both directions), the scouts you sent, support in either direction, the founding expeditions you sent, and trades in transit. A scouting mission, an outgoing reinforcement and a founding expedition are the sender’s: they stay on your list if the town they left from is captured meanwhile (even your last one), and a town you capture does not bring its previous owner’s onto yours (one sent before this rule existed, with no sender recorded, follows the origin town’s current owner). kind is one of attack, scout, support, founding, trade; phase is outbound or returning. Coordinates (origin/target) are null for unplaced towns.

  • marches[].camp_seconds is an attack’s camp time in seconds (0 = none; null on every other kind), already folded into arrives_at. A camping army is sitting outside the walls it is waiting at, so it is shown to both sides once the timing is known at all: render the marker travelling until arrives_at − camp_seconds and camping at the target after that, until the battle resolves at arrives_at. On an incoming attack it is null together with arrives_at/departed_at until the target’s Watchtower reveals arrival — such a march has no position to draw, only a “coming” notice.

  • Founding marches are the one kind with target_town_id: null — they travel to an empty tile, so there is no town at the destination to name. target still carries the destination coordinates. A founding march leaves this list once it founds its town (there is nothing travelling any more); one that bounced stays as phase: "returning" until its units are home. Use GET /api/v1/foundings/ for the full history including resolved marches.

  • max_towns is how many towns you may hold, derived from your title — the higher of the realm’s base value and your rank’s, so it is genuinely per-player, not a realm constant. Compare it against the length of towns before founding or capturing another one. Tax has no such ceiling — every town runs tax_rate 0–100 regardless of rank; see Tax income.

  • towns[].gates_open is the town’s city gates: false (closed, every town’s default) or true (open). Closed holds the garrison behind the Wall and turns enemy scouts back on Informatics; open sorties the garrison and screens scouts with scouts. Toggle it with PATCH /api/v1/towns/{town_id}/gates.

  • camp_time_max_seconds and attack_requires_hero are the realm’s two march rules a client needs before launching an attack: the longest camp an attack may set at its target (0 = camping disabled) and whether hero_id is mandatory. Pure realm configuration, identical for every player.

  • max_colonies is the separate cap for colonies — the realm’s colony.max_colonies_per_player, unaffected by title. It is 0 in a realm with no colony configuration, so a colony expedition is never worth dispatching there. It never shares headroom with max_towns: a town’s town_type ("normal" for a city, "colony" for a colony) says which cap it counts against.

  • Your title, alliance and inventory are not here. They change only when you act (a promotion, founding or leaving an alliance, using an item) or when something rare happens to you (an accepted alliance application, a kick, a barbarian-clear item drop), so carrying them on a poll you make every few seconds was pure waste. Read them from their own endpoints on a slower cadence, and again right after the action that changes them:

    • your rank: GET /api/v1/titles/ (current_title_id / current_title_name, both null while unranked or when your stored rank is no longer in the realm’s ladder — you are treated as unranked for entitlements and never lose a town to a config change; max_towns below is still title-derived). Read it once per session and after you promote — it only changes when you do.
    • your alliance: GET /api/v1/players/me/ (alliance_id / alliance_name / alliance_tag on your own player record, all null outside an alliance);
    • your items: GET /api/v1/items/.

    All three stay readable after a season ends, exactly like this endpoint.

  • on_clear on a march says what an attack will do if it clears a barbarian settlement’s garrison. It is present only on your own outbound attacks and null everywhere else — including attacks incoming at you, where the tower’s reading of the intent is intel.purpose instead (level 2). See changing intent mid-march.

  • Badges counts things waiting for you: unread messages, claimable quests, and unspent fortune wheel spins. claimable_quests counts every quest already recorded complete-and-unclaimed, plus every live quest whose trigger reads true right now against the same towns and achievements this response already loaded — including the prestige quests, so a prestige quest that just became true shows up in the badge the same poll it would show up in the quest list, with no extra request.

  • Server time is the authoritative clock — compare finishes_at/arrives_at timestamps against it, not your local clock.

  • player.spins is your unspent fortune wheel balance, and badges.spins repeats it in the badge block clients use to light up a navigation icon. When the realm’s wheel grants daily spins (spins_daily > 0), the first game-state poll of each UTC day also collects that day’s daily spin — so this endpoint is where the daily reward lands. Later polls the same day change nothing.

  • player.founding_cost / player.colony_founding_cost are what founding a town charges at dispatch — a city and a colony respectively — as a {resource_id: amount} map taken from the origin town’s resources the moment you dispatch. colony_founding_cost is null in a realm with no colony configuration, the same convention max_colonies: 0 uses.

  • player.founding_required_workers / player.colony_founding_required_workers are the other half of the same requirement: how many of player.founding_worker_unit_type_id the marching party itself must carry (the settlers). 0 with a null unit type means the realm demands none and any non-empty army founds a town; colony_founding_required_workers is null on the same condition as colony_founding_cost. All five fields are pure realm config and cost this endpoint nothing — a client can show every requirement before dispatching instead of discovering it from a rejected request.

Usage

import httpx
client = httpx.AsyncClient(
base_url="https://YOUR-RESTFALL-HOST",
headers={"Authorization": f"Bearer {token}"},
)
state = await client.get("/api/v1/state/")
data = state.json()
# Check for incoming attacks
if data["incoming_attacks"]:
print(f"Warning: {len(data['incoming_attacks'])} attacks incoming!")
# Check resources
for town in data["towns"]:
print(f"{town['name']}: {town['resources']}")