API-in-a-box

@switzerly

shelbyswitzer.com

getnotion.com

Civic hacking with hypermedia API containers

The world runs on small data.

show-me-the-food

  • identify food deserts
  • add canvassing tool
  • visualize findings
  • change the world

The need:

  • easy (and free) to store and maintain data
  • little or no changes to raw data
  • has or can integrate with flexible, robust API
  • does not need to be hosted
  • simple setup locally or on any server
{
	"business" : {
		"name" : "Hairy Convenience",
		"lat" : "33.760094",
		"lng" : "-84.386037",
		"bustype" : "convenience"
	}
}

document:

mapping:

{
	"business" : {
		"properties" : {
			"name" : { "type" : "string" },
			"lat" : { "type" : "string" },
			"lng" : { "type" : "string" },
			"bustype" : { "type" : "string" }
		}
	}
}

The need:

  • easy (and free) to store and maintain data
  • little or no changes to raw data
  • has or can integrate with flexible, robust API
  • does not need to be hosted
  • simple setup locally or on any server

API

web:
  build: ./api
  command: rackup -p 4567 -o 0.0.0.0
  volumes:
    - api:/api
  ports:
    - "4567:4567"
  links:
    - elastic

elastic:
  image: dockerfile/elasticsearch
  ports:
    - "9200:9200"
    - "9300:9300"
  volumes:
    - docker_volumes/elasticsearch_data:/usr/local/elasticsearch/data

docker-compose.yml

$ docker-compose up -e DATA_URL="https://api.github.com/repos/switzersc/food-data"
$ curl http://dockerip:4567/resources?type=business&dedupe=name
  1. throw data into github repo
  2. install docker
  3.  
  4.  

API-in-a-box

{
    "collection" :
        "href" : "http://dockerip:4567/resources/",
        "items" : [ 
            {
                "href" : "http://dockerip:4567/resources/8903493",
                "data" : [
                  {"name" : "name", "value" : "Bob's Convenience Store"},
                  {"name" : "lat", "value" : "33.760094"},
                  {"name" : "lng", "value" : "-84.386037"},
                  {"name" : "bustype", "value" : "convenience"},
                ]
              }
        ],
        "queries" : [
            {"rel" : "search", "href" : "http://dockerip:4567/resources", "prompt" : "Search",
                "data" : [
                    {"name" : "name", "value" : ""},
                    {"name" : "lat", "value" : ""},
                    {"name" : "lng", "value" : ""},
                    {"name" : "bustype", "value" : ""},
                    {"name" : "dedupe", "value" : ""}
                ]
            }
        ]
}

Hypermedia: Collection+JSON

The need:

  • easy (and free) to store and maintain data
  • little or no changes to raw data
  • has or can integrate with flexible, robust API
  • does not need to be hosted
  • simple setup locally or on any server

Thanks!

@switzerly

shelbyswitzer.com

getnotion.com

Made with Slides.com