zip/buildings rest API for Berlin
PLZ Rest API
A simple rest API that exposes data related to zip codes and buildings in Berlin.
This project is the Python implementation of PLZ
Built as an exercise
PLZ provides the following endpoints:
/statusreturns the status of the service
/zip/buildingsreturns the number of buildings aggregated by zip code
/zip/buildings/historyreturns the number of buildings aggregated by zip code and year
/zip/buildings/:codereturns the number of buildings for a specific zip code
/zip/buildings/:code/historyreturns the number of buildings aggregated by zip code and year for a specific zip code
There are 2 ways to run the PLZ api service: using Docker(recommended) or via manual setup.
For best results with Docker please use the image from the go project as described here since the image is orders of magnitude smaller.
Those are the steps to run the project manually:
- Install the library
pip install plzpy
- Download the dataset linked above:
curl -L https://opendata.arcgis.com/datasets/273bf4ae7f6a460fbf3000d73f7b2f76_0.csv?outSR=%7B%22latestWkid%22%3A3857%2C%22wkid%22%3A102100%7D -o /tmp/src.csv
- Massage the dataset to produce an optimized json to be served via the Rest API
plzpy massage --in /tmp/src.csv --out rest.json
- Run the Rest API service
plzpy serve --data rest.json
The project relies on poetry.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.