Skip to main content

Integrate once. Issue everywhere.

Python License


stackin

Python SDK for fiscal document issuance — a handful of business fields, nothing about certificates, XML, XSD, signing or SOAP. The API resolves all of that from the issuer's own configuration, identified by api_key.

One class, Invoiceissue()/consult()/cancel(), nothing else to instantiate. Each line item is a Product (stackin.br) — description/amount are universal, everything else (ncm/cfop/cest/tax groups...) is Brazil-specific and only required for NFE; NFSE ignores it.

Install

pip install stackin-python-sdk

Usage

Get an api_key from the stackin dashboard — select the issuing company, then Settings → API key. One key per issuing company, shown once at creation. The API resolves the issuer (CNPJ, state, address, certificate, environment) entirely from it; nothing about the issuer is ever passed on a call.

from stackin import Invoice, DocumentType, Address
from stackin.br import Product  # Brazil-specific line item — NCM/CFOP

client = Invoice(api_key="COMPANY_API_KEY")  # defaults to https://sdk.stackin.io

invoice = client.issue(
    document_type=DocumentType.NFSE,
    client_name="John Doe",
    tax_id="00000000000",
    items=[Product(description="Software development", amount=5000.00)],
)

status = client.consult("ACCESS_KEY...", document_type=DocumentType.NFSE)
client.cancel(
    "ACCESS_KEY...",
    document_type=DocumentType.NFSE,
    reason="Typo",
)

# NFE requires ncm/cfop on every item, and optionally recipient_address.state
# to get idDest right on interstate sales:
client.issue(
    document_type=DocumentType.NFE,
    client_name="Buyer Company Ltd",
    tax_id="11111111111111",
    items=[Product(description="Test product", amount=100.00, ncm="84713012", cfop="5102")],
    recipient_address=Address(state="RJ"),
)

recipient_address is an Address, but despite the name only .state is read — the rest of the fields aren't sent anywhere yet. It's the actual customer's state, used only to set idDest (interstate vs internal) on NFE — optional, omitting it always produces idDest=1 (internal).

items is a list of Product (stackin.br) — description/amount apply to any document type; ncm/cfop (plus everything else on Product: cest, tax groups, presumed credits...) are Brazil-specific and required per item for NFE, ignored for NFSE (a service isn't a physical good).

Errors

  • stackin.APIError — the API responded with a non-2xx status (status_code, detail) — a 401 here means api_key is missing, wrong, or was rotated.
  • stackin.ConnectionFailedError — the API didn't respond (network/DNS/timeout).
  • ValueErrorissue()'s items is empty, or missing ncm/cfop on an item for NFE.

Building the full fiscal document (issuer data, service code, tax groups, schema-accurate XML) is the API's job — configured once per company, not passed on every call.

Examples

Runnable end-to-end scripts in examples/simple_issue_nfe.py and simple_issue_nfse.py, each with a catalog of realistic line items covering every optional field.

Commit Style

Icon Type Description
⚙️ FEATURE New feature
📝 PEP8 Formatting fixes following PEP8
📌 ISSUE Reference to issue
🪲 BUG Bug fix
📘 DOCS Documentation changes
📦 PyPI PyPI releases
❤️️ TEST Automated tests
⬆️ CI/CD Changes in continuous integration/delivery
⚠️ SECURITY Security improvements

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stackin_python_sdk-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stackin_python_sdk-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file stackin_python_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: stackin_python_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for stackin_python_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6067c110a72264a8f4cbc72bf894ad625ad9ef70445c6bccb21a15d47d31f873
MD5 b6807cf69ff66eb4fd3b64c6cb71ca20
BLAKE2b-256 91bbef7c268327673d4d40173099f9fac7cf89711de54165a0c6f1babb596718

See more details on using hashes here.

Provenance

The following attestation bundles were made for stackin_python_sdk-0.1.0.tar.gz:

Publisher: python-publish-pypi.yml on stackin-io/stackin-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stackin_python_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stackin_python_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00c3ed8fe54e3f554f2a2ef53d530ad586211a21036f3e45dd07960c584fea52
MD5 1093989e76323db0883cb1ca7de8adda
BLAKE2b-256 1071f238098f7f1f2a2d1a8b27e396cf0680e225e7afeb05e67ee70f46b292d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for stackin_python_sdk-0.1.0-py3-none-any.whl:

Publisher: python-publish-pypi.yml on stackin-io/stackin-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

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