{
 "openapi": "3.1.0",
 "info": {
  "title": "Divr API",
  "version": "1",
  "summary": "La API de la bolsa española: dividendos, calendario, resultados, cuentas anuales, ratios y hechos relevantes de las cotizadas en BME, desde la CNMV.",
  "description": "Datos de las empresas cotizadas en BME leídos de los registros oficiales de la CNMV y de BME. Cada cifra dice de qué documento sale, con qué fórmula se calculó o por qué falta. Plan gratuito: 100 peticiones al día, clave al momento en https://api.divr.es/docs#clave. Las cifras de los ejemplos son inventadas; sólo las respuestas reales son datos.",
  "contact": {
   "name": "Divr",
   "url": "https://api.divr.es"
  }
 },
 "externalDocs": {
  "description": "Documentación, explorador y clave gratis",
  "url": "https://api.divr.es/docs"
 },
 "servers": [
  {
   "url": "https://api.divr.es"
  }
 ],
 "security": [
  {
   "bearer": []
  }
 ],
 "tags": [
  {
   "name": "Empresas"
  },
  {
   "name": "Dividendos"
  },
  {
   "name": "Hechos relevantes"
  },
  {
   "name": "Otros mercados"
  },
  {
   "name": "Sistema"
  },
  {
   "name": "Macro",
   "description": "Tipos de interés, bonos e inflación de organismos oficiales."
  }
 ],
 "paths": {
  "/v1/issuers": {
   "get": {
    "operationId": "listIssuers",
    "summary": "Catálogo de emisores",
    "description": "Todos los valores del mercado continuo, también los que no se sirven, con el motivo. Es el punto de partida: de aquí salen los id del resto.",
    "tags": [
     "Empresas"
    ],
    "parameters": [],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Catalog"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/issuers/{id}/annual": {
   "get": {
    "operationId": "getAnnual",
    "summary": "Cuentas anuales de un emisor",
    "description": "Un objeto por ejercicio, desde el XBRL que el emisor deposita en la CNMV (desde 2016). Cada cifra dice si es reportada, derivada o un hueco con motivo.",
    "tags": [
     "Empresas"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Ticker con sufijo (TEF.MC), ISIN o NIF del emisor. Salen de GET /v1/issuers.",
      "schema": {
       "type": "string"
      },
      "example": "TEF.MC"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Annual"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/issuers/{id}/results": {
   "get": {
    "operationId": "getResults",
    "summary": "Resultados por periodo",
    "description": "Lo que la empresa presentó en cada periodo: H1, H2 (ejercicio menos H1), FY y, si hay, Q1–Q4.",
    "tags": [
     "Empresas"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Ticker con sufijo (TEF.MC), ISIN o NIF del emisor. Salen de GET /v1/issuers.",
      "schema": {
       "type": "string"
      },
      "example": "TEF.MC"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Results"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/issuers/{id}/ratios": {
   "get": {
    "operationId": "getRatios",
    "summary": "Ratios por ejercicio",
    "description": "Márgenes, ROE, ROA, deuda neta, deuda neta/EBITDA, payout y crecimiento, calculados de /annual con su fórmula y entradas.",
    "tags": [
     "Empresas"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Ticker con sufijo (TEF.MC), ISIN o NIF del emisor. Salen de GET /v1/issuers.",
      "schema": {
       "type": "string"
      },
      "example": "TEF.MC"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Ratios"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/issuers/{id}/dividends": {
   "get": {
    "operationId": "getIssuerDividends",
    "summary": "Dividendos de un emisor",
    "description": "Tres bloques que no se mezclan: events (anunciado a la CNMV, con la frase de la que sale cada fecha), market (calendario de BME) y estimates (ventana estimada a partir de años anteriores).",
    "tags": [
     "Dividendos"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Ticker con sufijo (TEF.MC), ISIN o NIF del emisor. Salen de GET /v1/issuers.",
      "schema": {
       "type": "string"
      },
      "example": "TEF.MC"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Dividends"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/events": {
   "get": {
    "operationId": "getDividendCalendar",
    "summary": "Calendario de dividendos del mercado español",
    "description": "Qué se paga entre dos fechas en todos los emisores españoles, más ampliaciones liberadas (scrip) y fechas de presentación de resultados anunciadas.",
    "tags": [
     "Dividendos"
    ],
    "parameters": [
     {
      "name": "from",
      "in": "query",
      "required": false,
      "description": "Primer día. Por defecto, hoy.",
      "schema": {
       "type": "string",
       "format": "date"
      },
      "example": "2026-10-01"
     },
     {
      "name": "to",
      "in": "query",
      "required": false,
      "description": "Último día. Por defecto, hoy + 90. Ventana máxima: 400 días.",
      "schema": {
       "type": "string",
       "format": "date"
      },
      "example": "2026-12-31"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Calendar"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/filings": {
   "get": {
    "operationId": "listFilings",
    "summary": "Hechos relevantes del mercado",
    "description": "Cada comunicación de los registros de la CNMV (Otra Información Relevante e Información Privilegiada): dividendos, resultados, juntas, consejo, recompras. Por defecto, la última semana.",
    "tags": [
     "Hechos relevantes"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": false,
      "description": "Ticker, ISIN o NIF para filtrar a un emisor.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "from",
      "in": "query",
      "required": false,
      "description": "Primer día de publicación.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "to",
      "in": "query",
      "required": false,
      "description": "Último día de publicación. Máximo 400 días.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "topic",
      "in": "query",
      "required": false,
      "description": "Tema.",
      "schema": {
       "type": "string",
       "enum": [
        "dividendo",
        "resultados",
        "junta",
        "consejo",
        "recompra"
       ]
      }
     },
     {
      "name": "register",
      "in": "query",
      "required": false,
      "description": "Registro. Sin él, los dos.",
      "schema": {
       "type": "string",
       "enum": [
        "oir",
        "ip"
       ]
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "De 1 a 500. Por defecto 100, las más recientes primero.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 500
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Filings"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/issuers/{id}/filings": {
   "get": {
    "operationId": "listIssuerFilings",
    "summary": "Hechos relevantes de un emisor",
    "description": "Lo mismo que /v1/filings para un emisor; por defecto, el último año.",
    "tags": [
     "Hechos relevantes"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Ticker con sufijo (TEF.MC), ISIN o NIF del emisor. Salen de GET /v1/issuers.",
      "schema": {
       "type": "string"
      },
      "example": "TEF.MC"
     },
     {
      "name": "from",
      "in": "query",
      "required": false,
      "description": "Primer día.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "to",
      "in": "query",
      "required": false,
      "description": "Último día.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "topic",
      "in": "query",
      "required": false,
      "description": "Tema.",
      "schema": {
       "type": "string",
       "enum": [
        "dividendo",
        "resultados",
        "junta",
        "consejo",
        "recompra"
       ]
      }
     },
     {
      "name": "register",
      "in": "query",
      "required": false,
      "description": "Registro.",
      "schema": {
       "type": "string",
       "enum": [
        "oir",
        "ip"
       ]
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "De 1 a 500.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 500
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Filings"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/us/dividends": {
   "get": {
    "operationId": "getUSDividendCalendar",
    "summary": "Calendario de dividendos de EE. UU. (Nasdaq)",
    "description": "Por ex-date y, opcionalmente, por símbolo. Sólo el bloque market.",
    "tags": [
     "Otros mercados"
    ],
    "parameters": [
     {
      "name": "symbol",
      "in": "query",
      "required": false,
      "description": "Filtra a un valor.",
      "schema": {
       "type": "string"
      },
      "example": "KO"
     },
     {
      "name": "from",
      "in": "query",
      "required": false,
      "description": "Primer ex-date. Por defecto, hoy.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "to",
      "in": "query",
      "required": false,
      "description": "Último ex-date. Por defecto, hoy + 45. Máximo 400 días.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/MarketDividends"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/market/dividends": {
   "get": {
    "operationId": "getMarketDividends",
    "summary": "Dividendos de cualquier valor (NYSE, Londres…)",
    "description": "Yahoo bajo demanda y, para EE. UU., también Nasdaq, juntados por ex-date. Cada fila dice de qué fuente sale.",
    "tags": [
     "Otros mercados"
    ],
    "parameters": [
     {
      "name": "symbol",
      "in": "query",
      "required": true,
      "description": "Símbolo, con sufijo fuera de EE. UU.",
      "schema": {
       "type": "string"
      },
      "example": "DGE.L"
     },
     {
      "name": "from",
      "in": "query",
      "required": false,
      "description": "Por defecto, hace 30 días.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "to",
      "in": "query",
      "required": false,
      "description": "Por defecto, dentro de un año. Máximo 400 días.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/MarketDividends"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/us/results": {
   "get": {
    "operationId": "getUSResults",
    "summary": "Resultados de una empresa de EE. UU.",
    "description": "Cada presentación es un 8-K con ítem 2.02 de EDGAR (la SEC), con el enlace a la nota de resultados (anexo 99.1). Las cifras del periodo (ventas, beneficio neto, BPA diluido, frente al mismo periodo del año anterior) salen del XBRL del 10-Q o 10-K; mientras no se ha registrado, `figures` va a null con `figures_reason`. `next` es la próxima fecha según Yahoo, con `estimated` si Yahoo la estima.",
    "tags": [
     "Otros mercados"
    ],
    "parameters": [
     {
      "name": "symbol",
      "in": "query",
      "required": true,
      "description": "Símbolo de EE. UU., sin sufijo.",
      "schema": {
       "type": "string"
      },
      "example": "KHC"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/USResults"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     },
     "404": {
      "description": "La SEC no tiene ese símbolo.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/macro/series": {
   "get": {
    "operationId": "getMacroCatalog",
    "summary": "Tipos, bonos e inflación: el catálogo",
    "description": "Series macroeconómicas de organismos oficiales (BCE, Banco de España, Bundesbank, Tesoro de EE. UU., Reserva Federal, INE, Eurostat, ONS, OCDE), cada una con su atribución, licencia, enlace, último dato y última lectura. Se leen cada tres horas.",
    "tags": [
     "Macro"
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/MacroCatalog"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/v1/macro/series/{id}": {
   "get": {
    "operationId": "getMacroSeries",
    "summary": "Las observaciones de una serie",
    "description": "Por defecto, los últimos 10 años hasta hoy. La prima de riesgo (`es_prima_riesgo`) se calcula restando el bono alemán al español en las fechas que tienen los dos.",
    "tags": [
     "Macro"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Id de la serie (lista en /v1/macro/series).",
      "schema": {
       "type": "string"
      },
      "example": "es_bono_10a"
     },
     {
      "name": "from",
      "in": "query",
      "required": false,
      "description": "AAAA-MM-DD.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "to",
      "in": "query",
      "required": false,
      "description": "AAAA-MM-DD; por defecto, hoy.",
      "schema": {
       "type": "string",
       "format": "date"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "X-RateLimit-Limit": {
        "$ref": "#/components/headers/Limit"
       },
       "X-RateLimit-Remaining": {
        "$ref": "#/components/headers/Remaining"
       },
       "X-RateLimit-Reset": {
        "$ref": "#/components/headers/Reset"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/MacroObservations"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "404": {
      "description": "La serie no existe.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "429": {
      "$ref": "#/components/responses/RateLimited"
     },
     "500": {
      "$ref": "#/components/responses/Internal"
     }
    }
   }
  },
  "/health": {
   "get": {
    "operationId": "health",
    "summary": "Salud del servicio",
    "tags": [
     "Sistema"
    ],
    "security": [],
    "description": "Sin clave. 200 si el servicio llega a su base de datos; 503 si no.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "status": {
           "type": "string",
           "example": "ok"
          }
         }
        }
       }
      }
     },
     "503": {
      "description": "Base de datos no disponible"
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "Authorization: Bearer <clave>. Nunca en la URL."
   }
  },
  "headers": {
   "Limit": {
    "description": "Peticiones al día del plan.",
    "schema": {
     "type": "integer"
    }
   },
   "Remaining": {
    "description": "Peticiones que quedan hoy.",
    "schema": {
     "type": "integer"
    }
   },
   "Reset": {
    "description": "Segundos Unix de la próxima medianoche UTC.",
    "schema": {
     "type": "integer"
    }
   }
  },
  "responses": {
   "BadRequest": {
    "description": "Parámetro que no se entiende (fechas, ventana de más de 400 días, falta symbol).",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Unauthorized": {
    "description": "Falta la clave o no vale.",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "NotFound": {
    "description": "issuer_unknown, issuer_no_source (permanente), issuer_not_ingested (transitorio) o events_not_scanned.",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "RateLimited": {
    "description": "Cupo del plan gratuito agotado; vuelve a las 00:00 UTC (Retry-After).",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Internal": {
    "description": "Falló. Nunca un 200 parcial; se puede reintentar.",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   }
  },
  "schemas": {
   "Figure": {
    "type": "object",
    "description": "Una cifra nunca es un escalar: dice de dónde sale o por qué falta.",
    "properties": {
     "value": {
      "description": "El valor, o null si falta."
     },
     "origin": {
      "type": "string",
      "description": "reported (sale de un documento), derived (calculada) u otra fuente nombrada (p. ej. nasdaq_calendar)."
     },
     "doc": {
      "type": "integer",
      "description": "Documento del que sale, si es reportada."
     },
     "concept": {
      "type": "string",
      "description": "Concepto XBRL, si es reportada."
     },
     "formula": {
      "type": "string"
     },
     "inputs": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "quote": {
      "type": "string",
      "description": "La frase del anuncio de la que sale, en dividendos."
     },
     "unit": {
      "type": "string",
      "enum": [
       "fraction",
       "currency"
      ]
     },
     "reason": {
      "type": "string",
      "description": "Por qué falta: no_existe_en_taxonomia, no_reportado, no_aplica_al_emisor, error_de_parseo, denominador_cero, denominador_negativo, sin_ejercicio_anterior, cambio_de_perimetro…"
     }
    },
    "required": [
     "value"
    ],
    "additionalProperties": true
   },
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "object",
      "properties": {
       "code": {
        "type": "string",
        "enum": [
         "issuer_unknown",
         "issuer_no_source",
         "issuer_not_ingested",
         "events_not_scanned",
         "bad_request",
         "unauthorized",
         "plan_not_allowed",
         "rate_limited",
         "not_found",
         "method_not_allowed",
         "not_implemented",
         "internal_error"
        ]
       },
       "message": {
        "type": "string"
       },
       "ticker": {
        "type": "string"
       }
      },
      "additionalProperties": true
     }
    },
    "additionalProperties": true
   },
   "Coverage": {
    "type": "object",
    "properties": {
     "from": {
      "type": "integer"
     },
     "to": {
      "type": "integer"
     },
     "missing": {
      "type": "array",
      "items": {
       "type": "integer"
      }
     }
    },
    "additionalProperties": true
   },
   "Issuer": {
    "type": "object",
    "properties": {
     "ticker": {
      "type": "string"
     },
     "isin": {
      "type": "string"
     },
     "nif": {
      "type": "string"
     },
     "lei": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "ingestion": {
      "type": "string",
      "enum": [
       "loaded",
       "not_ingested",
       "identity_unverified",
       "no_source"
      ]
     },
     "coverage": {
      "$ref": "#/components/schemas/Coverage"
     }
    },
    "additionalProperties": true
   },
   "Catalog": {
    "type": "object",
    "properties": {
     "generated_at": {
      "type": "string",
      "format": "date-time"
     },
     "issuers": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Issuer"
      }
     }
    },
    "additionalProperties": true
   },
   "Annual": {
    "type": "object",
    "properties": {
     "issuer": {
      "$ref": "#/components/schemas/Issuer"
     },
     "coverage": {
      "$ref": "#/components/schemas/Coverage"
     },
     "years": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "year": {
         "type": "integer"
        },
        "perimeter": {
         "type": "string"
        },
        "taxonomy": {
         "type": "string"
        },
        "currency": {
         "type": "string"
        },
        "sources": {
         "type": "array",
         "items": {
          "type": "object",
          "additionalProperties": true
         }
        },
        "fields": {
         "type": "object",
         "additionalProperties": {
          "$ref": "#/components/schemas/Figure"
         }
        }
       },
       "additionalProperties": true
      }
     }
    },
    "additionalProperties": true
   },
   "Results": {
    "type": "object",
    "properties": {
     "issuer": {
      "$ref": "#/components/schemas/Issuer"
     },
     "years": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "year": {
         "type": "integer"
        },
        "periods": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "period": {
            "type": "string",
            "enum": [
             "H1",
             "H2",
             "FY",
             "Q1",
             "Q2",
             "Q3",
             "Q4"
            ]
           },
           "period_start": {
            "type": "string",
            "format": "date"
           },
           "period_end": {
            "type": "string",
            "format": "date"
           },
           "perimeter": {
            "type": "string"
           },
           "currency": {
            "type": "string"
           },
           "source": {
            "oneOf": [
             {
              "type": "object",
              "properties": {
               "url": {
                "type": "string"
               },
               "filed": {
                "type": "string"
               }
              },
              "additionalProperties": true
             },
             {
              "type": "null"
             }
            ]
           },
           "fields": {
            "type": "object",
            "additionalProperties": {
             "$ref": "#/components/schemas/Figure"
            }
           }
          },
          "additionalProperties": true
         }
        }
       },
       "additionalProperties": true
      }
     },
     "quarters": {
      "type": "object",
      "properties": {
       "available": {
        "type": "boolean"
       },
       "reason": {
        "type": "string"
       }
      },
      "additionalProperties": true
     }
    },
    "additionalProperties": true
   },
   "Ratios": {
    "type": "object",
    "properties": {
     "ratios_version": {
      "type": "string"
     },
     "years": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "year": {
         "type": "integer"
        },
        "ratios": {
         "type": "object",
         "additionalProperties": {
          "$ref": "#/components/schemas/Figure"
         }
        }
       },
       "additionalProperties": true
      }
     }
    },
    "additionalProperties": true
   },
   "DividendEvent": {
    "type": "object",
    "properties": {
     "kind": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "amount_gross": {
      "$ref": "#/components/schemas/Figure"
     },
     "ex_date": {
      "$ref": "#/components/schemas/Figure"
     },
     "record_date": {
      "$ref": "#/components/schemas/Figure"
     },
     "payment_date": {
      "$ref": "#/components/schemas/Figure"
     },
     "confirmed_by_bme": {
      "type": "boolean"
     },
     "source": {
      "type": "object",
      "additionalProperties": true
     }
    },
    "additionalProperties": true
   },
   "Estimate": {
    "type": "object",
    "properties": {
     "payment_window": {
      "type": "object",
      "properties": {
       "from": {
        "type": "string",
        "format": "date"
       },
       "to": {
        "type": "string",
        "format": "date"
       },
       "expected": {
        "type": "string",
        "format": "date"
       }
      },
      "additionalProperties": true
     },
     "amount_gross": {
      "$ref": "#/components/schemas/Figure"
     },
     "basis_years": {
      "type": "array",
      "items": {
       "type": "integer"
      }
     },
     "dispersion_days": {
      "type": "integer"
     }
    },
    "additionalProperties": true
   },
   "Dividends": {
    "type": "object",
    "properties": {
     "coverage": {
      "type": "object",
      "properties": {
       "scanned_through": {
        "type": "string"
       },
       "stale": {
        "type": "boolean"
       }
      },
      "additionalProperties": true
     },
     "events": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/DividendEvent"
      }
     },
     "market": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": true
      }
     },
     "market_coverage": {
      "type": "object",
      "properties": {
       "served_through": {
        "type": "string"
       }
      },
      "additionalProperties": true
     },
     "estimates": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Estimate"
      }
     }
    },
    "additionalProperties": true
   },
   "Calendar": {
    "type": "object",
    "properties": {
     "events": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/DividendEvent"
      }
     },
     "market": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": true
      }
     },
     "estimates": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Estimate"
      }
     },
     "bonus_issues": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "rights_from": {
         "type": "string",
         "format": "date"
        },
        "rights_to": {
         "type": "string",
         "format": "date"
        },
        "admission_date": {
         "type": "string",
         "format": "date"
        },
        "new_shares": {}
       },
       "additionalProperties": true
      }
     },
     "results_dates": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "date": {
         "type": "string",
         "format": "date"
        },
        "fiscal_year": {
         "type": "integer"
        },
        "period": {
         "type": "string"
        },
        "quote": {
         "type": "string"
        },
        "source": {
         "type": "object",
         "additionalProperties": true
        }
       },
       "additionalProperties": true
      }
     }
    },
    "additionalProperties": true
   },
   "Filings": {
    "type": "object",
    "properties": {
     "filings": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "register": {
         "type": "string",
         "enum": [
          "oir",
          "ip"
         ]
        },
        "registro": {
         "type": "string"
        },
        "published_at": {
         "type": "string",
         "format": "date-time"
        },
        "issuer": {
         "oneOf": [
          {
           "type": "object",
           "properties": {
            "nif": {
             "type": "string"
            },
            "name": {
             "type": "string"
            },
            "ticker": {
             "type": "string"
            }
           },
           "additionalProperties": true
          },
          {
           "type": "null"
          }
         ]
        },
        "entity": {
         "type": "string"
        },
        "title": {
         "type": "string"
        },
        "category": {
         "type": "string"
        },
        "topics": {
         "type": "array",
         "items": {
          "type": "string"
         }
        },
        "url": {
         "type": "string"
        }
       },
       "additionalProperties": true
      }
     },
     "coverage": {
      "type": "object",
      "properties": {
       "stored_from": {
        "type": "string"
       },
       "scanned_through": {
        "type": "string"
       },
       "stale": {
        "type": "boolean"
       }
      },
      "additionalProperties": true
     },
     "truncated": {
      "type": "boolean"
     }
    },
    "additionalProperties": true
   },
   "MarketDividends": {
    "type": "object",
    "properties": {
     "coverage": {
      "type": "object",
      "additionalProperties": true
     },
     "market": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "symbol": {
         "type": "string"
        },
        "company": {
         "type": "string"
        },
        "amount": {
         "$ref": "#/components/schemas/Figure"
        },
        "annual_dividend": {},
        "ex_date": {},
        "record_date": {},
        "payment_date": {},
        "announced_on": {},
        "source": {}
       },
       "additionalProperties": true
      }
     }
    },
    "additionalProperties": true
   },
   "USResults": {
    "type": "object",
    "properties": {
     "symbol": {
      "type": "string"
     },
     "cik": {
      "type": "integer"
     },
     "company": {
      "type": "string"
     },
     "exchange": {
      "type": "string"
     },
     "fiscal_year_end": {
      "type": "string",
      "description": "MMDD"
     },
     "presentations": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "date": {
         "type": "string",
         "format": "date"
        },
        "published_at": {
         "type": "string",
         "format": "date-time"
        },
        "fiscal_year": {
         "type": "integer"
        },
        "period": {
         "type": "string",
         "enum": [
          "Q1",
          "Q2",
          "Q3",
          "FY"
         ]
        },
        "source": {
         "type": "object",
         "properties": {
          "register": {
           "type": "string",
           "example": "sec"
          },
          "form": {
           "type": "string",
           "example": "8-K"
          },
          "accession": {
           "type": "string"
          },
          "url": {
           "type": "string",
           "format": "uri"
          }
         }
        },
        "figures": {
         "type": [
          "object",
          "null"
         ],
         "properties": {
          "currency": {
           "type": "string"
          },
          "period_start": {
           "type": "string",
           "format": "date"
          },
          "period_end": {
           "type": "string",
           "format": "date"
          },
          "source": {
           "type": "object",
           "properties": {
            "register": {
             "type": "string",
             "example": "sec"
            },
            "form": {
             "type": "string",
             "example": "8-K"
            },
            "accession": {
             "type": "string"
            },
            "url": {
             "type": "string",
             "format": "uri"
            }
           }
          },
          "revenue": {
           "type": "object",
           "properties": {
            "value": {
             "type": [
              "number",
              "null"
             ]
            },
            "prior": {
             "type": [
              "number",
              "null"
             ]
            },
            "concept": {
             "type": "string"
            },
            "reason": {
             "type": "string"
            }
           }
          },
          "net_income": {
           "type": "object",
           "properties": {
            "value": {
             "type": [
              "number",
              "null"
             ]
            },
            "prior": {
             "type": [
              "number",
              "null"
             ]
            },
            "concept": {
             "type": "string"
            },
            "reason": {
             "type": "string"
            }
           }
          },
          "eps_diluted": {
           "type": "object",
           "properties": {
            "value": {
             "type": [
              "number",
              "null"
             ]
            },
            "prior": {
             "type": [
              "number",
              "null"
             ]
            },
            "concept": {
             "type": "string"
            },
            "reason": {
             "type": "string"
            }
           }
          },
          "read": {
           "type": "string",
           "enum": [
            "press_release"
           ],
           "description": "press_release: leídas de la nota de prensa por el extractor, a falta del 10-Q"
          }
         }
        },
        "figures_reason": {
         "type": "string",
         "enum": [
          "10q_pendiente",
          "nota_leyendose",
          "cifras_no_leidas"
         ]
        }
       }
      }
     },
     "next": {
      "type": [
       "object",
       "null"
      ],
      "properties": {
       "date": {
        "type": "string",
        "format": "date"
       },
       "estimated": {
        "type": "boolean"
       },
       "source": {
        "type": "string",
        "example": "yahoo"
       }
      }
     }
    }
   },
   "MacroSeries": {
    "type": "object",
    "description": "Una serie del catálogo, con su procedencia.",
    "properties": {
     "id": {
      "type": "string",
      "example": "es_bono_10a"
     },
     "name": {
      "type": "string"
     },
     "area": {
      "type": "string",
      "enum": [
       "ES",
       "DE",
       "EA",
       "US",
       "UK"
      ]
     },
     "unit": {
      "type": "string",
      "enum": [
       "percent",
       "percentage_points"
      ]
     },
     "frequency": {
      "type": "string",
      "enum": [
       "daily",
       "monthly"
      ]
     },
     "source": {
      "type": "string",
      "description": "Organismo que publica la serie."
     },
     "attribution": {
      "type": "string",
      "description": "Texto con el que hay que citarla."
     },
     "license": {
      "type": "string"
     },
     "source_url": {
      "type": "string",
      "format": "uri"
     },
     "derived_from": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Si se calcula: la primera menos la segunda, en las fechas que tienen las dos."
     }
    }
   },
   "MacroObservation": {
    "type": "object",
    "properties": {
     "date": {
      "type": "string",
      "format": "date",
      "description": "Las mensuales llevan el día 1."
     },
     "value": {
      "type": "number"
     },
     "provisional": {
      "type": "boolean",
      "description": "Avance o estimación que el organismo confirmará."
     }
    }
   },
   "MacroCatalog": {
    "type": "object",
    "properties": {
     "series": {
      "type": "array",
      "items": {
       "allOf": [
        {
         "$ref": "#/components/schemas/MacroSeries"
        },
        {
         "type": "object",
         "properties": {
          "last": {
           "oneOf": [
            {
             "$ref": "#/components/schemas/MacroObservation"
            },
            {
             "type": "null"
            }
           ]
          },
          "read": {
           "type": "object",
           "properties": {
            "at": {
             "type": "string",
             "format": "date-time"
            },
            "ok": {
             "type": "boolean"
            },
            "error": {
             "type": "string"
            },
            "last_ok": {
             "type": [
              "string",
              "null"
             ],
             "format": "date-time"
            }
           }
          }
         }
        }
       ]
      }
     }
    }
   },
   "MacroObservations": {
    "type": "object",
    "properties": {
     "series": {
      "$ref": "#/components/schemas/MacroSeries"
     },
     "from": {
      "type": "string",
      "format": "date"
     },
     "to": {
      "type": "string",
      "format": "date"
     },
     "observations": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/MacroObservation"
      }
     }
    }
   }
  }
 }
}
