brazil-fiscal-client
A simple, modern and well tested SOAP client for the Brazilian Fiscal Authority.
This client is designed to be inherited by specialized clients such as for electronic invoicing (NFe). But with some extra boiler plate code to deal with the SOAP enveloppe, it can still be used alone as you can see in the usage section below.
It uses xsdata as a soft dependency for the databinding and it overrides its SOAP client
Installation
pip install brazil-fiscal-client
If you want xsdata databinding/parsing support (recommended for nfelib/Odoo and advanced SOAP use cases), install the optional extra:
pip install brazil-fiscal-client[xsdata]
Usage
For instance, with an appropriate pkcs12 certificate, you can query the NFe server status (remember specialized clients make all this simpler):
from brazil_fiscal_client.fiscal_client import FiscalClient
from tests.fixtures.nfestatusservico4 import NfeStatusServico4SoapNfeStatusServicoNf
from nfelib.nfe.bindings.v4_0.cons_stat_serv_v4_00 import ConsStatServ
from nfelib.nfe.bindings.v4_0.ret_cons_stat_serv_v4_00 import RetConsStatServ
ambiente = "2"
path_to_your_pkcs12_certificate = "/path_to_your_certificate/pkcs12_certificate.p12"
certificate_password = "your_certificate_password"
with open(path_to_your_pkcs12_certificate, "rb") as pkcs12_buffer:
pkcs12_data = pkcs12_buffer.read()
client = FiscalClient(
ambiente=ambiente,
versao="4.00",
pkcs12_data=pkcs12_data,
pkcs12_password=your_certificate_password,
)
result = client.send(
NfeStatusServico4SoapNfeStatusServicoNf,
"https://nfe-homologacao.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx",
{
"Body": {
"nfeDadosMsg": {
"content": [
ConsStatServ(
tpAmb="2",
cUF="42",
xServ="STATUS",
versao="4.00",
),
]
}
}
},
)
>>> result.body.nfeResultMsg.content[0]
RetConsStatServ(tpAmb=<Tamb.VALUE_2: '2'>, verAplic='SVRS202401251654', cStat='107', xMotivo='Servico SVC em Operacao', cUF=<TcodUfIbge.VALUE_42: '42'>, dhRecbto='2024-04-01T16:18:03-03:00', tMed='1', dhRetorno=None, xObs=None, versao='4.00')
>>> result.body.nfeResultMsg.content[0].cStat
'107'
Notice this example uses the ConsStatServ and RetConsStatServ bindings from
nfelib. In this example
NfeStatusServico4SoapNfeStatusServicoNf has been generated from a previously
downloaded wsdl file and using the
WSDL xsdata generator.
All this is usually done in the specialized clients that override this base
brazil-fiscal-clientSOAP client.
Usage without xsdata (requests-only mode)
If xsdata is not installed, FiscalClient still works for basic SOAP calls using
plain XML payloads (string/bytes). In this mode, send() returns the raw SOAP XML
response string.
from brazil_fiscal_client.fiscal_client import FiscalClient
client = FiscalClient(
ambiente="2",
versao="4.00",
pkcs12_data=pkcs12_data,
pkcs12_password=certificate_password,
fake_certificate=True,
)
raw_response_xml = client.send(
action_class=None, # not required in requests-only mode
location="https://example.com/service",
wrapped_obj="""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>...</soapenv:Body>
</soapenv:Envelope>
""",
)
Metadata
Release files for brazil-fiscal-client 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 | |
|---|---|---|---|
| brazil_fiscal_client-1.0.0.tar.gz | 17.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| brazil_fiscal_client-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.4 kB
Release files / brazil_fiscal_client-1.0.0.tar.gz
| Download URL | brazil_fiscal_client-1.0.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17f0f314ff7b3c3dcfda340050904d7344615ec74ee8e7d0af88931503f080d1
|
|
BLAKE2b-256 checksum How to use checksums |
e3a915ad80a685eca8b306eb0ede699bb49fac40293d27d24a4e5c5f9bfd770c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / brazil_fiscal_client-1.0.0-py3-none-any.whl
| Download URL | brazil_fiscal_client-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23d8852e57c260b19bd90e64d3cfa01983e4959f80f24aef1d88543c1552cedd
|
|
BLAKE2b-256 checksum How to use checksums |
dcfa7c69b5cad79d95afa07b0ed4395609075115179c7e19241cf7557751372e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency log