Roads terrain cache
The /roads/* HTTP API serves dense per-region terrain grids,
paving overlays, global paving/terraform catalogs, and a hex-list
harvestable lookup as
protobuf only (Accept: application/x-protobuf).
It is separate from the JSON-friendly /claim /
/player relay-cache API documented in
relay-cache joins, though both are fed by
the same embedded mirror process on the relay host.
What it provides
For each live BitCraft region the cache maintains:
-
A super-hex terrain grid (elevation, original elevation,
water level, water-body type) built from
terrain_chunk_state. -
A small-hex overlay grid (paving type + claim index per
tile) built from
paved_tile_state,claim_tile_state,claim_state, andlocation_state. -
Global catalogs from
paving_tile_descandterraform_recipe_desc, plus region metadata fromworld_region_state/region_name_state.
The heavy endpoint is
GET /roads/region/<id>/map, which returns one atomic
RegionMapSnapshot protobuf per request (~280 MiB).
See Region map format for grid layout,
coordinate math, and cell bit-packing. Harvestable trees/ore/rocks are
not in that snapshot — use
POST /roads/region/<id>/resources
with the hexes you care about (max 16 384 per request).
Recommended client workflow
-
Poll fleet readiness —
GET /roads/healthuntilreadyis true and your target region’sstateisREADY(3). -
Fetch region catalog —
GET /roads/regionsfor live flags, grid coords (rx,rz), and world origins. -
Load global catalogs once —
/roads/paving-typesand/roads/terraform-recipes(small, cache locally). -
Download region map —
GET /roads/region/<id>/map. Store theETagheader; on refresh sendIf-None-Matchto receive304 Not Modifiedwhen nothing changed. While a region is still loading the server returns202 Acceptedwith an empty body. -
Look up harvestables on planned tiles —
POST /roads/region/<id>/resourceswith a protobufResourceQueryof world small-hex(x, z)tiles. See Hex resources.
Endpoint reference
Base URL: https://relay.bitcraftsync.app.
All responses use Content-Type: application/x-protobuf.
| Endpoint | Protobuf message | Notes |
|---|---|---|
| GET /roads/health | roads_cache.RoadsCacheHealth |
Top-level ready, regions_ready /
regions_total, total_memory_bytes.
Each region row: state
(idle=1, loading=2, ready=3, error=4), connected,
timestamps, tile counts, memory_bytes,
optional error string.
|
| GET /roads/regions | bitcraft.roads.RegionsResponse |
All known regions with id, name,
live, grid position (rx, rz),
world origin (origin_x, origin_z).
Also region_width_chunks and
region_height_chunks (typically 80).
|
| GET /roads/paving-types | bitcraft.roads.PavingTypesResponse |
Global paving catalog: tile_type_id, name, duration,
tier, input cargo, consumed material stacks
(item_id, quantity, cargo bool).
Overlay cells store tile_type_id in bits 0–15.
|
| GET /roads/terraform-recipes | bitcraft.roads.TerraformRecipesResponse |
Height-difference keyed recipes: difference,
actions_count, stamina_per_action,
time_per_action.
|
| GET /roads/region/<id>/map | roads_cache.RegionMapSnapshot |
Full region snapshot. Unknown region → 404.
Still loading → 202 empty body.
Ready → 200 + ETag header.
Format details:
Region map format.
|
| POST /roads/region/<id>/resources | roads_cache.ResourcesResponse |
Body: ResourceQuery { repeated Hex tiles },
max 16 384. Returns sparse
ResourceNode { x, z, resource_id } for allowlisted
forestry/mining/clay/sand nodes on those tiles
(overworld only). Unknown region → 404.
Still loading → 202 empty body.
Oversize / invalid protobuf → 400.
Details: Hex resources.
|
Protobuf schemas
Listed alongside relay_cache.proto on
GET /proto:
roads_cache.proto— fleet health, region map snapshot, hex resource lookuproads.proto— regions, paving types, terraform recipes
Example requests
# Fleet readiness (decode with roads_cache.proto)
curl -sH 'Accept: application/x-protobuf' \
https://relay.bitcraftsync.app/roads/health -o roads-health.pb
# Region catalog
curl -sH 'Accept: application/x-protobuf' \
https://relay.bitcraftsync.app/roads/regions -o regions.pb
# Global catalogs (cache on disk — change rarely)
curl -sH 'Accept: application/x-protobuf' \
https://relay.bitcraftsync.app/roads/paving-types -o paving.pb
curl -sH 'Accept: application/x-protobuf' \
https://relay.bitcraftsync.app/roads/terraform-recipes -o terraform.pb
# Full region map (~280 MiB) — save ETag from response headers
curl -sH 'Accept: application/x-protobuf' -D /tmp/headers.txt \
https://relay.bitcraftsync.app/roads/region/14/map -o region14.pb
# Conditional refresh (replace with ETag value from prior response)
curl -sH 'Accept: application/x-protobuf' \
-H 'If-None-Match: abc123…' -D /tmp/headers2.txt \
https://relay.bitcraftsync.app/roads/region/14/map -o /dev/null
# Harvestables on a hex list (encode ResourceQuery as query.pb)
curl -sH 'Content-Type: application/x-protobuf' \
-H 'Accept: application/x-protobuf' \
--data-binary @query.pb \
https://relay.bitcraftsync.app/roads/region/14/resources -o resources.pb
# Download .proto sources
curl -s https://relay.bitcraftsync.app/proto
curl -OJ https://relay.bitcraftsync.app/proto/roads_cache.proto
curl -OJ https://relay.bitcraftsync.app/proto/roads.proto