CLI for the Polish National e-Invoice System (KSeF). Packaged as a single .exe via PyInstaller.
- Download
ksef-tools.exefrom Releases - Copy
config.json.exampletoconfig.jsonnext to the.exe - Fill in your KSeF credentials in
config.json
ksef-tools send invoice.xml
ksef-tools list --days 30
ksef-tools qr invoice.xmlCreate config.json next to the executable (or in the working directory for dev mode):
{
"ksef_token": "your_token_here",
"context_type": "nip",
"context_value": "1234567890",
"base_url": "https://ksef-demo.mf.gov.pl",
"subject_type": "Subject1",
"date_type": "Issue"
}| Field | Required | Default | Description |
|---|---|---|---|
ksef_token |
yes | - | KSeF authorization token |
context_type |
yes | - | Context type (nip) |
context_value |
yes | - | Tax identification number (NIP) |
base_url |
no | https://ksef-demo.mf.gov.pl |
KSeF API endpoint |
subject_type |
no | Subject1 |
Subject1 = sales, Subject2 = purchases |
date_type |
no | Issue |
Issue = invoice date, Receive = KSeF receive date |
Send an invoice XML file to KSeF:
ksef-tools send <path_to_xml_file>Returns JSON with ksef_number, reference_number, verification_url (QR Code I link), and processing status.
List invoices from the last N days:
ksef-tools list --days 30 --page-size 10Returns JSON with invoice metadata.
Generate a KSeF QR Code I verification link for an invoice:
ksef-tools qr <path_to_xml_file> [--nip NIP] [--date YYYY-MM-DD]Reads the invoice issue date (P_1) and seller NIP from config. Returns JSON with verification_url.
python -m venv venv
venv\Scripts\activate
pip install -e ".[build]"
ksef-tools --versionpython build.py
dist\ksef-tools.exe --versionPush a version tag to trigger CI build and GitHub Release:
git tag v0.1.0
git push origin v0.1.0