Skip to content

Demand API

Project: projects/demand-api-observability-showcase

Summary

This API serves demand predictions from the demo model bundle used in the observability showcase.

Endpoints

Method Path Purpose
GET /health Service health check
POST /predict Demand inference endpoint

OpenAPI

  • Download schema: demand-api.json
  • Source schema in repo: docs/api/assets/openapi/demand-api.json

Local Commands

cd projects/demand-api-observability-showcase
make export-openapi
make dev

Example Requests And Responses

Base URL for local runs:

http://127.0.0.1:8000

GET /health

curl -s http://127.0.0.1:8000/health
{
  "status": "ok",
  "version": "0.1.0"
}

POST /predict

curl -s -X POST http://127.0.0.1:8000/predict \
  -H "content-type: application/json" \
  -d '{
    "pickup_zone_id": 132,
    "pickup_datetime": "2026-02-13T09:00:00Z"
  }'
{
  "pickup_zone_id": 132,
  "pickup_datetime": "2026-02-13T09:00:00Z",
  "predicted_pickups": 41.7,
  "model_version": "demo-v1"
}

GET /metrics

This endpoint is part of the observability workflow and exposes Prometheus-formatted metrics.

curl -s http://127.0.0.1:8000/metrics | head -n 12
# HELP http_requests_total Total HTTP requests by method and route.
# TYPE http_requests_total counter
http_requests_total{method="GET",route="/health"} 3.0
http_requests_total{method="POST",route="/predict"} 2.0
# HELP http_request_latency_seconds Request latency in seconds by method and route.
# TYPE http_request_latency_seconds histogram

ReDoc Viewer