{
  "openapi": "3.1.0",
  "info": {
    "title": "eVoost Data API",
    "version": "1.0.0",
    "summary": "Open housing data with the source on every number.",
    "description": "Read-only and public. Authentication: none; no API key, account or OAuth is needed, and the first call works without credentials. No personal data. Every answer that carries numbers also carries where they come from, their licence and when they were checked. Errors follow RFC 9457 (problem details). Versioning and deprecation policy: the version is in the URL; a breaking change gets a new version, and the previous one keeps working for at least twelve months, announcing its end with the Deprecation and Sunset response headers (RFC 9745, RFC 8594). Additive changes do not change the version.",
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "contact": {
      "name": "eVoost AI",
      "url": "https://evoost.ai"
    }
  },
  "servers": [
    {
      "url": "https://data.evoost.ai/api/v1"
    }
  ],
  "security": [],
  "externalDocs": {
    "description": "Documentation for agents and developers",
    "url": "https://data.evoost.ai/en/developers"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "getIndex",
        "summary": "Entry point with links to every resource",
        "responses": {
          "200": {
            "description": "Links",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/countries": {
      "get": {
        "operationId": "listCountries",
        "summary": "Countries covered, with their code lists and levels",
        "responses": {
          "200": {
            "description": "Countries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/datasets": {
      "get": {
        "operationId": "listDatasets",
        "summary": "The public datasets",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "ISO 3166-1 alpha-2 code",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "topic",
            "in": "query",
            "required": false,
            "description": "Topic",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Datasets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/datasets/{id}": {
      "get": {
        "operationId": "getDataset",
        "summary": "One dataset: columns, source, licence, checks, links, citation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Dataset id, for example es-fixed-mortgage-rate",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dataset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/datasets/{id}/rows": {
      "get": {
        "operationId": "queryDataset",
        "summary": "Rows filtered on declared columns",
        "description": "A query parameter named after a column filters by equality (`territory=ES:ine:28079`). Suffixes add operators: `_gte`, `_lte`, `_gt`, `_lt`, `_ne`, `_in` (comma separated) and `_contains`. At most 1000 rows per call.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Dataset id, for example es-fixed-mortgage-rate",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "columns",
            "in": "query",
            "required": false,
            "description": "Comma separated columns to return",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order_by",
            "in": "query",
            "required": false,
            "description": "Column to sort by",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "asc or desc",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Rows to return (default 100, maximum 1000)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Rows to skip",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rows with the provenance of the dataset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/datasets/{id}/data.csv": {
      "get": {
        "operationId": "downloadCsv",
        "summary": "The whole dataset as CSV",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Dataset id, for example es-fixed-mortgage-rate",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CSV",
            "content": {
              "text/csv": {}
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/datasets/{id}/data.json": {
      "get": {
        "operationId": "downloadJson",
        "summary": "The whole dataset as JSON, with its description",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Dataset id, for example es-fixed-mortgage-rate",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dataset and rows",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/territories": {
      "get": {
        "operationId": "findTerritories",
        "summary": "Territories by name (accents and case ignored) or all of a country",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Name or part of it",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "ISO 3166-1 alpha-2 code",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum matches",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Territories",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/territories/{id}": {
      "get": {
        "operationId": "getTerritory",
        "summary": "The latest figure of every measure for one territory, each with its source",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Territory id as country:scheme:code, for example ES:ine:28079",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dataset",
            "in": "query",
            "required": false,
            "description": "Only this dataset",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Territory and facts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/definitions": {
      "get": {
        "operationId": "getDefinitions",
        "summary": "Fixed definitions and thresholds of a country, with their sources",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "description": "ISO 3166-1 alpha-2 code",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Definitions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/findings": {
      "get": {
        "operationId": "listFindings",
        "summary": "Findings, newest first, each with the day it was published (`published`), the last day it changed (`updated`), where it first appeared, its figures, explanation and limits",
        "responses": {
          "200": {
            "description": "Findings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/findings/{slug}": {
      "get": {
        "operationId": "getFinding",
        "summary": "One finding",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Finding slug",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Finding",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Problem": {
        "description": "Problem details (RFC 9457)",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "More than 120 requests in 60 seconds",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "Fact": {
        "type": "object",
        "description": "One number with everything needed to check it.",
        "required": [
          "dataset",
          "measure",
          "value",
          "period",
          "territory",
          "source",
          "as_of"
        ],
        "properties": {
          "dataset": {
            "type": "string"
          },
          "measure": {
            "type": "string"
          },
          "label": {
            "type": "object",
            "properties": {
              "es": {
                "type": "string"
              },
              "en": {
                "type": "string"
              }
            }
          },
          "value": {
            "type": "number"
          },
          "unit": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "period": {
            "type": "string"
          },
          "coverage": {
            "type": "object",
            "description": "How much of the period the figure covers, from its own row: quarters or months with data. A year with `quarters: 2` is half a year.",
            "additionalProperties": {
              "type": "number"
            }
          },
          "territory": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "source": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "license": {
                "type": "string"
              }
            }
          },
          "as_of": {
            "type": "string",
            "format": "date"
          }
        }
      }
    }
  }
}