nfe¶
Modulo NFe: consulta, validação de chave e status SEFAZ.
NFeResponse ¶
StatusSEFAZResponse ¶
consultar_nfe
async
¶
Look up NFe (Nota Fiscal Eletrônica) data by access key.
The access key has 44 digits and is printed on the DANFE document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chave_acesso
|
str
|
44 digit NFe access key, accepted with or without spaces. |
required |
Returns:
| Type | Description |
|---|---|
NFeResponse
|
NFeResponse with issuer, recipient, items and totals. |
Raises:
| Type | Description |
|---|---|
FiscalValidationError
|
If the access key is invalid. |
FiscalNotFoundError
|
If the NFe is not found. |
FiscalHTTPError
|
If SEFAZ or an upstream API fails. |
consultar_status_sefaz
async
¶
Look up the current SEFAZ service status for a state.
Checks whether the SEFAZ NFe issuance webservice is operational.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uf
|
str
|
State abbreviation, for example 'SP', 'MG' or 'RJ'. |
required |
Returns:
| Type | Description |
|---|---|
StatusSEFAZResponse
|
StatusSEFAZResponse with current status and description. |
Raises:
| Type | Description |
|---|---|
FiscalValidationError
|
If the state abbreviation is invalid. |
validar_chave_nfe
async
¶
Validate the format and check digit of an NFe access key.
This does not call external APIs. It only verifies the modulo 11 check digit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chave_acesso
|
str
|
44 digit access key. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Dictionary with validity and decoded fields when valid. |
client ¶
NFe lookup client backed by BrasilAPI and the National NFe Portal.
NFEClient ¶
Client for NFe lookup flows.
consultar_por_chave
async
¶
Look up NFe data by its 44 digit access key.
Fallback chain
- BrasilAPI, with partial state coverage
- National NFe Portal, public lookup without authentication
- Partial fields extracted from the access key itself
consultar_status_servico
async
¶
Look up the SEFAZ service status for a state.
BrasilAPI acts as a proxy for the state SEFAZ webservice.
schemas ¶
tools ¶
MCP tools for NFe lookups and validation.
NFeValidationError ¶
Bases: FiscalValidationError, ValidationError
Validation error compatible with both core and legacy exception hierarchies.
consultar_nfe
async
¶
Look up NFe (Nota Fiscal Eletrônica) data by access key.
The access key has 44 digits and is printed on the DANFE document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chave_acesso
|
str
|
44 digit NFe access key, accepted with or without spaces. |
required |
Returns:
| Type | Description |
|---|---|
NFeResponse
|
NFeResponse with issuer, recipient, items and totals. |
Raises:
| Type | Description |
|---|---|
FiscalValidationError
|
If the access key is invalid. |
FiscalNotFoundError
|
If the NFe is not found. |
FiscalHTTPError
|
If SEFAZ or an upstream API fails. |
validar_chave_nfe
async
¶
Validate the format and check digit of an NFe access key.
This does not call external APIs. It only verifies the modulo 11 check digit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chave_acesso
|
str
|
44 digit access key. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Dictionary with validity and decoded fields when valid. |
consultar_status_sefaz
async
¶
Look up the current SEFAZ service status for a state.
Checks whether the SEFAZ NFe issuance webservice is operational.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uf
|
str
|
State abbreviation, for example 'SP', 'MG' or 'RJ'. |
required |
Returns:
| Type | Description |
|---|---|
StatusSEFAZResponse
|
StatusSEFAZResponse with current status and description. |
Raises:
| Type | Description |
|---|---|
FiscalValidationError
|
If the state abbreviation is invalid. |