{
  "openapi": "3.0.1",
  "info": {
    "title": "Consultas vinculantes DGT · Spanish Tax Rulings Scraper",
    "description": "Extrae consultas vinculantes de la DGT (Hacienda, España) del buscador oficial: número, fecha, órgano, normativa, hechos y contestación en texto limpio. Spanish tax rulings (DGT) as JSON for tax software and RAG.",
    "version": "0.3",
    "x-build-id": "DZTbJzZVd9JL7CLqy"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/crispish_guava~dgt-consultas-vinculantes/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-crispish_guava-dgt-consultas-vinculantes",
        "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/crispish_guava~dgt-consultas-vinculantes/runs": {
      "post": {
        "operationId": "runs-sync-crispish_guava-dgt-consultas-vinculantes",
        "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/crispish_guava~dgt-consultas-vinculantes/run-sync": {
      "post": {
        "operationId": "run-sync-crispish_guava-dgt-consultas-vinculantes",
        "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",
        "properties": {
          "database": {
            "title": "Base de datos",
            "enum": [
              "vinculantes",
              "generales"
            ],
            "type": "string",
            "description": "Consultas vinculantes (art. 89 LGT) o consultas generales. Si indicas número de consulta se deduce automáticamente (prefijo V = vinculante).",
            "default": "vinculantes"
          },
          "numeroConsulta": {
            "title": "Número de consulta",
            "type": "string",
            "description": "Formato Vxxxx-aa (vinculantes) o xxxx-aa (generales), p.ej. V5955-26 o V0001-25. Devuelve como mucho esa consulta (0 ítems si no está publicada). Si se indica, se ignoran las fechas."
          },
          "textoLibre": {
            "title": "Texto libre",
            "type": "string",
            "description": "Búsqueda en todo el texto de la consulta (misma sintaxis que el buscador oficial)."
          },
          "normativa": {
            "title": "Normativa",
            "type": "string",
            "description": "Texto a buscar en el campo Normativa, p.ej. \"Ley 35/2006\" o \"LIVA\"."
          },
          "cuestionPlanteada": {
            "title": "Cuestión planteada",
            "type": "string",
            "description": "Texto a buscar en el campo Cuestión planteada."
          },
          "descripcionHechos": {
            "title": "Descripción de hechos",
            "type": "string",
            "description": "Texto a buscar en el campo Descripción de hechos."
          },
          "fechaDesde": {
            "title": "Fecha de salida desde",
            "type": "string",
            "description": "aaaa-mm-dd. Los rangos de más de un año se dividen automáticamente en tramos anuales."
          },
          "fechaHasta": {
            "title": "Fecha de salida hasta",
            "type": "string",
            "description": "aaaa-mm-dd. Si se deja vacío, hasta hoy."
          },
          "organo": {
            "title": "Órgano (filtro local)",
            "type": "string",
            "description": "Filtra por órgano emisor (p.ej. \"Personas Jurídicas\", \"Impuestos Patrimoniales\"). El buscador oficial no permite filtrar por órgano: el filtro se aplica tras descargar cada ficha, así que las fichas descartadas también consumen peticiones (pero no se cobran)."
          },
          "soloCriterioInteres": {
            "title": "Solo «criterio de interés»",
            "type": "boolean",
            "description": "Limita a las consultas marcadas por la DGT como criterio de interés.",
            "default": false
          },
          "sortOrder": {
            "title": "Orden por fecha de salida",
            "enum": [
              "desc",
              "asc"
            ],
            "type": "string",
            "description": "En modo incremental se fuerza el orden ascendente.",
            "default": "desc"
          },
          "maxItems": {
            "title": "Máximo de consultas",
            "minimum": 0,
            "type": "integer",
            "description": "Número máximo de consultas a guardar (500 por defecto). 0 = sin límite: con una fechaDesde amplia (p.ej. 1997-01-01) son muchos miles de consultas y horas de ejecución, así que trocea por años en varias ejecuciones. El ejemplo de la Store (prefill) es 5, para que la prueba automática de Apify acabe en segundos; el valor por defecto sigue siendo 500.",
            "default": 500
          },
          "incremental": {
            "title": "Modo incremental",
            "type": "boolean",
            "description": "Solo devuelve consultas no vistas en ejecuciones anteriores con la misma clave de estado. Revisa desde la última fecha de salida conocida menos la ventana de revisión (la DGT publica con retraso).",
            "default": false
          },
          "incrementalStateKey": {
            "title": "Clave de estado incremental",
            "type": "string",
            "description": "Usa claves distintas para seguimientos distintos (p.ej. \"iva\", \"irpf\").",
            "default": "default"
          },
          "incrementalLookbackDays": {
            "title": "Ventana de revisión (días)",
            "minimum": 0,
            "maximum": 365,
            "type": "integer",
            "description": "Días hacia atrás desde la última fecha de salida conocida que se vuelven a revisar en modo incremental.",
            "default": 60
          },
          "redactPersonalData": {
            "title": "Enmascarar datos personales",
            "type": "boolean",
            "description": "Salvaguarda adicional: sustituye NIF/DNI, NIE, emails, teléfonos e IBAN por [DATO OMITIDO] si apareciesen (las consultas publicadas ya están anonimizadas).",
            "default": true
          },
          "requestDelaySecs": {
            "title": "Retardo entre peticiones (s)",
            "minimum": 1,
            "maximum": 30,
            "type": "integer",
            "description": "Tiempo mínimo entre peticiones al servidor de Hacienda. Mínimo 1 s.",
            "default": 1
          },
          "maxConcurrency": {
            "title": "Concurrencia máxima",
            "minimum": 1,
            "maximum": 2,
            "type": "integer",
            "description": "Fichas descargadas en paralelo (máx. 2 por respeto al servidor público).",
            "default": 1
          },
          "maxRequestRetries": {
            "title": "Reintentos por petición",
            "minimum": 0,
            "maximum": 8,
            "type": "integer",
            "description": "Reintentos con backoff exponencial ante errores transitorios (5xx, 408, 429, red).",
            "default": 4
          },
          "healthCheck": {
            "title": "Fallar si no hay resultados (health check)",
            "type": "boolean",
            "description": "Si está activo, la ejecución falla cuando no se extrae ninguna consulta. Útil en una comprobación diaria programada.",
            "default": false
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Normalmente no es necesario."
          }
        }
      },
      "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}