{
  "openapi": "3.0.1",
  "info": {
    "title": "Equinomics | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://equinomics.co.uk/"
    }
  ],
  "paths": {
    "/api/v1/economic-indicators/public-spending-summary": {
      "get": {
        "tags": [
          "Economic Data"
        ],
        "summary": "UK public spending by function",
        "description": "HM Treasury PESA 2026 Table 4.2, financial years 2003-04 to 2025-26. Values in GBP millions.",
        "operationId": "GetPublicSpendingSummary",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSpendingResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/economic-indicators/public-spending-detail": {
      "get": {
        "tags": [
          "Economic Data"
        ],
        "summary": "UK public spending by subfunction",
        "description": "HM Treasury PESA 2026 Table 5.2, financial years 2021-22 to 2025-26. Values in GBP millions.",
        "operationId": "GetPublicSpendingDetail",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSpendingResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/economic-indicators/housing-affordability": {
      "get": {
        "tags": [
          "Economic Data"
        ],
        "summary": "House prices relative to earnings in England and Wales",
        "description": "ONS published median house-price-to-earnings ratio for England and Wales, 1997-2025.",
        "operationId": "GetHousingAffordability",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataSeriesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/economic-indicators/productivity-vs-pay": {
      "get": {
        "tags": [
          "Economic Data"
        ],
        "summary": "UK productivity vs real pay",
        "description": "Annual output per worker and real total pay, each rebased to 2000 = 100.",
        "operationId": "GetProductivityVsPay",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MultiSeriesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/economic-indicators/median-weekly-earnings": {
      "get": {
        "tags": [
          "Economic Data"
        ],
        "summary": "Median gross weekly full-time earnings",
        "description": "ONS NES/ASHE observed median gross weekly pay for full-time men, women and all employees in Great Britain and the UK. Nominal pounds per week.",
        "operationId": "GetMedianWeeklyEarnings",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MultiSeriesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/economic-indicators/median-annual-earnings": {
      "get": {
        "tags": [
          "Economic Data"
        ],
        "summary": "Annualised median gross weekly full-time earnings",
        "description": "ONS NES/ASHE median gross weekly full-time pay multiplied by 52 for men, women and all employees in Great Britain and the UK. Annualised weekly-pay estimates, not observed median annual earnings. Nominal pounds per year.",
        "operationId": "GetMedianAnnualEarnings",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MultiSeriesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/economic-indicators/income-inequality": {
      "get": {
        "tags": [
          "Economic Data"
        ],
        "summary": "UK income inequality",
        "description": "WID UK pre-tax national income shares for three population groups.",
        "operationId": "GetIncomeInequality",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MultiSeriesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/economic-indicators/wealth-inequality": {
      "get": {
        "tags": [
          "Economic Data"
        ],
        "summary": "UK wealth inequality",
        "description": "WID UK net personal wealth shares for three population groups.",
        "operationId": "GetWealthInequality",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MultiSeriesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/constituencies": {
      "get": {
        "tags": [
          "Constituencies"
        ],
        "summary": "List UK parliamentary constituencies",
        "description": "Returns constituency codes, names and nations, together with links to each constituency's details and statistics summary. The complete list is suitable for a searchable selector.",
        "operationId": "GetConstituencies",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ConstituencyListItemResponse"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/constituencies/{code}": {
      "get": {
        "tags": [
          "Constituencies"
        ],
        "summary": "Get constituency details",
        "description": "Returns the constituency's code, name, nation and region where available, together with links to itself and its statistics summary. Supply the official geographic constituency code.",
        "operationId": "GetConstituency",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConstituencyDetailsResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/constituencies/{code}/summary": {
      "get": {
        "tags": [
          "Constituencies"
        ],
        "summary": "Get the latest constituency statistics",
        "description": "Returns the latest available weekly pay, house price, child poverty and population measures, plus housing-tenure and age-profile breakdowns. Observations include units, reference periods, availability, sources and published comparisons where available. Different datasets can have different reference periods. Historical observations are not included.",
        "operationId": "GetConstituencySummary",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConstituencySummaryResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ConstituencyBreakdownResponse": {
        "required": [
          "slug",
          "name"
        ],
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "measures": {
            "type": "array",
            "items": { }
          }
        }
      },
      "ConstituencyComparisonResponse": {
        "required": [
          "area",
          "unit",
          "availability"
        ],
        "type": "object",
        "properties": {
          "area": {
            "$ref": "#/components/schemas/GeographicAreaResponse2"
          },
          "value": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "unit": {
            "type": "string"
          },
          "availability": {
            "type": "string"
          },
          "availabilityNote": {
            "type": "string",
            "nullable": true
          },
          "period": {
            "$ref": "#/components/schemas/DataPeriodResponse2"
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataSourceResponse"
            }
          }
        }
      },
      "ConstituencyDetailsResponse": {
        "required": [
          "code",
          "name",
          "nation",
          "links"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "nation": {
            "type": "string"
          },
          "region": {
            "$ref": "#/components/schemas/GeographicAreaResponse"
          },
          "links": {
            "$ref": "#/components/schemas/ConstituencyLinksResponse"
          }
        }
      },
      "ConstituencyIdentityResponse": {
        "required": [
          "code",
          "name",
          "nation"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "nation": {
            "type": "string"
          }
        }
      },
      "ConstituencyLinksResponse": {
        "required": [
          "self",
          "summary"
        ],
        "type": "object",
        "properties": {
          "self": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          }
        }
      },
      "ConstituencyListItemResponse": {
        "required": [
          "code",
          "name",
          "nation",
          "links"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "nation": {
            "type": "string"
          },
          "links": {
            "$ref": "#/components/schemas/ConstituencyLinksResponse"
          }
        }
      },
      "ConstituencyMeasureResponse": {
        "required": [
          "seriesSlug",
          "name",
          "description",
          "unit",
          "availability"
        ],
        "type": "object",
        "properties": {
          "seriesSlug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "value": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "unit": {
            "type": "string"
          },
          "availability": {
            "type": "string"
          },
          "availabilityNote": {
            "type": "string",
            "nullable": true
          },
          "period": {
            "$ref": "#/components/schemas/DataPeriodResponse2"
          },
          "dimensions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataDimensionResponse"
            }
          },
          "comparisons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConstituencyComparisonResponse"
            }
          },
          "sources": {
            "type": "array",
            "items": { }
          },
          "methodologyUrl": {
            "type": "string",
            "nullable": true
          },
          "sourceLastUpdated": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "ConstituencySummaryLinksResponse": {
        "required": [
          "self",
          "constituency"
        ],
        "type": "object",
        "properties": {
          "self": {
            "type": "string"
          },
          "constituency": {
            "type": "string"
          }
        }
      },
      "ConstituencySummaryResponse": {
        "required": [
          "constituency",
          "links"
        ],
        "type": "object",
        "properties": {
          "constituency": {
            "$ref": "#/components/schemas/ConstituencyIdentityResponse"
          },
          "links": {
            "$ref": "#/components/schemas/ConstituencySummaryLinksResponse"
          },
          "measures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConstituencyMeasureResponse"
            }
          },
          "breakdowns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConstituencyBreakdownResponse"
            }
          }
        }
      },
      "DataDimensionResponse": {
        "required": [
          "dimensionSlug",
          "valueSlug",
          "valueName"
        ],
        "type": "object",
        "properties": {
          "dimensionSlug": {
            "type": "string"
          },
          "valueSlug": {
            "type": "string"
          },
          "valueName": {
            "type": "string"
          }
        }
      },
      "DataPeriodResponse": {
        "required": [
          "label",
          "type"
        ],
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "start": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "end": {
            "type": "string",
            "format": "date",
            "nullable": true
          }
        }
      },
      "DataPeriodResponse2": {
        "required": [
          "label",
          "type"
        ],
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "start": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "end": {
            "type": "string",
            "format": "date",
            "nullable": true
          }
        },
        "nullable": true
      },
      "DataPointResponse": {
        "type": "object",
        "properties": {
          "period": {
            "$ref": "#/components/schemas/DataPeriodResponse"
          },
          "value": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "DataSeriesResponse": {
        "required": [
          "id",
          "name",
          "description",
          "unit",
          "dataSources",
          "values"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "isIllustrative": {
            "type": "boolean"
          },
          "dataSources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataSourceResponse"
            }
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataPointResponse"
            }
          }
        }
      },
      "DataSourceResponse": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "publisher": {
            "type": "string",
            "nullable": true
          },
          "url": {
            "type": "string",
            "nullable": true
          },
          "licence": {
            "type": "string",
            "nullable": true
          },
          "licenceUrl": {
            "type": "string",
            "nullable": true
          },
          "attribution": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "GeographicAreaResponse": {
        "required": [
          "code",
          "name"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "nullable": true
      },
      "GeographicAreaResponse2": {
        "required": [
          "code",
          "name"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "MultiSeriesResponse": {
        "required": [
          "id",
          "name",
          "description",
          "unit",
          "dataSources",
          "series"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "isIllustrative": {
            "type": "boolean"
          },
          "dataSources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataSourceResponse"
            }
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SeriesResponse"
            }
          }
        }
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PublicSpendingResponse": {
        "required": [
          "id",
          "name",
          "description",
          "unit",
          "financialYearStartMonth",
          "dataSources",
          "series"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "financialYearStartMonth": {
            "type": "integer",
            "format": "int32"
          },
          "isIllustrative": {
            "type": "boolean"
          },
          "dataSources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataSourceResponse"
            }
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicSpendingSeriesResponse"
            }
          }
        }
      },
      "PublicSpendingSeriesResponse": {
        "required": [
          "id",
          "name",
          "functionId",
          "functionName",
          "role",
          "sourceCode",
          "values"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "functionId": {
            "type": "string"
          },
          "functionName": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "sourceCode": {
            "type": "string"
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataPointResponse"
            }
          }
        }
      },
      "SeriesResponse": {
        "required": [
          "id",
          "name",
          "values"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataPointResponse"
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Economic Data"
    },
    {
      "name": "Constituencies"
    }
  ]
}