Skip to content

A comprehensive Python wrapper for the Kolada API v3, providing access to Swedish municipality data.

License

Notifications You must be signed in to change notification settings

xemarap/koladapy

Repository files navigation

KoladaPy

A comprehensive Python wrapper for the Kolada API v3, providing access to Swedish municipality data.

Python Versions License

About Kolada

Kolada is a database containing key performance indicators (KPIs) for Swedish municipalities and regions. This wrapper provides a simple interface to search for KPIs, download data, and work with the results in Pandas DataFrames.

Features

  • Search for KPIs with flexible filtering options
  • Access metadata for KPIs, municipalities, and organizational units
  • Download data with customizable parameters
  • Convert results to Pandas DataFrames for easy analysis
  • Automatic handling of pagination, validation and rate limits
  • Support for all API endpoints including data for different regions and organizational units

Requirements

  • Python 3.7 or higher
  • Dependencies:
    • requests>=2.25.0
    • pandas>=1.1.0
    • tqdm>=4.50.0
    • backoff>=1.10.0

Installation

pip install git+https://github.com/xemarap/koladapy.git

Quick Start

Visit the tutorials folder for a basic usage guide.

from koladapy import KoladaAPI

# Initialize the client
kolada = KoladaAPI()

# Search for KPIs related to school
kpis = kolada.search_kpis("skola")
print(f"Found {len(kpis)} KPIs related to 'skola'")

# Get a specific KPI by ID
kpi = kolada.get_kpi("N15033")  # Pupils/teacher in primary school
print(f"KPI title: {kpi['title']}")

# Get the same data as a pandas DataFrame
df = kolada.get_data_as_dataframe(
    kpi_id="N15033", 
    municipality_id="0180", # Stockholm municipality
    years=[2020, 2021]
)
print(df.head())

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Resources

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

This project uses the following open source packages:

The full license texts are available in the LICENSES directory.

About

A comprehensive Python wrapper for the Kolada API v3, providing access to Swedish municipality data.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages