Skip to main content

Datamodels generated from the data.gov.gr OpenAPI documentation

Project description

datagovgr-datamodels

Datamodels created for handling the data from the https://data.gov.gr API.

The models are automatically generated from the unofficial API documentation, using the datamodel-code-generator.

For more information regarding the related project, see https://github.com/KAUTH/govgr-opendata-api-schema.

Supported datamodels

Note: At this moment, the package focuses on the datamodels of the responses.

Quick Installation

To install datagovgr-datamodels:

  • For pydantic models:
$ pip install datagovgr-datamodels[pydantic]

Example Usage

Pydantic models

  • To test querying the API and using the pydantic data models, provide a valid token and run:
    $ python3 examples/pydantic_v1_models.py

  • Example directly using pydantic v1 models:

from datagovgr_datamodels.pydantic_v1 import VaccinationData


data = {
    'area': 'ΑΝΑΤΟΛΙΚΗΣ ΑΤΤΙΚΗΣ',
    'areaid': 901,
    'dailydose1': 45,
    'dailydose2': 0,
    'dailydose3': 0,
    'daydiff': 0,
    'daytotal': 45,
    'referencedate': '2021-01-01T00:00:00',
    'totaldistinctpersons': 276,
    'totaldose1': 276,
    'totaldose2': 0,
    'totaldose3': 0,
    'totalvaccinations': 276
}

vaccination = VaccinationData.parse_obj(data)
print(
    f"Total vaccinations in '{vaccination.area}' "
    f"for {vaccination.referencedate.date()}: "
    f"{vaccination.totalvaccinations}."
)
  • Example directly using pydantic v2 models:
from datagovgr_datamodels.pydantic_v2 import VaccinationData


data = {
    'area': 'ΑΝΑΤΟΛΙΚΗΣ ΑΤΤΙΚΗΣ',
    'areaid': 901,
    'dailydose1': 45,
    'dailydose2': 0,
    'dailydose3': 0,
    'daydiff': 0,
    'daytotal': 45,
    'referencedate': '2021-01-01T00:00:00',
    'totaldistinctpersons': 276,
    'totaldose1': 276,
    'totaldose2': 0,
    'totaldose3': 0,
    'totalvaccinations': 276
}

vaccination = VaccinationData.model_validate(data)
print(
    f"Total vaccinations in '{vaccination.area}' "
    f"for {vaccination.referencedate.date()}: "
    f"{vaccination.totalvaccinations}."
)

Changelog

Changes to the datamodels are accompanied by a version update, documented in https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python/CHANGELOG.md.

License

MIT License

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

datagovgr_datamodels-0.1.0a1.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

datagovgr_datamodels-0.1.0a1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file datagovgr_datamodels-0.1.0a1.tar.gz.

File metadata

File hashes

Hashes for datagovgr_datamodels-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 29f7f5d9257ab9dbc60e73445bb11295386cc28d23a8297b355db67cfa158326
MD5 cf553dae0f4992d2221689257036fefa
BLAKE2b-256 c61792e0a789c71763229b10d542dc20ab827d8c20f846011725b94423724da8

See more details on using hashes here.

File details

Details for the file datagovgr_datamodels-0.1.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for datagovgr_datamodels-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebb83f9930b819cd226b8123c58114a77d5547a9534097319df9def108f86bed
MD5 a3e7bc348c313d072021a247f71c3b63
BLAKE2b-256 a6645fc88a4a0060811b85a96f99cf9fcd12c6dc87e9a41e4994d0c4985b2456

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