Community Data Science Workshops (Fall 2014)/Day 2 lecture

Lecture Outline

 * 1) Introduction to APIs
 * 2) * definition of API: just an interface for programs
 * 3) * definition of web API
 * 4) ** like a website for your
 * 5) ** way to ask for data (almost always a URL)
 * 6) ** way to get data back (almost always in a format called JSON)
 * 7) ** every API is different, and documented
 * 8) * to use APIs to build a dataset we will need:
 * 9) ** all our tools from last session: variables, etc
 * 10) ** the ability to open urls on the web
 * 11) ** the ability to create custom URLS
 * 12) ** the ability to save to files
 * 13) ** the ability to understand (i.e., parse) JSON data that APIs usually give us
 * 14) Review material from last session
 * 15) * variables
 * 16) * lists
 * 17) * dictionaries
 * 18) * if statements
 * 19) * for loops
 * 20) * printing
 * 21) * modules
 * 22) New programming concepts:
 * 23) * urllib2 and urlopen
 * 24) * interpolate variables into a string using % and %s
 * 25) * open files and write to them
 * 26) placekitten.com
 * 27) * API that takes specially crafted URLs and gives appropriately sized picture of kittens
 * 28) * example of placekitten in browser
 * 29) ** visit the API documentation
 * 30) ** kittens of different sizes
 * 31) ** kittens in greyscale or color
 * 32) * show how to use place
 * 33) * write a small program to grab arbitrary square from placekitten by asking for the size on standard in
 * 34) JSON file (JavaScript Object Notation)
 * 35) * what is json: useful for more structure data
 * 36) * import json; json.loads
 * 37) * like Python (except no single quotes)
 * 38) * simple lists, dictionaries
 * 39) * can reflect more complicated data structures
 * 40) * Example file at http://mako.cc/cdsw.json
 * 41) * download it and parse it
 * 42) Other APIs
 * 43) * every API is different, so read the documentation!
 * 44) * for popular APIs, there are python modules that help you make requests and parse json!
 * 45) * rate limiting
 * 46) * authenticaiton
 * 47) * text encoding issues
 * 1) * text encoding issues