{"id":15551613,"url":"https://github.com/pprzetacznik/ksef-utils","last_synced_at":"2025-04-23T20:25:07.565Z","repository":{"id":209501030,"uuid":"723856255","full_name":"pprzetacznik/ksef-utils","owner":"pprzetacznik","description":"KSeF Python client for creating invoices","archived":false,"fork":false,"pushed_at":"2024-12-29T18:36:25.000Z","size":65,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-18T04:55:42.521Z","etag":null,"topics":["invoicing","ksef","openapi","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/ksef-utils/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pprzetacznik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-26T22:57:19.000Z","updated_at":"2024-12-29T18:36:28.000Z","dependencies_parsed_at":"2023-11-27T18:25:36.125Z","dependency_job_id":"83aca11c-730e-407b-9c9d-8627951ad9db","html_url":"https://github.com/pprzetacznik/ksef-utils","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":0.25,"last_synced_commit":"c55b5297ed057ac7ff2fe7c606d87432642cea8c"},"previous_names":["pprzetacznik/ksef-utils"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprzetacznik%2Fksef-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprzetacznik%2Fksef-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprzetacznik%2Fksef-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprzetacznik%2Fksef-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pprzetacznik","download_url":"https://codeload.github.com/pprzetacznik/ksef-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250507447,"owners_count":21441996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["invoicing","ksef","openapi","python"],"created_at":"2024-10-02T14:05:47.719Z","updated_at":"2025-04-23T20:25:07.548Z","avatar_url":"https://github.com/pprzetacznik.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KSeF utils\n\n[![ksef-utils Release](https://github.com/pprzetacznik/ksef-utils/actions/workflows/release.yml/badge.svg)](https://github.com/pprzetacznik/ksef-utils/actions/workflows/release.yml)\n[![ksef-utils Test](https://github.com/pprzetacznik/ksef-utils/actions/workflows/test.yml/badge.svg)](https://github.com/pprzetacznik/ksef-utils/actions/workflows/test.yml)\n[![PyPI version](https://badge.fury.io/py/ksef-utils.svg)](https://pypi.org/project/ksef-utils/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ksef-utils)](https://pypi.org/project/ksef-utils/)\n[![Documentation Status](https://readthedocs.org/projects/ksef-utils/badge/?version=latest)](https://ksef-utils.readthedocs.io/en/latest/?badge=latest)\n\nThis project contains Python utilities and example requests that can be helpful when integrating with Polish central invoicing system called [Krajowy System e-Faktur (KSeF)](https://www.podatki.gov.pl/ksef/).\n\n## Installation\n\n### Creating python virtual environment\n\nSee [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/) documentation.\n\n```Bash\n$ mkvirtualenv ksef\n$ workon ksef\n(ksef) $\n```\n\n### Installing package from source\n\n```Bash\n(ksef) $ git clone https://github.com/pprzetacznik/ksef-utils.git\n(ksef) $ cd ksef-utils\n(ksef) $ pip install -e .\n```\n\n### Installing package from PyPI\n\n```Bash\n(ksef) $ pip install ksef-utils\n```\n\n## Run tests\n\n### Set up secrets\n\nLog in to https://ksef-test.mf.gov.pl/web/ and generate your individual `KSEF_TOKEN`.\n\n```Bash\n#!/bin/bash\n\nexport KSEF_TOKEN=\"...\"\nexport KSEF_ENV=\"test\"\nexport KSEF_NIP=\"...\"\nexport KSEF_SIGN_CERT_PATH=\"cert.pem\"\nexport KSEF_SIGN_KEY_PATH=\"privkey.pem\"\nexport KSEF_SIGN_CA_PATH=\"cert.pem\"\n```\n\n### Generate test cert\n\n```Bash\nKSEF_NIP=${KSEF_NIP:-2222222222}\nKSEF_SUBJECT=\"/CN=John Doe/SN=Doe/GN=John/O=My Corp/C=PL/L=Lesser Voivodeship/serialNumber=NIP-${KSEF_NIP}/description=John Doe NIP-${KSEF_NIP}\"\nopenssl req -x509 \\\n  -nodes \\\n  -subj \"${KSEF_SUBJECT}\" \\\n  -days 365 \\\n  -newkey rsa \\\n  -keyout $KSEF_SIGN_KEY_PATH \\\n  -out $KSEF_SIGN_CERT_PATH\n```\n\n### Run pytest framework\n\n```Bash\n(ksef) $ pip install -r requirements.txt\n(ksef) $ pytest -svvv\n```\n\n### Markers\n\nRun all e2e/functional/current tests\n```\n(ksef) $ pytest -svvv tests/test_ksef.py -m \"e2e and not ignore\"\n(ksef) $ pytest -svvv tests/test_ksef.py -m \"functional and not ignore\"\n(ksef) $ pytest -svvv tests/test_ksef.py -m \"current and not ignore\"\n(ksef) $ ./run_tests.sh\n(ksef) $ TESTS_MARKERS=\"init_signed and functional and not ignore\" ./run_tests.sh\n```\n\n## Example\n\nSee [tests/test_e2e.py](tests/test_e2e.py) for detailed examples of usage.\n\n```Python\nfrom ksef_utils.server import KSEFServer, KSEFService\nfrom ksef_utils.config import TestConfig, DemoConfig, ProdConfig\n\nconfig = TestConfig()\nserver = KSEFServer(config)\nservice = KSEFService(service)\n\ninvoice_data = {\n    # ...\n    # see tests/conftest.py for example json invoice\n}\n\nsession_token = service.init_signed()\nresponse_send_invoice = service.send_invoice(**invoice_data)\n```\n\n## Using cli utilities\n\n```\n(ksef) $ python -m ksef_utils keygen --identifier 1111111111 --identifier_type NIP --working_directory .\n(ksef) $ pip install .\n(ksef) $ which ksef-utils\n(...)/.envs/bin/ksef-utils\n(ksef) $ ksef-utils keygen --identifier 1111111111 --identifier_type PESEL --working_directory .\n```\n\n## OpenAPI\n\n```\n/openapi/gtw/svc/api/KSeF-common.yaml\n/openapi/gtw/svc/api/KSeF-batch.yaml\n/openapi/gtw/svc/api/KSeF-online.yaml\n```\n\n## Publish new release\n\n```Bash\n$ git tag v1.0\n$ git push origin v1.0\n```\n\n## Building documentation\n\n```Bash\n(ksef) $ sphinx-build -M html docs docs_build\n```\n\n## KSEF references\n\n* https://www.podatki.gov.pl/ksef/\n* https://ksef-test.mf.gov.pl/web/\n* https://www.youtube.com/watch?v=dnBGO6IPtzA\n\n## TODO\n\n* Checking if upo can be downloaded after termination of the session\n\n## Contributing\n\n* https://www.conventionalcommits.org/en/v1.0.0/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpprzetacznik%2Fksef-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpprzetacznik%2Fksef-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpprzetacznik%2Fksef-utils/lists"}