{
  "openapi": "3.0.1",
  "info": {
    "title": "Mercado Público Chile – Licitaciones y Órdenes de Compra",
    "description": "Normalized Chilean public procurement data for AI agents and developers: tenders (licitaciones) and purchase orders from the official Mercado Público API (Compra Ágil in beta), using your own free ChileCompra ticket. Not affiliated with ChileCompra.",
    "version": "0.1",
    "x-build-id": "Jgxop3RXuVfqQVTKl"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/better-llama~mercado-publico-chile/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-better-llama-mercado-publico-chile",
        "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/better-llama~mercado-publico-chile/runs": {
      "post": {
        "operationId": "runs-sync-better-llama-mercado-publico-chile",
        "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/better-llama~mercado-publico-chile/run-sync": {
      "post": {
        "operationId": "run-sync-better-llama-mercado-publico-chile",
        "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": [
          "ticket"
        ],
        "properties": {
          "ticket": {
            "title": "Ticket de la API de Mercado Público / API ticket",
            "type": "string",
            "description": "Tu ticket personal de ChileCompra. Se guarda cifrado y solo se usa para tus consultas; nunca se registra en logs. Solicítalo en https://www.chilecompra.cl/api/ (Clave Única). / Your personal ChileCompra ticket, stored encrypted, never logged."
          },
          "source": {
            "title": "Fuente de datos / Data source",
            "enum": [
              "licitaciones",
              "ordenes_compra",
              "compra_agil"
            ],
            "type": "string",
            "description": "licitaciones = tenders (API v1); ordenes_compra = purchase orders (API v1); compra_agil = Compra Ágil (API v2, BETA — la API oficial está en beta y aún no se ha validado con datos reales en este Actor; puede fallar con 504).",
            "default": "licitaciones"
          },
          "codes": {
            "title": "Códigos específicos / Specific codes",
            "type": "array",
            "description": "Opcional. Si se indican, se consulta la ficha de cada código e ignoran los demás filtros. Ej.: 1509-5-L114 (licitación), 1057532-156-AG26 (OC), 1057539-228-COT26 (Compra Ágil). / Optional: fetch these codes only.",
            "items": {
              "type": "string"
            }
          },
          "dateFrom": {
            "title": "Desde (fecha) / From date",
            "pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
            "type": "string",
            "description": "YYYY-MM-DD, día calendario de Chile. Por defecto: hoy. Licitaciones/OC: una consulta por día; la API devuelve los registros asociados a esa fecha según su propio criterio (en pruebas reales incluye licitaciones publicadas, cerradas y adjudicadas ese día, no solo las publicadas). Compra Ágil: fecha de publicación. Máx. 31 días por ejecución."
          },
          "dateTo": {
            "title": "Hasta (fecha) / To date",
            "pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
            "type": "string",
            "description": "YYYY-MM-DD, inclusive. Por defecto igual a 'Desde' (o hoy)."
          },
          "tenderStatus": {
            "title": "Estado de licitación / Tender status",
            "enum": [
              "activas",
              "publicada",
              "cerrada",
              "desierta",
              "adjudicada",
              "revocada",
              "suspendida",
              "todos"
            ],
            "type": "string",
            "description": "Solo para 'licitaciones'. 'activas' = todas las publicadas hoy (ignora fechas si no indicas fechas)."
          },
          "purchaseOrderStatus": {
            "title": "Estado de orden de compra / Purchase order status",
            "enum": [
              "todos",
              "enviadaproveedor",
              "aceptada",
              "cancelada",
              "recepcionconforme",
              "pendienterecepcion",
              "recepcionaceptadacialmente",
              "recepecionconformeincompleta"
            ],
            "type": "string",
            "description": "Solo para 'ordenes_compra'. Valores tal como los publica la documentación oficial."
          },
          "buyerCode": {
            "title": "Código de organismo comprador / Buyer code",
            "type": "string",
            "description": "Licitaciones/OC: CodigoOrganismo numérico (ej. 6945). Se combina con la fecha."
          },
          "supplierCode": {
            "title": "Código de proveedor / Supplier code",
            "type": "string",
            "description": "Licitaciones/OC: CodigoProveedor numérico de Mercado Público (ej. 17793). No es el RUT."
          },
          "agileStatuses": {
            "title": "Estados de Compra Ágil / Compra Ágil statuses",
            "type": "array",
            "description": "[BETA] Solo para 'compra_agil'. Vacío = todos.",
            "items": {
              "type": "string",
              "enum": [
                "publicada",
                "cerrada",
                "desierta",
                "cancelada",
                "proveedor_seleccionado",
                "oc_emitida"
              ],
              "enumTitles": [
                "Publicada / Published",
                "Cerrada / Closed",
                "Desierta / Deserted",
                "Cancelada / Cancelled",
                "Proveedor seleccionado / Supplier selected",
                "OC emitida / PO issued"
              ]
            }
          },
          "regions": {
            "title": "Regiones (Compra Ágil) / Regions",
            "type": "array",
            "description": "[BETA] Solo para 'compra_agil'. Región del organismo comprador. Vacío = todo Chile.",
            "items": {
              "type": "string",
              "enum": [
                "15",
                "1",
                "2",
                "3",
                "4",
                "5",
                "13",
                "6",
                "7",
                "16",
                "8",
                "9",
                "14",
                "10",
                "11",
                "12"
              ],
              "enumTitles": [
                "Arica y Parinacota",
                "Tarapacá",
                "Antofagasta",
                "Atacama",
                "Coquimbo",
                "Valparaíso",
                "Metropolitana",
                "O'Higgins",
                "Maule",
                "Ñuble",
                "Biobío",
                "Araucanía",
                "Los Ríos",
                "Los Lagos",
                "Aysén",
                "Magallanes"
              ]
            }
          },
          "keyword": {
            "title": "Palabras clave (Compra Ágil) / Keywords",
            "type": "string",
            "description": "[BETA] Solo para 'compra_agil': búsqueda en nombre/descripción (parámetro q de la API)."
          },
          "buyerRut": {
            "title": "RUT del organismo (Compra Ágil) / Buyer RUT",
            "type": "string",
            "description": "[BETA] Solo para 'compra_agil'. La API v2 no filtra por organismo; este filtro se aplica localmente. Combínalo con una región para ahorrar cuota."
          },
          "fetchDetails": {
            "title": "Obtener ficha completa / Fetch full details",
            "type": "boolean",
            "description": "Los listados por fecha solo traen datos básicos (código, nombre, estado, cierre). Activado: se consulta la ficha de cada resultado (organismo, montos, fechas). Usa 1 solicitud extra de tu cuota por resultado.",
            "default": true
          },
          "includeRaw": {
            "title": "Incluir respuesta original / Include raw record",
            "type": "boolean",
            "description": "Agrega el campo 'raw' con el registro original de la API (sin datos personales de funcionarios/contactos).",
            "default": false
          },
          "maxItems": {
            "title": "Máximo de resultados / Max results",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Tope de resultados entregados (y cobrados) en esta ejecución.",
            "default": 50
          },
          "requestIntervalMs": {
            "title": "Intervalo entre solicitudes (ms) / Request interval",
            "minimum": 500,
            "maximum": 10000,
            "type": "integer",
            "description": "Pausa mínima entre el fin de una respuesta y la siguiente solicitud. La API rechaza 'peticiones simultáneas' (10500) incluso con 1–1,5 s; 2500 ms es el valor por defecto tras pruebas reales.",
            "default": 2500
          },
          "maxRetries": {
            "title": "Reintentos / Max retries",
            "minimum": 0,
            "maximum": 8,
            "type": "integer",
            "description": "Reintentos con espera exponencial ante errores transitorios (red, 5xx, peticiones simultáneas).",
            "default": 4
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}