The Python interface to online accounting service Fakturoid.
Update to API v3 by Jan Tomek (jan.tomek@outlook.com). This library was created and developed by Roman Krejcik (farin@farin.cz). It is unofficial and no support from Fakturoid team can be claimed.
- Merge of rambousek's "InvoicePayments API" from pull requests #2 and #3
- Merge of nextsux's "fix: paginate subjects" from open pull request #16
- Merge of martn's "Bank accounts" from open pull request #11
- Merge of piit79's "Add support for InvoicesApi.find parameters until and updated_until" from open pull request #18
- Merge of piit79's "Fix paging by auto-detecting the page size" from open pull request #17 and open issue #14
- Update to v3 API, mostly update of authorization and small changes including metadata update
- Fork of python-fakturoid. Written by farin. Thank you for great work.
Install from PyPI uses v2 - for v3 use pip and overwrite files in site-packages/fakturoid with v3 files from github
pip install fakturoid
or alternatively install development version directly from github
pip install -e git+git://github.com/jan-tomek/python-fakturoid#egg=fakturoid
Supported Python versions are 2.6+ and 3.x. Dependencies are requests,
python-dateutil
Create context - change to v3 uses client id and client secret:
from fakturoid import Fakturoid
fa = Fakturoid('yourslug', 'your@email.com', 'clientid038dc73...', 'clientsecret7452f8..,','YourApp (yourname@example.com)')Print all regular invoices from year 2024:
from datetime import date
for invoice in fa.invoices(proforma=False, since=date(2024,1,1)):
print(invoice.number, invoice.total)Delete subject with id 27:
subject = fa.subject(27)
fa.delete(subject)And finally create new invoice:
from fakturoid import Invoice, InvoiceLine
invoice = Invoice(
subject_id=23205068,
#number='2025-0108',
due=10,
issued_on=date(2025, 1, 31),
taxable_fulfillment_due=date(2025, 1, 31),
lines=[
# use Decimal or string for floating values
InvoiceLine(name='Hard work', unit_name='h', unit_price=40000, vat_rate=21),
InvoiceLine(name='Soft material', quantity=12, unit_name='ks', unit_price="4.60", vat_rate=21),
]
)
fa.save(invoice)
print(invoice.due_on)Fakturoid.account()
Returns Account instance. Account is readonly and can't be updated by API.
Fakturoid.bank_accounts()
Returns list of BankAccount instances. Bank accounts are readonly and can't be updated by API.
Fakturoid.subject(id)
Returns Subject instance.
Fakturoid.subjects(since=None, updated_since=None, custom_id=None)
Loads all subjects filtered by args.
If since (date or datetime) parameter is passed, returns only subjects created since given date.
Fakturoid.subjects.search("General Motors")
Perform full text search on subjects
Fakturoid.invoce(id)
Returns Invoice instance.
Fakturoid.invoices(proforma=None, subject_id=None, since=None, updated_since=None, number=None, status=None, custom_id=None)
Use proforma=False/True parameter to load regular or proforma invoices only.
Returns list of invoices. Invoices are lazily loaded according to slicing.
fa.invoices(status='paid')[:100] # loads 100 paid invoices
fa.invoices()[-1] # loads first issued invoice (invoices are ordered from latest to first)Fakturoid.fire_invoice_event(id, event, **args)
Fires basic events on invoice. All events are described in Fakturoid API docs.
Pay event can accept optional arguments paid_at and paid_amount
fa.fire_invoice_event(11331402, 'pay', paid_at=date(2024, 11, 17), paid_amount=2000)Fakturoid.generator(id)
Returns Generator instance.
Fakturoid.generators(recurring=None, subject_id=None, since=None)
Use recurring=False/True parameter to load recurring or simple templates only.
Fakturoid.save(model)
Create or modify Subject, Invoice or Generator.
To modify or delete inoive lines simply edit lines
invoice = fa.invoices(number='2024-0002')[0]
invoice.lines[0].unit_price = 5000 # edit first item
del invoice.lines[-1] # delete last item
fa.save(invoice)Fakturoid.delete(model)
Delete Subject, Invoice or Generator.
subj = fa.subject(1234)
fa.delete(subj) # delete subject
fa.delete(Subject(id=1234)) # or alternativelly delete is possible without object loadingAll models fields are named same as Fakturoid API.
Values are mapped to corresponding int, decimal.Decimal, datetime.date and datetime.datetime types.
Fakturoid.Account
https://www.fakturoid.cz/api/v3/account
Fakturoid.BankAccount
https://www.fakturoid.cz/api/v3/bank-accounts
Fakturoid.Subject
https://www.fakturoid.cz/api/v3/subjects
Fakturoid.Invoices
Fakturoid.InvoiceLine
https://www.fakturoid.cz/api/v3/invoices
Fakturoid.Invoice Payments
https://www.fakturoid.cz/api/v3/invoice-payments
Fakturoid.Generators
https://www.fakturoid.cz/api/v3/generators
Use InvoiceLine for generator lines
Fakturoid.Invoice Messages