Hypermedia & Civic Hacking
A Love Story
Shelby Switzer
@switzerly
shelbyswitzer.com
Local Government Data
Local Government API
Show-Me-The-Food
- identify food deserts
- add canvassing tool
- visualize findings
- change the world
API-in-a-Box
Containerized hypermedia APIs for open data
Document:
{
"business" : {
"name" : "Hairy Convenience",
"lat" : "33.760094",
"lng" : "-84.386037",
"bustype" : "convenience"
}
}
Mapping:
{
"business" : {
"properties" : {
"name" : { "type" : "string" },
"lat" : { "type" : "string" },
"lng" : { "type" : "string" },
"bustype" : { "type" : "string" },
"FILE_SOURCE": { "type": "string"},
}
}
}
- easy (and free) way to store and maintain data
- little or no changes to raw data
- has a flexible, robust API
- does not need to be hosted
- simple setup locally or on any server
API-in-a-Box
- throw data into github repo
- pull/build docker image
API-in-a-Box
$ docker-compose up -e ORIGIN_REPO="switzersc/food-data"
$ curl http://dockerip:4567/resources?dedupe=bustype
{
"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"},
{"name" : "FILE_SOURCE", "value" : "GA_EBT.csv"}
]
}
],
"queries" : [
{"rel":"search", "href":"http://dockerip:4567/resources/search", "prompt":"Search",
"data" : [
{"name" : "name", "value" : ""},
{"name" : "lat", "value" : ""},
{"name" : "lng", "value" : ""},
{"name" : "bustype", "value" : ""},
{"name" : "FILE_SOURCE", "value": ""},
{"name" : "dedupe", "value" : ""}
]
}
]
}
Hypermedia: Collection+JSON
{
"collection" :
"href" : "http://dockerip:4567/resources/",
"items" : [
{
"href" : "http://dockerip:4567/resources/8903493",
"data" : [
{"name" : "name", "value" : "Linda May"},
{"name" : "salary", "value" : "$113,367.00"},
{"name" : "agency", "value" : "Citizenship and Immigration"},
{"name" : "grade", "value" : "14"},
{"name" : "FILE_SOURCE", "value" : "federal_salaries.csv"}
]
}
],
"queries" : [
{"rel":"search", "href":"http://dockerip:4567/resources/search", "prompt":"Search",
"data" : [
{"name" : "name", "value" : ""},
{"name" : "salary", "value" : ""},
{"name" : "agency", "value" : ""},
{"name" : "grade", "value" : ""},
{"name" : "FILE_SOURCE", "value": ""},
{"name" : "dedupe", "value" : ""}
]
}
]
}
"REST's uniform interface constraint, the principle that all these parts are interchangeable, is antithetical to the way tech companies do business today."
- Leonard Richardson
Civic Hacking
Hypermedia
Get involved!
Merci!
Shelby Switzer
@switzerly
shelbyswitzer.com
- https://github.com/switzersc/api-in-a-box
- https://hub.docker.com/r/switzersc/api-in-a-box/
- http://www.codeforamerica.org/brigade/
- http://www.elastic.co/guide/en/elasticsearch/guide/current/index.html
- http://amundsen.com/media-types/collection/
- https://www.data.gov/developers/apis
Resources
Hypermedia & Civic Hacking
By Shelby Switzer
Hypermedia & Civic Hacking
- 2,115