validar-iti
API e cliente Python não oficial para validar assinaturas de PDFs pelo ITI VALIDAR.
O projeto não implementa um verificador criptográfico próprio. Ele envia PDFs ou URLs para os endpoints públicos usados pelo site do VALIDAR e normaliza a resposta em JSON simples para uso em sistemas.
Aviso
Este projeto não é oficial, não é mantido pelo ITI e não tem relação com o Gov.br. O serviço VALIDAR não publica esses endpoints como API pública estável, então o contrato pode mudar.
Instalação
pip install validar-iti
Para desenvolvimento local:
python -m pip install -e ".[dev]"
Subir a API
validar-iti serve --host 127.0.0.1 --port 8000
Em desenvolvimento:
validar-iti serve --reload
Endpoints
Validar um PDF
curl -F "file=@documento_assinado.pdf;type=application/pdf" \
http://127.0.0.1:8000/validate/file
Validar múltiplos PDFs
curl \
-F "files=@um.pdf;type=application/pdf" \
-F "files=@dois.pdf;type=application/pdf" \
http://127.0.0.1:8000/validate/files
Validar URL
curl -X POST http://127.0.0.1:8000/validate/url \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/documento.pdf"}'
Healthcheck
curl http://127.0.0.1:8000/health
Uso como cliente Python
import asyncio
from validar_iti import ValidarClient
async def main():
async with ValidarClient() as client:
resultado = await client.validate_pdf("documento_assinado.pdf")
print(resultado.valid)
print(resultado.status_label)
print(resultado.simple_report_text)
asyncio.run(main())
Resposta
A API retorna campos estruturados e também simple_report_text, montado a partir
do relatório simples retornado pelo próprio VALIDAR.
Exemplo resumido:
{
"valid": true,
"status": "approved",
"status_label": "Aprovado",
"report_source": "validar_simples",
"file_name": "documento_assinado.pdf",
"sha256": "...",
"signatures": [
{
"signer_name": "NOME DO ASSINANTE",
"authority": "Gov-Br",
"cpf": "***.000.000-**",
"status": "approved",
"status_label": "Aprovado"
}
]
}
Configuração
Variáveis de ambiente:
VALIDAR_BASE_URL, padrãohttps://validar.iti.gov.brVALIDAR_TIMEOUT_SECONDS, padrão190VALIDAR_MAX_CONCURRENCY, padrão2MAX_UPLOAD_MB, padrão10MAX_BATCH_MB, padrão30MAX_FILES_PER_REQUEST, padrão10VALIDAR_PROXY_URL, proxy HTTP(S) opcional para chamadas ao VALIDARVALIDAR_USE_SIMPLE_REPORT, padrãotrueUSER_AGENT, user-agent enviado ao VALIDAR
Quando VALIDAR_USE_SIMPLE_REPORT=true, o fluxo usa /arquivo ou /url e em
seguida /simples, que é a fonte dos dados da visão "Simples" do
relatorio.html.
Quando VALIDAR_USE_SIMPLE_REPORT=false, a biblioteca pula /simples e mapeia
localmente a resposta bruta para reduzir tráfego.
Testes
python -m pytest
Teste real opcional contra o VALIDAR:
RUN_LIVE_VALIDAR_TESTS=1 python -m pytest tests/test_live_validar.py
Licença
MIT
Metadata
Release files for validar-iti 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| validar_iti-1.0.0.tar.gz | 13.6 kB | Without provenance | Details for validar_iti-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| validar_iti-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for validar_iti-1.0.0-py3-none-any.whl |
Total release size: 26.8 kB
Release files / validar_iti-1.0.0.tar.gz
| Download URL | validar_iti-1.0.0.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a26a84ce12f4845f69993efb30f6086fb1d87377eaf74905e31554f20711500
|
|
BLAKE2b-256 checksum How to use checksums |
81c5bf40960e7e31d315da4c8fbf4d97f5bc8c8b00688aacc22c828ce98d2c6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / validar_iti-1.0.0-py3-none-any.whl
| Download URL | validar_iti-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6afbb37e4cf4d436b2caa299191e6f7b020847938ba5883e2c555092df04ba62
|
|
BLAKE2b-256 checksum How to use checksums |
e850568225c0d6872470f9519f9ba8c4c3cea02829eb75b35e5580222c001467
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for validar-iti 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.