Python Workshops for Beginners/Saturday October 25th lecture

Lecture Outline

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