Skip to content

API Reference

Bases: BaseClient

A DataGovClient allows apps to communicate with the Hellenic Government's open-data API (data.gov.gr) The data.gov.gr API is an interface for querying data published by central government, local authorities and public bodies to help you build products and services.

Note: Any attributes or methods prefixed with _underscores are forming a so called "private" API, and is for internal use only. They may be changed or removed at anytime.

Example

from pydatagovgr import DataGovClient gov = DataGovClient(token='xoxb-1234-1243')

Source code in pydatagovgr/client.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class DataGovClient(BaseClient):
    """A `DataGovClient` allows apps to communicate with the Hellenic Government's open-data API (data.gov.gr)
    The data.gov.gr API is an interface for querying data published by central government, local authorities
    and public bodies to help you build products and services.

    **Note**: Any attributes or methods prefixed with _underscores are forming a so called "private" API, and is
    for internal use only. They may be changed or removed at anytime.

    Example:

        >>> from pydatagovgr import DataGovClient
        >>> gov = DataGovClient(token='xoxb-1234-1243')

    """

    def query(self, dataset: str, **kwargs: Any) -> list:
        """Query a `dataset`. Additional (optional) parameters can be specified.

        Example:
            >>> # 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')

        Args:
            dataset: The name of the dataset.
            **kwargs: Arbitrary keyword arguments.

        Returns:
            The dataset.

        Raises:
            DataGovResponseError: Error raised when data.gov.gr does not send the expected response.
        """
        url = self._build_url(f"query/{dataset}")

        return self.session.get(url, params=kwargs, headers=self.headers)

query(dataset, kwargs)

Query a dataset. Additional (optional) parameters can be specified.

Example

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')

Parameters:

Name Type Description Default
dataset str

The name of the dataset.

required
**kwargs Any

Arbitrary keyword arguments.

{}

Returns:

Type Description
list

The dataset.

Raises:

Type Description
DataGovResponseError

Error raised when data.gov.gr does not send the expected response.

Source code in pydatagovgr/client.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def query(self, dataset: str, **kwargs: Any) -> list:
    """Query a `dataset`. Additional (optional) parameters can be specified.

    Example:
        >>> # 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')

    Args:
        dataset: The name of the dataset.
        **kwargs: Arbitrary keyword arguments.

    Returns:
        The dataset.

    Raises:
        DataGovResponseError: Error raised when data.gov.gr does not send the expected response.
    """
    url = self._build_url(f"query/{dataset}")

    return self.session.get(url, params=kwargs, headers=self.headers)