API Access

Production API reference for datasets, recommendations, and AI-assisted query/discovery workflows.

Base URL

http://127.0.0.1:5000

Content-Type

application/json for all POST endpoints.

Authentication

Current version is internal and does not enforce auth headers.

Response format

Most endpoints return JSON arrays/objects with HTTP 200.

Endpoint Index

Quick list of currently available endpoints.

EndpointMethodPurpose
/api/zonesGETZone master data.
/api/footfallGETFootfall records by zone and hour.
/api/mobility_odGETOrigin-destination mobility flows.
/api/audience_profileGETAudience and SES indicators.
/api/device_digital_profileGETDevice and digital readiness metrics.
/api/weekend_patternsGETWeekend vs weekday behavior.
/api/inflow_diversityGETCatchment diversity signals.
/api/affinity_segmentsGETAffinity segment distributions.
/api/queryPOSTNatural language query interpretation.
/api/chatPOSTConversational analysis assistant.
/api/discoverPOSTInsight discovery with chart recommendations.
/api/recommendationGETTop recommended zones and rationale.
/api/kpisGETExecutive KPI snapshot for reports.

Detailed API Spec

Parameters, payload schemas, and sample requests/responses.

GET /api/zones

Returns the zone master list used across all analytics modules.

Response fields:

  • zone_id (string): Zone identifier.
  • zone_name (string): Human-readable zone name.
  • city (string): City classification.
curl -X GET "http://127.0.0.1:5000/api/zones"
[
  {
    "zone_id": "Z001",
    "zone_name": "Blok M",
    "city": "Jakarta Selatan"
  }
]

GET /api/footfall

Returns hourly footfall records by zone.

Response fields:

  • zone_id (string)
  • hour (number, 0-23)
  • estimated_people (number)
  • avg_dwell_minutes (number, optional)
  • repeat_visitor_pct (number, optional)
curl -X GET "http://127.0.0.1:5000/api/footfall"

GET /api/mobility_od

Returns origin-destination trip flow records.

Response fields:

  • origin_zone_id (string)
  • destination_zone_id (string)
  • trip_count (number)
  • peak_hour (number or string, optional)
  • commute_flag (boolean, optional)
curl -X GET "http://127.0.0.1:5000/api/mobility_od"

GET /api/audience_profile

Returns zone-level audience and SES attributes.

Response fields:

  • zone_id (string)
  • ses_low_pct, ses_mid_pct, ses_high_pct (number)
  • worker_pct, resident_pct, visitor_pct (number)
  • mobility_radius_km (number, optional)
curl -X GET "http://127.0.0.1:5000/api/audience_profile"

GET /api/device_digital_profile, /api/weekend_patterns, /api/inflow_diversity, /api/affinity_segments, /api/poi_clusters

Returns additional telco-derived profile layers used in reports and discovery.

curl -X GET "http://127.0.0.1:5000/api/device_digital_profile"

POST /api/query

Parses natural-language query into structured dashboard intent.

Request body:

{
  "q": "Which zones are attractive for banking branch expansion?"
}

Sample request:

curl -X POST "http://127.0.0.1:5000/api/query" \
  -H "Content-Type: application/json" \
  -d '{"q":"Which zones are attractive for banking branch expansion?"}'

Response:

{
  "intent": "site_selection",
  "filters": {
    "industry": "banking_insurance",
    "time_window": "evening"
  }
}

POST /api/chat

Conversational assistant for guided analytics exploration.

Request body:

{
  "message": "How does mobility consistency help fraud detection?",
  "history": [
    {"role": "user", "content": "What signals support location verification for KYC?"}
  ]
}

Response:

{
  "reply": "Mobility consistency checks compare claimed location and observed movement patterns..."
}

Error modes:

  • 400 when message is empty.
  • 200 with error payload if API key is not configured.

POST /api/discover

Maps a business question to recommended data products and chart types.

Request body:

{
  "message": "Where should we expand our branch network to reach affluent customers?"
}

Response:

{
  "reply": "Use audience SES and evening footfall to shortlist high-value branch zones.",
  "chart_types": ["audience_ses", "footfall"]
}

Allowed chart_types:

  • footfall, mobility_od, audience_ses, device_digital
  • weekend_patterns, catchment_diversity, affinity_segments, poi_commercial

GET /api/recommendation

Returns top ranked zones for recommendation workflows.

Query params:

  • geography (string, default: South Jakarta)
  • time_window (string, default: evening)
  • top_n (number, default: 3)
curl -X GET "http://127.0.0.1:5000/api/recommendation?geography=South%20Jakarta&time_window=evening&top_n=3"

GET /api/zone_scores

Returns computed zone scoring outputs for ranking and map overlays.

Query params:

  • time_window (string, default: evening)
curl -X GET "http://127.0.0.1:5000/api/zone_scores?time_window=evening"

GET /api/kpis

Returns executive KPI aggregate snapshot for reports header cards.

Response fields:

  • total_daily_footfall
  • nighttime_footfall
  • total_od_trips
  • top_hotspot_zone
  • strongest_commuter_corridor
  • dominant_ses_segment
  • avg_digital_readiness
  • top_weekend_zone
curl -X GET "http://127.0.0.1:5000/api/kpis"