{
  "openapi": "3.1.0",
  "info": {
    "title": "LGU Health Spending Lens API",
    "version": "0.1.0",
    "description": "Read-only. The published figures behind the nine Central Luzon LGU briefs: PIDS health spending and primary care figures, and DBM COMPASS NTA, joined on PSGC codes. Every record lists its sources. For discussion, not a finding. Figures belong to PIDS and DBM."
  },
  "servers": [
    {
      "url": "https://nuque.dev"
    }
  ],
  "paths": {
    "/api/lgu": {
      "get": {
        "summary": "Every LGU with a brief",
        "responses": {
          "200": {
            "description": "All records with sources and field notes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "title": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Source"
                      }
                    },
                    "records": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Record"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/lgu/{psgc}": {
      "get": {
        "summary": "One LGU by PSGC code",
        "parameters": [
          {
            "name": "psgc",
            "in": "path",
            "required": true,
            "description": "10-digit PSGC code, for example 0306900000 (Tarlac)",
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record and its sources",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "record": {
                      "$ref": "#/components/schemas/Record"
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Source"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not a 10-digit code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No brief for that code yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Record": {
        "type": "object",
        "required": [
          "psgc",
          "name",
          "lgu_type",
          "region",
          "health_spending_per_person_php",
          "health_spending_is_rounded",
          "times_current_spending",
          "share_of_operating_income_pct",
          "nta_fy2024_php"
        ],
        "properties": {
          "psgc": {
            "type": "string",
            "title": "PSGC code",
            "description": "10-digit Philippine Standard Geographic Code, the join key. Source: psa-psgc."
          },
          "name": {
            "type": "string",
            "title": "LGU",
            "description": "Province or highly urbanized city."
          },
          "lgu_type": {
            "type": "string",
            "title": "LGU type",
            "description": "province or huc. LGUs are compared only within their type."
          },
          "region": {
            "type": "string",
            "title": "Region",
            "description": "Region as of the PSGC list used."
          },
          "health_spending_per_person_php": {
            "type": "integer",
            "title": "Health spending per person (PHP), 2024",
            "description": "LGU health spending per capita, 2024. Source: pids-explorer."
          },
          "health_spending_is_rounded": {
            "type": "boolean",
            "title": "Shown rounded by PIDS",
            "description": "True where the PIDS explorer shows the value rounded to the nearest 100."
          },
          "times_current_spending": {
            "type": "number",
            "title": "Full primary care, times current spending",
            "description": "Annual cost of primary care (2026 estimate) against 2024 health spending. Source: pids-dp-2026-07."
          },
          "share_of_operating_income_pct": {
            "type": "integer",
            "title": "Share of operating income (%)",
            "description": "Share of operating income full primary care would take. Source: pids-dp-2026-07."
          },
          "nta_fy2024_php": {
            "type": "integer",
            "title": "National Tax Allotment, FY 2024 (PHP)",
            "description": "As published. Context only: never a ratio to health spending. Source: dbm-compass-nta."
          }
        }
      },
      "Source": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "path": {
            "type": "string",
            "format": "uri"
          },
          "period": {
            "type": "string"
          },
          "pulled": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    }
  },
  "x-sources": [
    "pids-explorer",
    "pids-dp-2026-07",
    "dbm-compass-nta",
    "psa-psgc"
  ]
}
