{
 "openapi": "3.1.0",
 "info": {
  "title": "GeoPJ - API pública",
  "version": "2026-10-29",
  "description": "Rotas públicas do GeoPJ (geopj.com.br), sem login e sem chave. Grátis e pago: https://geopj.com.br/llms.txt. A base do GeoPJ (relatórios, diários, licenças e autos por cidade, mapa da base própria) não está aqui: só sai logado, e um agente de IA consulta logado na conta do usuário que o supervisiona, consumindo a cota e os pontos dela e nos limites do plano (ex.: base própria em janelas de até 10 km² e 30 km² de área nova por dia). Pedidos repetidos sem login às rotas protegidas bloqueiam o IP por algumas horas. Limite: 120 pedidos/min por cliente (20 em /enquadramento/obrigacoes).",
  "contact": {
   "name": "GeoPJ",
   "email": "contato@geopj.com.br",
   "url": "https://geopj.com.br"
  }
 },
 "servers": [
  {
   "url": "https://andersonstaub.com/apps/diario/api"
  }
 ],
 "externalDocs": {
  "description": "Resumo para agentes de IA",
  "url": "https://geopj.com.br/llms.txt"
 },
 "paths": {
  "/enquadramento/cnaes": {
   "get": {
    "operationId": "listarCnaes",
    "summary": "CNAEs com dado de enquadramento ambiental",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "status",
          "data"
         ],
         "properties": {
          "status": {
           "type": "string",
           "const": "ok"
          },
          "data": {
           "type": "object",
           "properties": {
            "total": {
             "type": "integer"
            },
            "cnaes": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "cnae": {
                "type": "string",
                "example": "4930202"
               },
               "descricao": {
                "type": "string"
               }
              }
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "429": {
      "description": "Limite de pedidos por minuto excedido; espere 60 s.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     }
    }
   }
  },
  "/enquadramento/obrigacoes": {
   "get": {
    "operationId": "obrigacoesPorCnae",
    "summary": "Licenciamento ambiental por UF e CTF/IBAMA de um CNAE ou dos CNAEs de um CNPJ",
    "description": "Informe cnae OU cnpj. Cobertura do licenciamento parcial: UF sem linha ainda não foi carregada (não quer dizer que a atividade esteja liberada). Referência, não parecer. Limite 20/min.",
    "parameters": [
     {
      "name": "cnae",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^[0-9]{7}$"
      },
      "example": "4930202",
      "description": "Subclasse CNAE, 7 dígitos (pontuação é ignorada)."
     },
     {
      "name": "cnpj",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^[0-9]{14}$"
      },
      "description": "CNPJ com 14 dígitos; resolve o CNAE principal e os secundários."
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "status",
          "data"
         ],
         "properties": {
          "status": {
           "type": "string",
           "const": "ok"
          },
          "data": {
           "$ref": "#/components/schemas/Obrigacoes"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Erro",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     },
     "429": {
      "description": "Limite de pedidos por minuto excedido; espere 60 s.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     }
    }
   }
  },
  "/status/cobertura": {
   "get": {
    "operationId": "cobertura",
    "summary": "Cobertura agregada por fonte e estado (também estática em https://geopj.com.br/assets/data/home.json)",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "status",
          "data"
         ],
         "properties": {
          "status": {
           "type": "string",
           "const": "ok"
          },
          "data": {
           "type": "object",
           "properties": {
            "diario_fontes_por_estado": {
             "type": "array",
             "items": {
              "type": "object"
             }
            },
            "diario_conteudo_por_estado": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "estado": {
                "type": "string"
               },
               "uf": {
                "type": "string"
               },
               "total": {
                "type": "integer"
               },
               "ultima_publicacao": {
                "type": "string",
                "format": "date"
               },
               "dias_com_edicao_30d": {
                "type": "integer"
               }
              }
             }
            },
            "diario_uniao": {
             "type": "object"
            },
            "licencas_por_fonte_uf": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "fonte": {
                "type": "string"
               },
               "uf": {
                "type": "string"
               },
               "total": {
                "type": "integer"
               },
               "ultima_leitura": {
                "type": "string"
               }
              }
             }
            },
            "autos_por_uf": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "uf": {
                "type": "string"
               },
               "total": {
                "type": "integer"
               },
               "ultima_coleta": {
                "type": "string"
               }
              }
             }
            },
            "cnpj": {
             "type": "object",
             "properties": {
              "total_aproximado": {
               "type": "integer"
              },
              "com_coordenada": {
               "type": "integer"
              }
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "429": {
      "description": "Limite de pedidos por minuto excedido; espere 60 s.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     }
    }
   }
  },
  "/catalog/products": {
   "get": {
    "operationId": "produtos",
    "summary": "Produtos e preços (também estático em https://geopj.com.br/assets/data/home.json)",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "status",
          "data"
         ],
         "properties": {
          "status": {
           "type": "string",
           "const": "ok"
          },
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Produto"
           }
          }
         }
        }
       }
      }
     },
     "429": {
      "description": "Limite de pedidos por minuto excedido; espere 60 s.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     }
    }
   }
  },
  "/wms/camadas": {
   "get": {
    "operationId": "camadasQgis",
    "summary": "Catálogo de camadas do GeoPJ para QGIS por nível",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "status",
          "data"
         ],
         "properties": {
          "status": {
           "type": "string",
           "const": "ok"
          },
          "data": {
           "type": "object",
           "properties": {
            "camadas": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "slug": {
                "type": "string"
               },
               "nome": {
                "type": "string"
               },
               "grupo": {
                "type": "string"
               },
               "nivel": {
                "type": "integer",
                "description": "1 grátis, 2 GeoPJ para QGIS, 3 Avançado"
               },
               "fonte": {
                "type": "string"
               },
               "uf": {
                "type": "string"
               },
               "descricao": {
                "type": "string"
               },
               "vetor": {
                "type": "boolean"
               }
              }
             }
            },
            "niveis": {
             "type": "array",
             "items": {
              "type": "object"
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "429": {
      "description": "Limite de pedidos por minuto excedido; espere 60 s.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     }
    }
   }
  },
  "/materias": {
   "get": {
    "operationId": "listarMaterias",
    "summary": "Notícias geradas dos diários oficiais",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string",
       "maxLength": 100
      },
      "description": "Até 5 palavras (2+ letras) no título, resumo, tags ou texto."
     },
     {
      "name": "uf",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^[A-Z]{2}$"
      },
      "description": "Sigla do estado; BR = União."
     },
     {
      "name": "data_inicio",
      "in": "query",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "data_fim",
      "in": "query",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "ordem",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "recentes",
        "antigas",
        "relevancia",
        "estado"
       ]
      }
     },
     {
      "name": "alta",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "1"
       ]
      },
      "description": "Só as de alta relevância."
     },
     {
      "name": "pagina",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1
      }
     },
     {
      "name": "por_pagina",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 60
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "status",
          "data"
         ],
         "properties": {
          "status": {
           "type": "string",
           "const": "ok"
          },
          "data": {
           "type": "object",
           "properties": {
            "items": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/Materia"
             }
            },
            "total": {
             "type": "integer"
            },
            "pagina": {
             "type": "integer"
            },
            "por_pagina": {
             "type": "integer"
            }
           }
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Erro",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     },
     "429": {
      "description": "Limite de pedidos por minuto excedido; espere 60 s.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     }
    }
   }
  },
  "/materias/{id}": {
   "get": {
    "operationId": "materia",
    "summary": "Notícia completa com o link da publicação original",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "status",
          "data"
         ],
         "properties": {
          "status": {
           "type": "string",
           "const": "ok"
          },
          "data": {
           "type": "object"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Erro",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     },
     "429": {
      "description": "Limite de pedidos por minuto excedido; espere 60 s.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Erro"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Erro": {
    "type": "object",
    "properties": {
     "status": {
      "type": "string",
      "const": "error"
     },
     "message": {
      "type": "string"
     }
    }
   },
   "Produto": {
    "type": "object",
    "properties": {
     "codigo": {
      "type": "string"
     },
     "nome": {
      "type": "string"
     },
     "descricao": {
      "type": "string"
     },
     "preco_centavos": {
      "type": "integer"
     },
     "preco_original_centavos": {
      "type": [
       "integer",
       "null"
      ]
     },
     "tipo_cobranca": {
      "type": "string",
      "enum": [
       "unitario",
       "assinatura"
      ]
     }
    }
   },
   "Obrigacoes": {
    "type": "object",
    "properties": {
     "empresa": {
      "type": [
       "object",
       "null"
      ],
      "properties": {
       "cnpj": {
        "type": "string"
       },
       "razao_social": {
        "type": [
         "string",
         "null"
        ]
       },
       "municipio": {
        "type": [
         "string",
         "null"
        ]
       },
       "uf": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     },
     "cnaes": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "cnae": {
         "type": "string"
        },
        "papel": {
         "type": "string",
         "enum": [
          "informado",
          "principal",
          "secundario"
         ]
        },
        "cnae_descricao": {
         "type": [
          "string",
          "null"
         ]
        },
        "licenciamento": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "uf": {
            "type": "string"
           },
           "licenciavel": {
            "type": [
             "boolean",
             "null"
            ]
           },
           "fator_excludente": {
            "type": [
             "string",
             "null"
            ]
           },
           "orgao_licenciador": {
            "type": [
             "string",
             "null"
            ]
           },
           "atividade_codigo": {
            "type": [
             "string",
             "null"
            ]
           },
           "atividade_nome": {
            "type": [
             "string",
             "null"
            ]
           },
           "criterio_porte": {},
           "fonte_norma": {
            "type": [
             "string",
             "null"
            ]
           },
           "confianca": {
            "type": [
             "string",
             "null"
            ]
           }
          }
         }
        },
        "ctf": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "categoria_codigo": {
            "type": [
             "string",
             "null"
            ]
           },
           "categoria_nome": {
            "type": [
             "string",
             "null"
            ]
           },
           "atividade_codigo": {
            "type": [
             "string",
             "null"
            ]
           },
           "atividade_nome": {
            "type": [
             "string",
             "null"
            ]
           },
           "amostras": {
            "type": [
             "integer",
             "string",
             "null"
            ]
           },
           "confianca": {
            "type": [
             "string",
             "null"
            ]
           }
          }
         }
        }
       }
      }
     }
    }
   },
   "Materia": {
    "type": "object",
    "properties": {
     "id_materia": {
      "type": "integer"
     },
     "titulo": {
      "type": "string"
     },
     "resumo": {
      "type": "string"
     },
     "tags": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "fonte": {
      "type": "string"
     },
     "data_publicacao": {
      "type": "string"
     },
     "alta_relevancia": {
      "type": "boolean"
     },
     "uf": {
      "type": [
       "string",
       "null"
      ]
     },
     "estado": {
      "type": [
       "string",
       "null"
      ]
     },
     "esfera": {
      "type": [
       "string",
       "null"
      ]
     },
     "municipio": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   }
  }
 }
}
