RESTful(ish) JSON API for Swedish alcohol monopoly, Systembolaget. Running on k8s! 🚀🍺
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
chart
scripts
services
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE
Makefile
README.md
docker-compose.yaml
flowchart.png

README.md

bolaget.io (https://bolaget.io)

Build Status

This API has nothing to do with Systembolaget, this app consumes a large XML API from Systembolaget and transforms it into a REST JSON API. More info can be found here: http://www.systembolaget.se/api

Flowchart

Flowchart

Versions

Please have a look at CHANGELOG.md for more information. Otherwise this project adheres to Semantic Versioning.

Version Url
v1 https://bolaget.io/v1

All resources will be available without versioning in the url and be an alias for the latest API version.

Products

GET /products
Host: bolaget.io
  • URL Params

    Optional:

    limit=[number] - Default limit is 10, max limit is 100

    offset=[number]

    ecological=[bool]

    koscher=[bool]

    ethical=[bool]

    year_from=[number]

    year_to=[number]

    sales_start_from=[date] - YYYY-MM-DD

    sales_start_to=[date] - YYYY-MM-DD

    price_from=[number]

    price_to=[integer]

    volume_from=[integer]

    volume_to=[number]

    assortment=[alphanumeric] - BS = Reservation assortment, TS = Temporary assortment, FS = Regular assortment and FSN = Regular assortment (new product)

    sort=[alphanumeric] - Property to sort by, accepting:

    • price:asc|desc
    • price_per_liter:asc|desc
    • volume_in_milliliter:asc|desc
    • sales_start:asc|desc
    • year:asc|desc
    • zip_code:asc|desc
    • name:asc|desc

    name|type|style|provider|producer|origin|origin_country|packaging|product_group|sealing=[alphanumeric] - Fuzzy match

    search=[alphanumeric] - Fuzzy search in several fields

  • Response headers:

    X-Total-Count=[number] - Total count of products based on filtering used for pagination

  • Success Response:

    • Code: 200
      Content: [{ name: '117 Grythyttan' ... }] or []
  • Error Response:

    • Code: 500 INTERNAL SERVER ERROR
      Content: { error : "Ouch, an ugly error has occured!" }

Product

GET /products/:nr
Host: bolaget.io
  • Success Response:

    • Code: 200
      Content: { nr: 12, name: "117 Grythyttan" ... }
  • Error Response:

    • Code: 500 INTERNAL SERVER ERROR
      Content: { error : "Ouch, an ugly error has occured!" }

    OR

    • Code: 404 NOT FOUND
      Content: { error : "Move along, nothing to see here!" }

Stores

GET /stores
Host: bolaget.io
  • URL Params

    Optional:

    limit=[number] - Default limit is 10, max limit is 100

    offset=[number]

    labels=[alphanumeric] - Takes a comma separated list, eg. norrbotten,jämtland, returns documents containing all labels matched (fuzzy)

    sort=[alphanumeric] - Property to sort by, accepting:

    • RT90x:asc|desc
    • RT90y:asc|desc
    • address:asc|desc
    • city:asc|desc
    • county:asc|desc

    type|name|city|county|address=[alphanumeric] - Fuzzy match

    search=[alphanumeric] - Fuzzy search in several fields

  • Response headers:

    X-Total-Count=[number] - Total count of stores based on filtering used for pagination

  • Success Response:

    • Code: 200
      Content: [{ adress_1: 'Kungsholmstorg 11 A' ... }] or []
  • Error Response:

    • Code: 500 Internal Server Error
      Content: { error : "Ouch, an ugly error has occured!" }

Store

GET /stores/:nr
Host: bolaget.io
  • Success Response:

    • Code: 200
      Content: { address: "Vasagatan 25", ... }
  • Error Response:

    • Code: 500 INTERNAL SERVER ERROR
      Content: { error : "Ouch, an ugly error has occured!" }

    OR

    • Code: 404 NOT FOUND
      Content: { error : "Move along, nothing to see here!" }

Development environment

Kubernetes

You need a local Kubernetes cluster (minikube, docker-for-mac etc.) with helm installed.

Build:

make build

Install:

helm install \
  --set nginx.image.tag=local \
  --set nginx.image.pullPolicy=Never \
  --set web.image.tag=local \
  --set web.image.pullPolicy=Never \
  --name bolagetio \
  ./chart

Docker Compose

Using Docker and Docker Compose (https://www.docker.com/)

Build

  • docker-compose build

Start

  • docker-compose up web

Start worker

  • docker-compose run --rm web npm run dev:worker

Run tests

  • docker-compose run --rm web npm test