{
  "openapi": "3.0.1",
  "info": {
    "title": "INE (Instituto Nacional de Estadística)",
    "description": "Capa semántica en lenguaje natural para extraer datos del INE (Instituto Nacional de Estadística de España).",
    "version": "0.0",
    "x-build-id": "HvS1jo07HqHdeBp1F"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/legaltech~ine/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-legaltech-ine",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/legaltech~ine/runs": {
      "post": {
        "operationId": "runs-sync-legaltech-ine",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/legaltech~ine/run-sync": {
      "post": {
        "operationId": "run-sync-legaltech-ine",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "action"
        ],
        "properties": {
          "action": {
            "title": "Acción",
            "enum": [
              "search",
              "table_data",
              "series_data",
              "operation_variables",
              "table_dimension_values",
              "operation_data",
              "refresh_catalog"
            ],
            "type": "string",
            "description": "Qué quieres hacer. Casi siempre el flujo correcto es: (1) \"search\" con la pregunta del usuario en lenguaje natural para encontrar la tabla/operación, y (2) \"table_data\" (o \"operation_data\" si necesitas filtrar por territorio/sexo/edad...) para traer los datos numéricos de esa tabla. NO inventes un tableId/seriesCode/operationCode sin haberlo obtenido antes con \"search\" u \"operation_variables\": los códigos del INE son opacos y adivinarlos casi siempre falla. Para dimensiones con MUCHOS valores dentro de una tabla concreta (ej. Municipios), usa \"table_dimension_values\" en vez de \"operation_variables\": es mucho más rápido.",
            "default": "search"
          },
          "query": {
            "title": "Búsqueda en lenguaje natural (para action=\"search\")",
            "type": "string",
            "description": "Describe en español lo que el usuario quiere encontrar, con el tema estadístico (no la pregunta completa): funciona mejor \"índice de precios de consumo\" o \"población por comunidades autónomas\" que una frase larga tipo \"¿cómo ha evolucionado...?\". Si el usuario ya conoce el nombre o siglas de la operación (IPC, EPA, PIB, Cifras de Población...), inclúyelo tal cual: mejora mucho la precisión."
          },
          "maxResults": {
            "title": "Número máximo de candidatos (para action=\"search\")",
            "minimum": 1,
            "maximum": 30,
            "type": "integer",
            "description": "Cuántas tablas candidatas devolver como máximo, ordenadas por relevancia. Súbelo si la primera búsqueda no trae la tabla que el usuario necesita.",
            "default": 8
          },
          "tableId": {
            "title": "Id de tabla (para table_data / table_dimension_values)",
            "type": "string",
            "description": "Identificador numérico de la tabla del INE (campo \"tableId\" de un resultado de action=\"search\"), ej. \"50902\". NUNCA lo inventes: si no lo tienes, ejecuta primero action=\"search\"."
          },
          "seriesCode": {
            "title": "Código de serie (para action=\"series_data\")",
            "type": "string",
            "description": "Código de una serie temporal concreta del INE, ej. \"IPC251856\". Suele obtenerse de los metadatos de una tabla ya consultada, no de \"search\" (que trabaja a nivel de tabla). Úsalo solo cuando ya sepas exactamente qué serie individual quieres, en vez de todas las series de una tabla."
          },
          "operationCode": {
            "title": "Código de operación (para operation_variables / operation_data)",
            "type": "string",
            "description": "Código alfabético de la operación estadística, ej. \"IPC\" (Índice de Precios de Consumo), \"EPA\" (Encuesta de Población Activa). Se obtiene del campo \"operationCode\" de un resultado de action=\"search\", o de la propia sigla si el usuario la menciona."
          },
          "variableId": {
            "title": "Id de variable (para action=\"operation_variables\")",
            "type": "string",
            "description": "Opcional. Sin rellenar, action=\"operation_variables\" lista TODAS las variables de la operación (ej. \"Provincias\", \"Sexo\", \"Grupos ECOICOP\") con su id. Rellénalo con el id de UNA de esas variables (campo \"variableId\" del resultado anterior) para obtener sus valores posibles y el id de cada uno (ej. valores de \"Provincias\" -> \"Madrid\"=29). Es el paso previo obligado para construir un filtro de \"filters\". ⚠️ Para variables con MUCHOS valores en toda España (la más notable: Municipios, ~8.000 valores), esto puede tardar 80-90 s — usa mejor action=\"table_dimension_values\" con el tableId concreto que ya tengas, mucho más rápido."
          },
          "dimension": {
            "title": "Nombre de dimensión (para action=\"table_dimension_values\")",
            "type": "string",
            "description": "Nombre de una de las dimensiones de la tabla indicada en \"tableId\" (campo \"dimensions\" de un resultado de action=\"search\" para esa tabla, ej. \"Municipios\", \"Sexo\"). Devuelve los valores posibles de esa dimensión SOLO dentro de esa tabla (ej. los municipios de una provincia concreta, no los ~8.000 de toda España), lo que lo hace mucho más rápido que \"operation_variables\" para dimensiones con muchos valores."
          },
          "filters": {
            "title": "Filtros variable:valor (para table_data / operation_data)",
            "type": "array",
            "description": "Lista de filtros en formato \"variableId:valorId\" (ej. \"115:29\" = provincia de Madrid si 115 es el id de la variable Provincias y 29 el de Madrid). Los ids se obtienen con action=\"operation_variables\" — NUNCA los inventes. Deja el valorId vacío (\"115:\") para pedir TODOS los valores de esa variable en vez de uno concreto. En \"operation_data\" cada filtro es obligatorio (así se localizan las series sin conocer una tabla); en \"table_data\" son opcionales y sirven para acotar una tabla que ya trae muchas series mezcladas. ⚠️ Una operación puede tener varias variables para el mismo concepto (ej. la EPA tiene 4 variables de \"edad\" distintas) y una tabla concreta solo usa una: si el id no aplica a esa tabla, la llamada falla. Si dudas, llama antes a \"table_data\" SIN filtros (o con nult=1) y mira el campo \"labels\" de las filas para ver el desglose real que usa esa tabla.",
            "items": {
              "type": "string"
            }
          },
          "periodicity": {
            "title": "Periodicidad (OBLIGATORIA para action=\"operation_data\")",
            "type": "integer",
            "description": "Id de periodicidad de las series a devolver: 1=mensual, 3=trimestral, 6=semestral, 12=anual. Comprobado contra la API real del INE: sin este valor, \"operation_data\" (DATOS_METADATAOPERACION) devuelve vacío aunque los filtros sean correctos. Consulta la periodicidad habitual de la operación (ej. el IPC es mensual=1, la EPA es trimestral=3) o mira \"periodicity\" en un resultado previo de action=\"search\"."
          },
          "nult": {
            "title": "Últimos N periodos",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Cuántos periodos (los más recientes) devolver por serie. Aplica a table_data, series_data y operation_data. Por defecto 12 para no devolver decenas de años de histórico de golpe; súbelo si el usuario pide una serie temporal larga, o mejor usa \"dateFrom\"/\"dateTo\" para un rango concreto (nult y las fechas son alternativos: si usas fechas, puedes dejar nult vacío).",
            "default": 12
          },
          "dateFrom": {
            "title": "Fecha desde",
            "type": "string",
            "description": "Devuelve datos desde esta fecha en adelante (formato YYYY-MM-DD). Alternativa a \"nult\" cuando el usuario pide un rango de fechas concreto (ej. \"desde 2020\") en vez de \"los últimos N datos\"."
          },
          "dateTo": {
            "title": "Fecha hasta",
            "type": "string",
            "description": "Devuelve datos hasta esta fecha (formato YYYY-MM-DD). Combínalo con \"dateFrom\" para acotar un rango, o úsalo solo para \"hasta tal fecha\"."
          },
          "maxRows": {
            "title": "Límite de filas de datos",
            "minimum": 1,
            "maximum": 20000,
            "type": "integer",
            "description": "Corta la salida a este número de filas (serie × periodo) como máximo, para no desbordar el contexto del LLM cuando una tabla trae muchas series — y para no facturar por resultados que no pediste (el actor cobra por fila devuelta). Acota mejor los filtros (\"filters\", \"nult\") en vez de subir mucho este límite.",
            "default": 500
          },
          "language": {
            "title": "Idioma",
            "enum": [
              "ES",
              "EN"
            ],
            "type": "string",
            "description": "Idioma de los nombres/etiquetas devueltos por el INE.",
            "default": "ES"
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}