Skip to main content

Fatoority Python bindings

This package wraps Diplomat-generated native bindings with the public fatoora Python API. Install with pip install fatoority and import as fatoora. See Diplomat bindings.

Development (uv)

uv venv
uv pip install .

Build a wheel (uv)

uv build --wheel

Wheels (CI)

  • GitHub Actions uses cibuildwheel to produce platform wheels in dist/ (wheel-only publishing).
  • See .github/workflows/python.yml for the build matrix.

Notes

  • The build step compiles fatoora-ffi with cargo build -p fatoora-ffi --release.
  • The shared library is bundled into the Python package.
  • Building the native extension requires CMake and a C++20 compiler. Nanobind is pinned in the build dependencies. Reinstall the package after native changes.
  • ZATCA API responses are exposed via owned objects with read-only properties (no JSON payloads).
  • Errors are raised as typed exceptions mapped from FFI error codes (see FfiErrorKind). Each exception exposes .code, .kind, and .details, a dictionary containing structured validation issues or diagnostics. Unknown codes remain available on a generic FfiError.
  • Reinstall the package after changes; the extension loads its bundled shared library.

Examples

python examples/load_lib.py
python examples/invoice_basic.py
python examples/invoice_parse.py

Tests

uv pip install -e .[dev]
SKIP_ZATCA_LIVE_API=1 uv run pytest tests

High-level API

from datetime import datetime, timezone
from uuid import uuid4

from fatoora import (Address, InvoiceBuilder, InvoiceSubType, InvoiceTypeKind,
                     PaymentMeans, VatCategory)

invoice = (
    InvoiceBuilder(
        InvoiceTypeKind.TAX, InvoiceSubType.SIMPLIFIED,
        id="INV-1",
        uuid=uuid4(),
        issue_datetime=datetime.now(timezone.utc),
        currency="SAR",
        previous_invoice_hash="hash",
        invoice_counter=1,
        vat_category=VatCategory.STANDARD,
    )
    .set_seller("Acme Inc", vat_id="399999999900003",
                address=Address("SAU", "Riyadh", "King Fahd", "1234", "12222"))
    .add_payment_means(PaymentMeans("10"))
    .add_line_item(description="Item", quantity="1.0", unit_code="PCE",
                   unit_price="100.0", vat_rate="15.0", vat_category=VatCategory.STANDARD)
    .build()
)
print(invoice.id, invoice.issue_datetime, invoice.totals.payable_amount)
print(invoice.xml)

Header fields can be passed to the constructor or set with the chaining setters. Timestamps accept a timezone-aware datetime or YYYY-MM-DDTHH:MM:SSZ text; UUIDs accept uuid.UUID or text. Invoice data is read through properties (invoice.seller.address.city) and returned as frozen dataclasses (Party, Address, Adjustment, InvoiceLineItem, ...) that can be passed back to a builder: InvoiceBuilder(..., seller=parsed.seller).

Local ZATCA validation

from fatoora import validate_zatca

report = validate_zatca(xml, previous_invoice_hash=previous_hash_from_history)
if not report.is_valid:
    for finding in report.findings:
        print(finding.severity.value, finding.code, finding.message)

validate_zatca returns a frozen ZatcaReport dataclass (report.to_json() gives the JSON report). The report retains warnings and distinguishes rejection from incomplete coverage. Missing predecessor context leaves the report incomplete. Execution failures raise a typed exception with any partial report in error.details["report"]. Standard invoices skip signature/QR checks in this SDK profile. Local integrity does not establish issuer trust or remote acceptance. The wheel embeds runtime schemas and native rules; Java, SDK files and a source checkout are unnecessary.

Deprecations

0.6 turns getters into properties (a hard break: drop the parentheses) and renames parts of the 0.5 API (Signer -> InvoiceSigner, ...). The renamed names keep working with a DeprecationWarning until 0.7; see the Python reference. The public surface is recorded in tests/public_api.json; regenerate it after an intentional change with python tests/test_public_api.py --update.

Metadata

Release files for fatoority 0.6.0

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

Built distributions (wheels)

Table of built distributions (wheels) for fatoority 0.6.0
File Actions
fatoority-0.6.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for fatoority-0.6.0-cp313-cp313-win_amd64.whl
fatoority-0.6.0-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for fatoority-0.6.0-cp313-cp313-manylinux_2_28_x86_64.whl
fatoority-0.6.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for fatoority-0.6.0-cp313-cp313-macosx_11_0_arm64.whl
fatoority-0.6.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for fatoority-0.6.0-cp312-cp312-win_amd64.whl
fatoority-0.6.0-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for fatoority-0.6.0-cp312-cp312-manylinux_2_28_x86_64.whl
fatoority-0.6.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for fatoority-0.6.0-cp312-cp312-macosx_11_0_arm64.whl
fatoority-0.6.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for fatoority-0.6.0-cp311-cp311-win_amd64.whl
fatoority-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for fatoority-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl
fatoority-0.6.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for fatoority-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
fatoority-0.6.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for fatoority-0.6.0-cp310-cp310-win_amd64.whl
fatoority-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details for fatoority-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl
fatoority-0.6.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for fatoority-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
fatoority-0.6.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for fatoority-0.6.0-cp39-cp39-win_amd64.whl
fatoority-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64 Details for fatoority-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl
fatoority-0.6.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details for fatoority-0.6.0-cp39-cp39-macosx_11_0_arm64.whl

Total release size: 85.0 MB

Release files / fatoority-0.6.0-cp313-cp313-win_amd64.whl

Download URL fatoority-0.6.0-cp313-cp313-win_amd64.whl
Size 5.5 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
13155e63fb55de4440bdde12f10936f0543f636108b45caa04dffa43ca8770fc
BLAKE2b-256 checksum
How to use checksums
151cdef1d1d77d8101d40c1be99288e7b7fc5a4903b7009d1303c820a5705dfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL fatoority-0.6.0-cp313-cp313-manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e4c9bebf1af974b7ff27a11f91387a71a0324c6567bc1aee6d0e071bc74dbfb3
BLAKE2b-256 checksum
How to use checksums
af63036b398028ad7a878b53c15184e76a9d6ce7bee83a74f4f288733771e85d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL fatoority-0.6.0-cp313-cp313-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9bdc5af528e5294dd09965853218ad87d42c29ab90beb9cdc523063c48bc0e0d
BLAKE2b-256 checksum
How to use checksums
3921b689e134f3f055a4b478c47b0ea8d17fdcdbc071bee3ee43ff7812f5739f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp312-cp312-win_amd64.whl

Download URL fatoority-0.6.0-cp312-cp312-win_amd64.whl
Size 5.5 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
b8044c6bb189978e8b964cb98a4a3531b0b6b14a51c499b5e884b1b923236334
BLAKE2b-256 checksum
How to use checksums
6ffd6560f06bf5e4cb71d3c223d6fcfc418a5dde0a36bbcf331db925edddc06f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL fatoority-0.6.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
830f8744cbdb93d2661496b0450ed511af7653ca3a5c981a414a94c0f8b7dbfd
BLAKE2b-256 checksum
How to use checksums
dec974a8ac681998c83f9436a56781bbca7442b2741edc25a6ea1e11371fbff1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL fatoority-0.6.0-cp312-cp312-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ca9b87c7ecf01f11e693c496514a26357ebee0e4960a1658ed9fc8d61c7ece4d
BLAKE2b-256 checksum
How to use checksums
b827c7662f8867681aec9419e37f7104fa7838034cf274c3c7415a563d72e52b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp311-cp311-win_amd64.whl

Download URL fatoority-0.6.0-cp311-cp311-win_amd64.whl
Size 5.5 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
fdd96cd8887123ac02f08feb63caaa525a161d9e0fb6ec9e42fea3bf193120c1
BLAKE2b-256 checksum
How to use checksums
3d715936608a3b49919e771055a91c44ccd08ae007bfe598a2d90804fa07bb47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL fatoority-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0b2fde229cf12c18b55965a69b025cf0e57363d527db46abb4f08c81ff81a12e
BLAKE2b-256 checksum
How to use checksums
6671fee5d74f717b44e9390577510876e73c3b662da85d600018dc536e8ea905
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL fatoority-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4fb972fb4bc94cae513873054bc19e2676470405f6402a8bc1e6ce721abe5eb8
BLAKE2b-256 checksum
How to use checksums
133d68cd3f99b49b20fe6d6fd279c9cfc30f50a75dafcf4151be968440850092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp310-cp310-win_amd64.whl

Download URL fatoority-0.6.0-cp310-cp310-win_amd64.whl
Size 5.5 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
5ecde9f80df356134440a4689637a79531176293fa9ee698342d5952665f2571
BLAKE2b-256 checksum
How to use checksums
9c922ed4e4fb08b52b94680cb717885ffaca7548cc0345ef6adfb6463cdf6643
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL fatoority-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5f28470587fa23da634bc84c36fb3fd7e0dbc484049fe0af642e4a3c011a641f
BLAKE2b-256 checksum
How to use checksums
8831ffd552ad4bec36cf76d2e1aab39fabd96c8588c501bd61f5923ca119d0c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL fatoority-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e8277ae341b5bde57220dc8edc3e7c7252a8b88dc22a5ca7f059e2ab6ed2d2b4
BLAKE2b-256 checksum
How to use checksums
f58167ea0ea5b6640a7f54f7c18eca8bfeadec7ab683f62f801f5815f3aa345b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp39-cp39-win_amd64.whl

Download URL fatoority-0.6.0-cp39-cp39-win_amd64.whl
Size 5.5 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
0308f2ba72ac1abadf464987e4b5605ba28df7e4f5f3f4fe1dcf895f8835c0d4
BLAKE2b-256 checksum
How to use checksums
4ce473fa23990286177839b00a376882d9024ddf18dcc07004a2f917bbe506e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl

Download URL fatoority-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9d20a114e55609a8fd66eb2e290e84df569ccad1ab821a14c95b117de4ee452b
BLAKE2b-256 checksum
How to use checksums
4301032b4058f68117273313a3b662a09a5c66a1568382a14718bb9185e4c35d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / fatoority-0.6.0-cp39-cp39-macosx_11_0_arm64.whl

Download URL fatoority-0.6.0-cp39-cp39-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d1ca122cc3900d59319941e06830c463d4f85add0e46351712e110f9919bc7e0
BLAKE2b-256 checksum
How to use checksums
d330eb3066ade6f6abd0694b25a177d18a19672f3bc9dfe4db27db87e9c13a2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Security for fatoority 0.6.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.

Full provenance

All 15 files in this release have been uploaded with provenance metadata.

Select from 15 files

Attestation for fatoority-0.6.0-cp313-cp313-win_amd64.whl

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 Nov 17, 2026.

Transparency log

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.

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