Skip to main content

shade-plugins-nfe-distribuicao

Plugin do ShadeOne que baixa o XML das NF-e de entrada de cada cliente pelo webservice oficial NFeDistribuicaoDFe do Ambiente Nacional (SEFAZ), com o e-CNPJ do próprio cliente. Sem tela e sem captcha.

Uso

No shade.toml do robô:

[hosts]
permitidos = ["www1.nfe.fazenda.gov.br"]

[certificado]
modo = "por_cnpj"
coluna = "cnpj"

[config]
nfe_distribuicao_ambiente = "producao"   # ou "homologacao" (hom1.nfe.fazenda.gov.br)
nfe_distribuicao_uf = "35"               # opcional: código IBGE da UF do autor

[plugins]
nfe-distribuicao = "0.1.0"

No robô:

import shade_plugins_nfe_distribuicao as nfe

for nota in nfe.xmls_de_entrada(item["cnpj"]):
    if nota["completo"]:
        print(nota["chave"], nota["arquivo"])  # xmls_de_entrada/<chave>.xml, já anexado ao item

xmls_de_entrada(cnpj)

Devolve as NF-e em que o CNPJ é destinatário, a partir do último NSU guardado. Cada item da lista tem chave, nsu, completo, xml (bytes) e arquivo.

  • Só lê e anexa. O plugin não manifesta o destinatário. O serviço entrega o XML completo da nota depois que o destinatário manifestou; as demais chegam como resumo (completo falso, sem xml nem arquivo). A Ciência da Operação é decisão de quem recebe a nota.
  • O último NSU fica guardado por CNPJ, em estado/nfe-distribuicao/ no diretório de trabalho, e só avança depois de os arquivos da página estarem no disco e anexados ao item. Uma queda no meio repete a página, nunca a perde, e a chamada seguinte baixa só o que é novo.
  • Limite de consumo. Quem chega ao fim da fila só deve consultar de novo uma hora depois: antes disso a chamada devolve lista vazia sem ir à SEFAZ. Se a SEFAZ responder cStat 656, o plugin levanta ConsumoIndevido com aguardar_ate e guarda a espera; não repete na hora.
  • No ensaio a consulta roda, mas nada é gravado nem anexado e o NSU não avança.
  • Até 20 páginas (1.000 documentos) por chamada; o resto vem na chamada seguinte. Cada XML anexado respeita o teto de 8 MiB por arquivo do run.
  • CNPJ de 14 dígitos numéricos; o certificado precisa ter o mesmo CNPJ-base.

Erros

  • DistribuicaoIndisponivel: falha técnica (SEFAZ fora do ar, sem resposta, resposta fora da forma). O laço do robô repete o item.
  • RecusaDaSefaz (ErroDeNegocio): motivo é certificado_recusado, certificado_de_outro_cnpj, nsu_invalido ou entrada_invalida. Não repete.
  • ConsumoIndevido (ErroDeNegocio): aguardar_ate diz quando consultar de novo.

As mensagens trazem o status e o código da SEFAZ, nunca o CNPJ, o certificado nem o corpo.

Licença

Apache-2.0. O pedido e a resposta usam os bindings do nfelib (MIT), gerados dos XSDs oficiais.

Metadata

Release files for shade-plugins-nfe-distribuicao 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for shade-plugins-nfe-distribuicao 0.1.0
File Interpreter ABI Platform Actions
shade_plugins_nfe_distribuicao-0.1.0-py3-none-any.whl Python 3 none any Details for shade_plugins_nfe_distribuicao-0.1.0-py3-none-any.whl

Release files / shade_plugins_nfe_distribuicao-0.1.0-py3-none-any.whl

Download URL shade_plugins_nfe_distribuicao-0.1.0-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d39c32f048bf82b00a986e9cad24d18abf4472b3b3d65548844a952a1860162
BLAKE2b-256 checksum
How to use checksums
f0da54e0aee33d8db9be7806c2d156d4c57684f1be2db0fde08f47da5400e68d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for shade-plugins-nfe-distribuicao 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page