To make things easier for you, we have created a Python SDK for the The-Datagarden API. This will allow you to easily access the API and make requests to the API without having to now the implementation details of the API.
The SDK is easy when it comes to requesting The-Datagarden data. On top of that, it provides you with additional functionality to work with the data. On this page you will find an introsuxtion to using the SDK. For detailed information on the SDK, please refer to the SDK read-the-docs page.
Installing the SDK is straightforward.
$ pip install the-datagarden
The response on this request should provide you with the access and refresh token.
Let's say you want to get demographic data for the netherlands since 2010. If you have an account at The-Datagarden, you can easily request this data using the SDK. Assuming you have installed the SDK and you have an account at The-Datagarden.
# retrieve nl demographics data
>>> from the_datagarden import TheDataGardenAPI
>>> my_datagarden_api = TheDataGardenAPI(email="<your-email>", password="<your-password>")
>>> nl = my_datagarden_api.NL # or my_datagarden_api.netherlands
>>> nl_demographics = nl.demographics(period_from="2022-01-01", period_to="2030-01-01")
TheDataGardenRegionalDataModel : Demographics : (count=18)
The ``nl_demographics`` object is a TheDataGardenRegionalDataModel now holds the requested demographics data. Turning this into either a pandas dataframe or a polars dataframe is easy.
# retrieve nl demographics data
>>> nl_dem_df = nl_demographics.full_model_to_pandas() # or nl_demographics.full_model_to_polars()
>>> nl_dem_df["name", "source_name", "period", "population.total_male", "population.total_female", "fertility.fertility_rate"].head(10)
As this dataframe holds a lot of columns only a few selected columns are shown here.
┌─────────────┬────────────────┬──────────────────────┬───────────────────────┬─────────────────────────┬──────────────────────────┐ │ name ┆ source_name ┆ period ┆ population.total_male ┆ population.total_female ┆ fertility.fertility_rate │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str ┆ f64 ┆ f64 ┆ f64 │ ╞═════════════╪════════════════╪══════════════════════╪═══════════════════════╪═════════════════════════╪══════════════════════════╡ │ Netherlands ┆ Eurostat ┆ 2022-01-01T00:00:00Z ┆ 8.745468e6 ┆ 8.845204e6 ┆ 1.49 │ │ Netherlands ┆ United Nations ┆ 2022-01-01T00:00:00Z ┆ 8.890013e6 ┆ 9.014408e6 ┆ 1.51 │ │ Netherlands ┆ United Nations ┆ 2023-01-01T00:00:00Z ┆ 8.986255e6 ┆ 9.106269e6 ┆ 1.43 │ │ Netherlands ┆ Eurostat ┆ 2023-01-01T00:00:00Z ┆ 8.850309e6 ┆ 8.960982e6 ┆ null │ │ Netherlands ┆ CBS ┆ 2024-01-01T00:00:00Z ┆ null ┆ null ┆ 1.42 │ │ Netherlands ┆ United Nations ┆ 2024-01-01T00:00:00Z ┆ 9.055978e6 ┆ 9.172763e6 ┆ null │ │ Netherlands ┆ United Nations ┆ 2025-01-01T00:00:00Z ┆ 9.116159e6 ┆ 9.23066e6 ┆ null │ │ Netherlands ┆ CBS ┆ 2025-01-01T00:00:00Z ┆ null ┆ null ┆ 1.4 │ │ Netherlands ┆ CBS ┆ 2026-01-01T00:00:00Z ┆ null ┆ null ┆ 1.4 │ │ Netherlands ┆ United Nations ┆ 2026-01-01T00:00:00Z ┆ 9.168238e6 ┆ 9.280538e6 ┆ null │ └─────────────┴────────────────┴──────────────────────┴───────────────────────┴─────────────────────────┴──────────────────────────┘
This example dataframe provides you with timeseries demographic data for the Netherlands. With the SDK you can easily add regional time series data for for example provinces, cities, etc. Or you can select a whole different data model like economics, weather, etc. The SDK also makes gives you quick access to the GeoJSON for these regions allowing you to easily make map representations.
Check out the SDK read-the-docs page for more detailed information on how to use the SDK.