Skip to main content

A Pythonic client for the official https://data.gov.gr API.

Project description

pydatagovgr

PyPI PyPI - Python Version codecov Code style: black GitHub Workflow Status Documentation Status PyPI - Wheel

A Pythonic client for the official data.gov.gr API. Aims to be an easy, intuitive and out-of-the-box way to:

  • find data published by central government, local authorities and public bodies of Greece
  • build related products and services.

while being robust, following best-practices and eliminating developer-induced bugs.

The aspiration for this library is to enable users of different backgrounds (academia, industry, students etc.) with an interest to programmatically explore and utilize the open data of data.gov.gr, to do so without having to write-debug-maintain trivial code or worry about that.

Install

The recommended installation is via pip:

pip install pydatagovgr

Quick Usage

You must have an account on data.gov.gr to use the API service. In order to register and request an API token, submit a request in the designated official form here. The procedure is very simple and takes less than 5 minutes.

from pydatagovgr import DataGovClient


gov = DataGovClient(token='xoxb-1234-1243')

# fetch the COVID-19 vaccination data
covid_data = gov.query('mdg_emvolio')

# fetch data on Greece's internet traffic
traffic_data = gov.query('internet_traffic')

# fetch a list of the forest fires
fire_data = gov.query('mcp_forest_fires')

Features

The pydatagovgr client supports out-of-the-box all the things you know (and love), such as:

  • authentication: properly handles the authentication to data.gov.gr - all you have to do is provide a valid token.
  • persistent session: making several requests to data.gov.gr reuses the same underlying connection.
  • timeout policy: informs data.gov.gr that it will await at most x seconds for a response for a given request. Defaults to 60 sec.
  • retry policy: to account for potential server failures of lossy network connections, client automatically retries with an exponential-backoff, to avoid harming the data.gov.gr. Defaults to a maximum of 3 retries.

Not-So-Quick Usage

The data.gov.gr API exposes, through its api/v1/query GET endpoint, various datasets from different topics.

The pydatagovgr client thus provides a corresponding query method, through which every available dataset can be obtained. You can also pass additional arguments to filter the results accordingly.

from pydatagovgr import DataGovClient


gov = DataGovClient(token='xoxb-1234-1243')

# fetch the COVID-19 vaccination data for the 2021
data = gov.query('mdg_emvolio', date_from='2021-01-01', date_to='2021-12-31')

You can also use Python objects as arguments:

import datetime


data = gov.query(
    'mdg_emvolio', 
    date_from=datetime.date(2021, 1, 1), 
    date_to=datetime.date(2021, 12, 31)
)

Apart from the authentication token, you can also configure the timeout and retry policies of your client. For example:

# this client will stop waiting for a response after 7 seconds 
gov = DataGovClient(token='xoxb-1234-1243', timeout=7)

# this client will retry at most 3 times, with an exponential-backoff
# (i.e. each retry waits exponentially longer before occurs: 1, 2, 4, 8, ...sec)
gov = DataGovClient(token='xoxb-1234-1243', max_retries=3)

# this client will respect both a timeout policy and a retry policy
gov = DataGovClient(token='xoxb-1234-1243', timeout=7, max_retries=3)

Related Projects

How to contribute

If you wish to contribute, this is a great place to start!

License

Distributed under the MIT License.

Acknowledgements

All rights are reserved by the official https://data.gov.gr site, its developers, its maintainers and the Hellenic Government.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydatagovgr-0.3.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

pydatagovgr-0.3.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file pydatagovgr-0.3.0.tar.gz.

File metadata

  • Download URL: pydatagovgr-0.3.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1022-azure

File hashes

Hashes for pydatagovgr-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a5360a795912636f1668c8760f0d49d82a76ff066bbcf92e652fc38a7fa8bd40
MD5 c606eb1c554a6921889f9625d8efc902
BLAKE2b-256 a8b40cf081a3bc73c9b53de625965a541d4a8a41867004573359de43b2d51a1e

See more details on using hashes here.

File details

Details for the file pydatagovgr-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pydatagovgr-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1022-azure

File hashes

Hashes for pydatagovgr-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3998eba3d6558804dc244958898f4936b9688685cc7879ce552184dc6c02821c
MD5 df32f807b8e6e2a8f5d54a8aff2c3adf
BLAKE2b-256 d9b523a7ea94290425945216c3c44823a6fb8e3071fbbec87bbcdec9beb0ac39

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page