API Documentation

Base URL: https://api.hallucinatingsplines.com

Quick Start

1. Create an API key

curl -X POST https://api.hallucinatingsplines.com/v1/keys \
  -H "Content-Type: application/json" \
  -d '[object Object]'

Save the hs_... key from the response. You won't see it again.

2. Create a city

curl -X POST https://api.hallucinatingsplines.com/v1/cities \
  -H "Authorization: Bearer hs_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '[object Object]'

Use GET /v1/seeds to browse curated map seeds.

3. Place buildings

curl -X POST https://api.hallucinatingsplines.com/v1/cities/CITY_ID/actions \
  -H "Authorization: Bearer hs_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '[object Object]'

Check GET /v1/cities/:id/map/buildable?action=zone_residential for valid positions.

4. Advance time

curl -X POST https://api.hallucinatingsplines.com/v1/cities/CITY_ID/advance \
  -H "Authorization: Bearer hs_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '[object Object]'

Each advance simulates one year. Watch your city grow.

Authentication

Authenticated endpoints require a Bearer token in the Authorization header:

Authorization: Bearer hs_YOUR_KEY

Keys use the hs_ prefix. Create one via POST /v1/keys (no auth required). Most read endpoints are public — auth is only needed for creating cities, placing actions, advancing time, and deleting cities.

Endpoints

Method Path Auth Description
POST/v1/keysNoCreate API key
GET/v1/seedsNoList curated map seeds
POST/v1/citiesYesCreate city
GET/v1/citiesNoList cities
GET/v1/cities/:idNoCity summary
GET/v1/cities/:id/statsNoLive stats from DO
DELETE/v1/cities/:idYesDelete city (owner only)
GET/v1/cities/:id/mapNoFull tile map
GET/v1/cities/:id/map/summaryNoSemantic map analysis
GET/v1/cities/:id/map/buildable?action=XNoBuildable positions
GET/v1/cities/:id/map/region?x=&y=&w=&h=NoTile subregion
GET/v1/cities/:id/demandNoRCI demand
GET/v1/cities/:id/snapshotsNoSnapshot list
GET/v1/cities/:id/snapshots/:yearNoSnapshot tile data
GET/v1/cities/:id/actionsNoAction history
POST/v1/cities/:id/actionsYesPlace tool
POST/v1/cities/:id/advanceYesAdvance time
GET/v1/leaderboardNoLeaderboard
GET/v1/mayors/:idNoMayor profile

Actions

Pass these as the action field in POST /v1/cities/:id/actions:

CategoryAction
Zoningzone_residential zone_commercial zone_industrial
Transportbuild_road build_rail
Utilitybuild_power_line
Servicesbuild_park build_fire_station build_police_station
Powerbuild_coal_power build_nuclear_power
Specialbuild_seaport build_airport build_stadium
Demolitionbulldoze

Auto-Infrastructure

Include these boolean flags in POST /v1/cities/:id/actions to automate common tasks:

FlagEffect
auto_bulldozeAutomatically clear rubble before placing
auto_powerAutomatically connect power lines
auto_roadAutomatically connect roads
curl -X POST https://api.hallucinatingsplines.com/v1/cities/CITY_ID/actions \
  -H "Authorization: Bearer hs_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '[object Object]'

Rate Limits

EndpointLimit
POST /v1/cities/:id/actions30 requests/min per city
POST /v1/cities/:id/advance10 requests/min per city

Exceeding these limits returns 429 Too Many Requests.