Browser-backed FastAPI service and web UI for extracting reports from spending.gov.ua by EDRPOU, date range, and report form.
The project uses Playwright + Chromium instead of direct requests/curl, because the portal often blocks or breaks plain HTTP clients and headless scraping.
- search reports for one EDRPOU or a batch of EDRPOU codes
- filter by year, date range, report type name, or report type id
- summarize which report forms exist across a group of organizations
- export raw JSON report payloads into ZIP archives
- render individual reports as readable HTML tables
- generate PDF versions of individual reports
- batch-export all available
Form 2reports for a predefined EDRPOU list
GET /GET /healthGET /api/catalog/{edrpou}POST /api/reports/searchPOST /api/report-types/summaryGET /api/reports/{edrpou}/{report_id}/htmlGET /api/reports/{edrpou}/{report_id}/pdfPOST /api/reports/export/zip
uv venv
.venv\Scripts\activate
uv pip install -e .
python -m playwright install chromium
uvicorn spendinggovua_api.main:app --reloadAfter startup:
- UI:
http://127.0.0.1:8000/ - Swagger:
http://127.0.0.1:8000/docs - OpenAPI JSON:
http://127.0.0.1:8000/openapi.json
After installation, two CLI commands are available:
spendinggovua-api
spendinggovua-form2-exportYou can also run the API as a module:
python -m spendinggovua_apiuv buildArtifacts are written to dist/.
Search reports:
{
"edrpous": ["43861328", "02125473"],
"report_types": ["Форма № 2"],
"date_from": "2021-01-01",
"date_to": "2025-12-31",
"include_details": false
}Summarize available forms:
{
"edrpous": ["43861328", "02125473", "02071033"]
}Single report HTML and PDF:
/api/reports/43861328/1701610529/html
/api/reports/43861328/1701610529/pdf
POST /api/reports/export/zip returns:
manifest.jsonin the archive root- one folder per EDRPOU
index.jsonand report files when reports were foundno_reports.jsonwhen no reports matched the filterserror.jsonwhen the source portal failed for that EDRPOU
Example request:
{
"edrpous": ["43861328", "02125473"],
"report_types": ["Форма № 2"],
"include_details": true,
"latest_only_per_edrpou": false
}For a concrete reportId, the service can build:
- HTML with the report header and table layout
- PDF generated by Chromium from the same HTML
This is useful when you need a readable document instead of only raw JSON cells.
To build one archive with all available Form 2 reports for the predefined EDRPOU list:
.venv\Scripts\python scripts\export_form2_html_zip.pyThe script writes the resulting ZIP archive to output/.
To assemble the package artifacts, GitHub description draft, Dockerfile, and the batch Form 2 archive into one distributable ZIP:
.venv\Scripts\python scripts\build_delivery_bundle.pyThe resulting bundle is written to release/.
This project is distributed under the MIT License. See LICENSE.
Important: the MIT license applies to the source code in this repository. It does not automatically change the legal status of data or content obtained from spending.gov.ua, which may be subject to separate terms or source licensing.
spendinggovua_api/main.py- FastAPI app and HTTP routesspendinggovua_api/spending_client.py- browser-backed access tospending.gov.uaspendinggovua_api/report_render.py- HTML rendering for report pagesspendinggovua_api/zip_export.py- ZIP archive builder for JSON exportsspendinggovua_api/batch_export.py- reusable batch export helper for Form 2 archivesspendinggovua_api/static/index.html- web UIspendinggovua_api/static/app.js- frontend logicspendinggovua_api/static/app.css- frontend stylingscripts/export_form2_html_zip.py- convenience script for the batch Form 2 archiveDockerfile- container runtime setup