A simple rest API that exposes data related to zip codes and buildings in Berlin.
The source dataset is published by Esri and is available here.
Built as an exercise
PLZ provides the following endpoints:
/status returns the status of the service/zip/buildings returns the number of buildings aggregated by zip code/zip/buildings/history returns the number of buildings aggregated by zip code and year/zip/buildings/:code returns the number of buildings for a specific zip code/zip/buildings/:code/history returns the number of buildings aggregated by zip code and year for a specific zip codeThere are 2 ways to run the PLZ api service: using Docker(recommended) or via manual setup.
For more details about the command line options, use the command
plz --help
The Docker image is available at noandrea/plz, and can be run with
docker run -p 2007:2007 noandrea/plz
The image is built on scratch, the image size is ~9.3mb:
Those are the steps to setup the service:
plzgo get github.com/noandrea/plz
OR
Download the latest from the release page
curl -L https://opendata.arcgis.com/datasets/273bf4ae7f6a460fbf3000d73f7b2f76_0.csv?outSR=%7B%22latestWkid%22%3A3857%2C%22wkid%22%3A102100%7D -o /tmp/src.csv
plz massage --input /tmp/src.csv --output rest.json
plz serve --data rest.json
docker-compose.yaml example
version: '3'
services:
plz:
container_name: plz
image: noandrea/plz:latest
ports:
- 2007:2007
Kubernetes configuration example:
---
# Deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: plz
name: plz
spec:
replicas: 1
revisionHistoryLimit: 3
selector:
matchLabels:
app: plz
template:
metadata:
labels:
app: plz
spec:
containers:
- env:
image: noandrea/plz:latest
imagePullPolicy: Always
name: plz
ports:
- name: http
containerPort: 2007
livenessProbe:
httpGet:
path: /status
port: 2007
---
# Service
# the service for the above deployment
apiVersion: v1
kind: Service
metadata:
name: plz-service
spec:
type: ClusterIP
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
selector:
app: plz
Content type
Image
Digest
Size
3.5 MB
Last updated
about 6 years ago
docker pull noandrea/plz