Python Workshops for Beginners/Saturday October 25th lecture

Welcome to the second Saturday lecture of the Python Workshops for Beginners! For about an hour and a half, we'll learn about "Application Programming Interfaces" (or APIs) so we can use them for some data science exercises in the afternoon.

Resources

 * Python data types cheat sheet
 * Python loops cheat sheet
 * Full slides deck

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) New programming concepts:
 * 14) * urllib2 and urlopen
 * 15) * interpolate variables into a string using % and %s
 * 16) * open files and write to them
 * 17) placekitten.com
 * 18) * API that takes specially crafted URLs and gives appropriately sized picture of kittens
 * 19) * example of placekitten in browser
 * 20) ** visit the API documentation
 * 21) ** kittens of different sizes
 * 22) ** kittens in greyscale or color
 * 23) * show how to use place
 * 24) * write a small program to grab arbitrary square from placekitten by asking for the size on standard in
 * 25) Other APIs
 * 26) * every API is different, so read the documentation!
 * 27) * for popular APIs, there are python modules that help you make requests and parse json!
 * 28) * rate limiting
 * 29) * authentication
 * 30) * text encoding issues