Skip to main content

Python client for the Fakturownia (InvoiceOcean) REST API

Project description

fakturownia-client

PyPI CI Python License: MIT

Python client for the Fakturownia (InvoiceOcean) REST API. Covers invoices (list/search, create/update, status changes, PDF download), clients (CRUD) and products.

Security note: token in header, never in URL

The official Fakturownia docs mostly show ?api_token=... in URLs, which leaks tokens into server and proxy logs. This client sends the token only in the Authorization: Bearer header. Header auth was verified against the live API for every endpoint used here (see scripts/verify_auth.py — a no-side-effects check you can run against your own account).

Install

uv add fakturownia-client   # or: pip install fakturownia-client

Usage

from fakturownia_client import FakturowniaClient, InvoiceCreate, InvoicePositionCreate

with FakturowniaClient("mycompany", api_token="...") as fk:
    # list & search
    invoices = fk.list_invoices(period="this_month", include_positions=True)
    for inv in fk.iter_invoices(period="this_year"):  # auto-pagination
        print(inv.number, inv.price_gross)

    # create
    created = fk.create_invoice(
        InvoiceCreate(
            buyer_name="ACME Sp. z o.o.",
            buyer_tax_no="1234567890",
            positions=[InvoicePositionCreate(name="Usługa", total_price_gross=123.00, tax=23)],
        )
    )

    # status & PDF
    fk.change_invoice_status(created.id, "paid")
    pdf = fk.download_invoice_pdf(created.id)

    # clients / products
    clients = fk.list_clients(tax_no="1234567890")
    products = fk.list_products()

Async

AsyncFakturowniaClient mirrors the sync API 1:1 on httpx.AsyncClient:

from fakturownia_client import AsyncFakturowniaClient

async with AsyncFakturowniaClient("mycompany", api_token="...") as fk:
    invoices = await fk.list_invoices(period="this_month")
    async for inv in fk.iter_invoices(period="this_year"):
        print(inv.number)

domain accepts "mycompany", "mycompany.fakturownia.pl" or a full URL.

InvoiceOcean

InvoiceOcean is the international brand of Fakturownia — same API. Pass your full domain: FakturowniaClient("mycompany.invoiceocean.com", api_token=...). There is also an official alias package, invoiceocean-client, which re-exports this API as InvoiceOceanClient / AsyncInvoiceOceanClient. Errors raise typed exceptions: AuthenticationError, NotFoundError, ValidationError, RateLimitError, ServerError (all subclass FakturowniaError).

Caveat: delete_product() calls an endpoint absent from the official API docs — it may not work on all accounts.

Development

uv sync --extra dev
uv run ruff check . && uv run mypy && uv run pytest -m "not live"

# optional read-only smoke test against the real API:
FAKTUROWNIA_DOMAIN=mycompany FAKTUROWNIA_API_TOKEN=... uv run pytest -m live

License

MIT

Project details


Download files

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

Source Distribution

fakturownia_client-0.1.1.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

fakturownia_client-0.1.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file fakturownia_client-0.1.1.tar.gz.

File metadata

  • Download URL: fakturownia_client-0.1.1.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fakturownia_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aedd58e2f05b24a4dd73dd0d9e227cd310b18061d478fbc86d69cd13d3f6f85c
MD5 d81b5962c74743f78ba04c2bc86f99db
BLAKE2b-256 163ad87508ed81ed49af3049148bb6ed61706b4928b4d931014f9932a2f13b60

See more details on using hashes here.

File details

Details for the file fakturownia_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fakturownia_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 590efd01496c2210e5eacbdffb2b1b48455ea28e6f03e20731db26e3bf5ef4e2
MD5 3b7229731e9b01de2ba68659598e30eb
BLAKE2b-256 f4a58e2ee3c965432140011276444f572d9f05ad8c718024de14f61528bc4048

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page