{ "x-nota": "borda-json: clientes de IA de fora (ChatGPT, Claude, Cursor) e integradores externos que só leem OpenAPI em JSON",
  "openapi": "3.1.0",
  "info": {
    "title": "Wortic Leilões",
    "version": "1.0.0",
    "summary": "Leilões públicos do Brasil, das fontes oficiais.",
    "description": "Leilões da Receita Federal, do PNCP e da Caixa, e as comunicações do Diário de Justiça Eletrônico Nacional. Sem chave: 60 pedidos por minuto por IP. Plano Pro (cabeçalho x-api-key): filtros a mais, CSV, jsonW, até 1000 por página e os resultados dos leilões. A API não é o edital: confira sempre o link oficial.",
    "contact": { "name": "Wortic", "url": "https://wortic.com.br" }
  },
  "servers": [{ "url": "https://leiloes.wortic.com" }],
  "paths": {
    "/v1/tipos": {
      "get": {
        "operationId": "tipos",
        "summary": "Os tipos de leilão (fontes), com quantos lotes e a última leitura",
        "responses": { "200": { "description": "As fontes", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Tipos" } } } } }
      }
    },
    "/v1/leiloes": {
      "get": {
        "operationId": "listar",
        "summary": "Lista de leilões, abertos primeiro",
        "parameters": [
          { "name": "tipo", "in": "query", "schema": { "type": "string", "enum": ["receita", "pncp", "spu", "aneel", "caixa", "judicial"] } },
          { "name": "uf", "in": "query", "schema": { "type": "string", "pattern": "^[A-Za-z]{2}$" } },
          { "name": "cidade", "in": "query", "schema": { "type": "string", "maxLength": 90 }, "description": "Sem acento e sem caixa: Porto Alegre e porto alegre dão o mesmo" },
          { "name": "q", "in": "query", "schema": { "type": "string", "maxLength": 190 }, "description": "Palavras do bem; ordena pela relevância" },
          { "name": "ate", "in": "query", "schema": { "type": "string", "format": "date" }, "description": "Encerra até esta data (horário de Brasília)" },
          { "name": "cursor", "in": "query", "schema": { "type": "string", "pattern": "^[0-9]+$" }, "description": "O valor de proximo da página anterior" },
          { "name": "limite", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 1000, "default": 50 }, "description": "Até 50 sem chave; até 1000 no plano Pro" },
          { "name": "valor_min", "in": "query", "schema": { "type": "string" }, "description": "Pro. Avaliação mínima em reais" },
          { "name": "valor_max", "in": "query", "schema": { "type": "string" }, "description": "Pro. Avaliação máxima em reais" },
          { "name": "raio", "in": "query", "schema": { "type": "string" }, "description": "Pro. latitude,longitude,km (km até 500), pelo centro da cidade do lote" },
          { "name": "categoria", "in": "query", "schema": { "type": "string" }, "description": "Pro. imovel, veiculo, joia, eletronico, informatica, celular, maquina, sucata, mobiliario, vestuario, embarcacao, aeronave, bebida, animal, outros; separadas por vírgula" },
          { "name": "encerra_em", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 365 }, "description": "Pro. Encerra em até N dias" },
          { "name": "formato", "in": "query", "schema": { "type": "string", "enum": ["json", "csv", "jsw"], "default": "json" }, "description": "csv e jsw são do plano Pro" }
        ],
        "responses": {
          "200": {
            "description": "A página",
            "headers": {
              "x-total": { "schema": { "type": "integer" }, "description": "Quantos leilões passam nos filtros" },
              "x-cursor": { "schema": { "type": "string" }, "description": "O cursor da próxima página, quando há" }
            },
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/Lista" } },
              "text/csv": { "schema": { "type": "string" } },
              "application/x-jsonw": { "schema": { "type": "string", "contentEncoding": "binary" } }
            }
          },
          "400": { "$ref": "#/components/responses/Erro" }, "401": { "$ref": "#/components/responses/Erro" },
          "403": { "$ref": "#/components/responses/Erro" }, "429": { "$ref": "#/components/responses/Limite" }
        }
      }
    },
    "/v1/leiloes/{id}": {
      "get": {
        "operationId": "ficha",
        "summary": "A ficha de um leilão; use o url que vem na lista (o id do PNCP tem / e #)",
        "parameters": [{ "$ref": "#/components/parameters/Id" }],
        "responses": { "200": { "description": "A ficha", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Lote" } } } }, "404": { "$ref": "#/components/responses/Erro" } }
      }
    },
    "/v1/leiloes/{id}/parecidos": {
      "get": {
        "operationId": "parecidos",
        "summary": "Os 10 lotes de descrição mais parecida",
        "parameters": [{ "$ref": "#/components/parameters/Id" }],
        "responses": { "200": { "description": "Os parecidos", "content": { "application/json": { "schema": { "type": "object", "properties": { "leiloes": { "type": "array", "items": { "$ref": "#/components/schemas/Lote" } } } } } } }, "404": { "$ref": "#/components/responses/Erro" } }
      }
    },
    "/v1/leiloes/{id}/resultados": {
      "get": {
        "operationId": "resultados",
        "summary": "Pro. Quem arrematou cada item de um leilão do PNCP e por quanto (só empresa)",
        "security": [{ "chave": [] }],
        "parameters": [{ "$ref": "#/components/parameters/Id" }],
        "responses": { "200": { "description": "Os resultados", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Resultados" } } } }, "401": { "$ref": "#/components/responses/Erro" }, "404": { "$ref": "#/components/responses/Erro" } }
      }
    }
  },
  "components": {
    "securitySchemes": { "chave": { "type": "apiKey", "in": "header", "name": "x-api-key" } },
    "parameters": { "Id": { "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "O id do lote codificado (%2F para /, %23 para #), ou judicial-<número>" } },
    "responses": {
      "Erro": { "description": "Recusa explicada", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Erro" } } } },
      "Limite": { "description": "Limite ou bloqueio", "headers": { "retry-after": { "schema": { "type": "integer" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Erro" } } } }
    },
    "schemas": {
      "Erro": { "type": "object", "properties": { "erro": { "type": "object", "properties": { "codigo": { "type": "string" }, "mensagem": { "type": "string" } }, "required": ["codigo", "mensagem"] } } },
      "Lote": {
        "type": "object",
        "properties": {
          "id": { "type": "string" }, "url": { "type": "string", "format": "uri" }, "fonte": { "type": "string" }, "fonte_nome": { "type": "string" },
          "categoria": { "type": ["string", "null"] }, "uf": { "type": ["string", "null"] }, "cidade": { "type": ["string", "null"] }, "orgao": { "type": ["string", "null"] },
          "descricao": { "type": ["string", "null"] }, "lance_minimo": { "type": ["number", "null"] }, "avaliacao": { "type": ["number", "null"] }, "desconto": { "type": ["number", "null"] },
          "abertura": { "type": ["string", "null"], "format": "date-time" }, "encerramento": { "type": ["string", "null"], "format": "date-time" }, "aberto": { "type": "boolean" },
          "situacao": { "type": ["string", "null"] }, "link": { "type": ["string", "null"], "format": "uri" }, "edital": { "type": ["string", "null"] },
          "coletado": { "type": "string", "format": "date-time" }, "nota": { "type": "number", "description": "Só com q: a relevância" },
          "tribunal": { "type": ["string", "null"], "description": "Só no judicial" }, "tipo_comunicacao": { "type": ["string", "null"] }, "disponibilizado": { "type": ["string", "null"], "format": "date-time" }
        }
      },
      "Lista": { "type": "object", "properties": { "total": { "type": "integer" }, "limite": { "type": "integer" }, "proximo": { "type": ["string", "null"] }, "leiloes": { "type": "array", "items": { "$ref": "#/components/schemas/Lote" } }, "aviso": { "type": "string" } } },
      "Tipos": { "type": "object", "properties": { "tipos": { "type": "array", "items": { "type": "object", "properties": { "tipo": { "type": "string" }, "nome": { "type": "string" }, "orgao": { "type": "string" }, "onde_conferir": { "type": "string", "format": "uri" }, "total": { "type": "integer" }, "abertos": { "type": ["integer", "null"] }, "ultima_coleta": { "type": ["string", "null"], "format": "date-time" } } } } } },
      "Resultados": { "type": "object", "properties": { "edital": { "type": "string" }, "resultados": { "type": "array", "items": { "type": "object", "properties": { "item": { "type": "integer" }, "valor_total": { "type": ["number", "null"] }, "data_resultado": { "type": ["string", "null"] }, "situacao": { "type": ["string", "null"] }, "arrematante": { "type": ["object", "null"], "properties": { "nome": { "type": "string" }, "cnpj": { "type": ["string", "null"] } } } } } }, "aviso": { "type": "string" } } }
    }
  }
}
