{
  "openapi": "3.0.1",
  "info": {
    "title": "Licitaciones LATAM — Government Tenders Aggregator",
    "description": "Unifies and prioritizes public tenders from 6 LATAM countries (Colombia SECOP, Brazil PNCP, Peru, Chile, Mexico, Argentina) into one OCDS-like schema with an explainable 0–100 opportunity score, monitor mode, awardee analytics and integrity red flags.",
    "version": "0.1",
    "x-build-id": "5WzHwj4OQXhz5Pjww"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/karmic_mastodon~licitaciones-latam/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-karmic_mastodon-licitaciones-latam",
        "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/karmic_mastodon~licitaciones-latam/runs": {
      "post": {
        "operationId": "runs-sync-karmic_mastodon-licitaciones-latam",
        "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/karmic_mastodon~licitaciones-latam/run-sync": {
      "post": {
        "operationId": "run-sync-karmic_mastodon-licitaciones-latam",
        "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": {
          "countries": {
            "title": "Países",
            "type": "array",
            "description": "Países a consultar. Chile (CL) requiere la variable de entorno CL_TICKET (ticket gratuito de MercadoPublico). Perú (PE) usa la API abierta OECE/OCDS, sin token. México (MX) usa archivos OCDS abiertos: Nuevo León (vivo, semanal) + CompraNet federal (histórico 2022). Argentina (AR) usa OCDS abierto de la provincia de Mendoza (vivo, mensual); no hay agregador federal vivo disponible hoy en MX ni AR.",
            "items": {
              "type": "string",
              "enum": [
                "CO",
                "BR",
                "CL",
                "PE",
                "MX",
                "AR"
              ],
              "enumTitles": [
                "Colombia",
                "Brasil",
                "Chile (beta · requiere CL_TICKET)",
                "Perú",
                "México (Nuevo León + CompraNet 2022)",
                "Argentina (solo Mendoza)"
              ]
            },
            "default": [
              "CO",
              "BR"
            ]
          },
          "mxSources": {
            "title": "Fuentes de México (avanzado)",
            "type": "array",
            "description": "Qué colecciones OCDS de México incluir. NL = Nuevo León (vivo, semanal). CN = CompraNet federal (histórico, congelado en 2022). Vacío = ambas.",
            "items": {
              "type": "string",
              "enum": [
                "NL",
                "CN"
              ],
              "enumTitles": [
                "Nuevo León (vivo)",
                "CompraNet federal (histórico 2022)"
              ]
            },
            "default": []
          },
          "keywords": {
            "title": "Palabras clave (filtro)",
            "type": "string",
            "description": "Texto libre para filtrar en la fuente (opcional)"
          },
          "priorityKeywords": {
            "title": "Palabras clave prioritarias (scoring)",
            "type": "array",
            "description": "Temas que te interesan; suben el puntaje de oportunidad de las licitaciones que los mencionan",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "dateFrom": {
            "title": "Fecha desde",
            "type": "string",
            "description": "YYYY-MM-DD"
          },
          "dateTo": {
            "title": "Fecha hasta",
            "type": "string",
            "description": "YYYY-MM-DD"
          },
          "modalidades": {
            "title": "Modalidades de Brasil (PNCP)",
            "type": "array",
            "description": "Códigos de modalidad PNCP (1–14). Vacío = todas. Menos modalidades = corridas más baratas.",
            "default": []
          },
          "mode": {
            "title": "Modo",
            "enum": [
              "dump",
              "monitor"
            ],
            "type": "string",
            "description": "dump = todo lo que matchea; monitor = solo lo nuevo/cambiado desde la última corrida",
            "default": "dump"
          },
          "minScore": {
            "title": "Puntaje mínimo (0-100)",
            "minimum": 0,
            "maximum": 100,
            "type": "integer",
            "description": "Emite solo licitaciones con puntaje de oportunidad >= este valor. 0 = sin filtro",
            "default": 0
          },
          "sortByScore": {
            "title": "Ordenar por puntaje",
            "type": "boolean",
            "description": "Devuelve primero las de mayor puntaje (usa un buffer acotado por el límite)",
            "default": false
          },
          "scoringWeights": {
            "title": "Pesos del puntaje (avanzado)",
            "type": "object",
            "description": "Opcional. Ajusta la importancia de cada factor. Deben sumar 100. Si se omite, usa los pesos por defecto del roadmap",
            "default": {}
          },
          "maxItems": {
            "title": "Límite de resultados",
            "minimum": 1,
            "type": "integer",
            "description": "Tope de registros para controlar costo/tiempo",
            "default": 500
          },
          "webhookUrl": {
            "title": "Webhook de alertas (opcional)",
            "type": "string",
            "description": "URL de Slack o Discord. Al terminar la corrida envía UN resumen con las mejores licitaciones. Se autodetecta por el dominio."
          },
          "telegramBotToken": {
            "title": "Token del bot de Telegram (opcional)",
            "type": "string",
            "description": "Token del bot para enviar el resumen por Telegram. Requiere también el Chat ID."
          },
          "telegramChatId": {
            "title": "Chat ID de Telegram (opcional)",
            "type": "string",
            "description": "ID numérico o @canal donde enviar el resumen de Telegram."
          },
          "alertTopN": {
            "title": "Cantidad en el resumen (alertas)",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "Cuántas licitaciones (las de mayor puntaje) incluir en la alerta de fin de corrida.",
            "default": 10
          },
          "includeAwardeeAnalytics": {
            "title": "Análisis de adjudicatarios (de esta corrida)",
            "type": "boolean",
            "description": "Agrega un resumen por proveedor (adjudicaciones vistas EN ESTA corrida, no histórico). Acumula en memoria acotada por el límite.",
            "default": false
          },
          "includeIntegrityFlags": {
            "title": "Señales de integridad (banderas rojas, de esta corrida)",
            "type": "boolean",
            "description": "Agrega banderas de riesgo determinísticas por registro (ventana de ofertas muy corta, método no competitivo, concentración/repetición de adjudicatario EN ESTA corrida). Son heurísticas según los campos disponibles; NO son prueba de irregularidad. Acumula en memoria acotada por el límite.",
            "default": false
          },
          "includeSupplierGraph": {
            "title": "Proveedores cross-país (de esta corrida)",
            "type": "boolean",
            "description": "Detecta proveedores adjudicados en 2+ países dentro de ESTA corrida, cruzados por NOMBRE normalizado (los IDs fiscales no coinciden entre países). Heurística: puede confundir empresas distintas con el mismo nombre; excluye Brasil (su fuente no trae adjudicatario). Suele estar vacío salvo que consultes varios países con datos solapados.",
            "default": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}