This is an API tutorial for a workshop at "Code for DC's National Day of Civic Hacking"
- Application Programming Interface
- “set of routines, protocols, and tools for building software and applications” [Wikipedia]
- Usually used when someone makes an app that uses data
- Access:
- Databases (comment sections on websites, open government data)
- streaming data (e.g uber, twitter)
- One
.keynote
with some basic API info and a resources slide - Two
.py
files:API_code.py
contains code to grab data from the 30-day crime APIscheduled_API_code.py
contains code to schedule grabing of the data so you can collect multiple times at regular intervals (eg when running on a server): - Data is appended to a csv, - Duplicates are removed, - Scheduling is (currently, but you can change it) once every ~29 days
- One
.ipynb
file that steps through the process more clearly (hopefully)- the code is a little different from
API_code.py
but essentally does the same thing
- the code is a little different from
- One
.geojson
file as an example of API output - Two
.csv.
example output files. They are slightly different:spyder_foo.csv
is an output when running thescheduled_API_code.py
from my Spyder IDEipython_foo.csv
is the output when running theipython notebook
code.
- Read more about APIs on this Techcrunch post
Tutorials
- Codecademy tutorials
- Automating the boring stuff Scroll down to JSON and APIs section: Tips
- How to read response codes
- Always check the Terms of Use / Terms of Service
APIs you could play with