openapi: 3.1.0
info:
  title: Grados de más — API
  version: v1
  description: API de solo lectura, en ficheros estáticos JSON. Solo anomalías de
    temperatura, nunca temperaturas absolutas. Cada respuesta lleva en `meta` las
    fuentes, la licencia y la atribución obligatoria.
  license:
    name: CC BY 4.0
    url: https://creativecommons.org/licenses/by/4.0/deed.es
servers:
- url: https://gradosdemas.nuvolastudiogroup.com/v1
paths:
  /municipios.json:
    get:
      summary: Índice de municipios para el buscador (búsqueda en el navegador)
      responses:
        '200':
          description: Lista de municipios
  /municipios/{ine}/index.json:
    get:
      summary: Ficha de un municipio
      parameters:
      - name: ine
        in: path
        required: true
        schema:
          type: string
          pattern: ^[0-9]{5}$
        description: Código INE de 5 cifras (por ejemplo, 40170 = Riaza)
      responses:
        '200':
          description: Ficha
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Municipio'
  /municipios/{ine}/rayas.svg:
    get:
      summary: Rayas del municipio (SVG)
      parameters:
      - name: ine
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Imagen SVG
          content:
            image/svg+xml: {}
  /provincias/{codigo}/index.json:
    get:
      summary: Ficha de una provincia (código INE de 2 cifras)
      parameters:
      - name: codigo
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Ficha
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Territorio'
  /comunidades/{codigo}/index.json:
    get:
      summary: Ficha de una comunidad o ciudad autónoma
      parameters:
      - name: codigo
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Ficha
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Territorio'
  /espana/index.json:
    get:
      summary: Ficha de España
      responses:
        '200':
          description: Ficha
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Territorio'
components:
  schemas:
    Meta:
      type: object
      required:
      - fuentes
      - licencia
      - referencia
      properties:
        editor:
          type: string
        licencia:
          type: string
        licencia_url:
          type: string
        fuentes:
          type: array
          items:
            type: object
        referencia:
          type: array
        periodo:
          type: array
        metodologia:
          type: string
        generado:
          type: string
    Municipio:
      type: object
      properties:
        ine:
          type: string
        nombre:
          type: string
        slug:
          type: string
        provincia:
          type: object
        comunidad:
          type: object
        comparacion:
          type: object
        titular: &id001
          type: string
        titular_C: &id002
          type: number
          description: Diferencia de la última década con la referencia, en °C, con
            un decimal
        serie: &id003
          type: array
          items:
            type: object
            properties:
              año:
                type: integer
              anomalia_C:
                type: number
                description: Anomalía en °C respecto a la referencia
        escala_color: &id004
          type: object
        notas: &id005
          type: array
          items:
            type: string
        rayas_svg: &id006
          type: string
        meta: &id007
          $ref: '#/components/schemas/Meta'
    Territorio:
      type: object
      properties:
        codigo:
          type: string
        tipo:
          type: string
        nombre:
          type: string
        municipios:
          type: integer
        titular: *id001
        titular_C: *id002
        serie: *id003
        escala_color: *id004
        notas: *id005
        rayas_svg: *id006
        meta: *id007
