Skip to content

KSeF CLI

ksef
automation
cli
go

In Poland, we now have KSeF (national e-invoicing system if you will) which allows for fetching structured invoices data through their API.

I built a small CLI to interact with it to make it less manual. It isn’t production-grade integration but it’s fine for local personal use.

KSeF CLI GitHub

It handles:

  • awkward bootstrap auth flow,
  • generates tokens,
  • lists invoices for a given month,
  • downloads invoice XMLs,
  • exports metadata to CSV,
  • renders PDF views from the structured data.

One ksef download-pdfs gives me a reproducible monthly package of the KSeF invoices. Replaces clicking around in a browser and copy-pasting files into folders.

I made a post about fetching pdf invoices from gmail automatically as well. Now I use these two tools to automate my monthly accounts chores.