Editing Community Data Science Workshops (Sprint 2015)/Day 2 lection

From CommunityData

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
#redirect [[Community Data Science Workshops (Spring 2015)/Day 2 Lecture]]
== Lecture Outline ==
Β 
# Introduction to APIs
#* definition of API: just an interface for programs
#* definition of web API
#** way to ask for data (almost always a URL)
#** way to get data back (almost always in a format called JSON)
#** every API is different, and documented
#* to use APIs to build a dataset we will need:
#** all our tools from last session: variables, etc
#** the ability to open urls on the web
#** the ability to create custom URLS
#** the ability to save to files
#** the ability to understand (i.e., parse) JSON data that APIs usually give us
# Review material from last session
#* variables
#* lists
#* dictionaries
#* if statements
#* for loops
#* printing
#* modules
# New programming concepts:
#* Using [http://docs.python-requests.org/en/latest/ requests] to access files on the internet
#* interpolate variables into a string using % and %()s
#* open files and write to them
# [http://placebear.com/ placebear.com]
#* API that takes specially crafted URLs and gives appropriately sized picture of bears
#* example of placebear in browser
#** visit the API documentation
#** bears of different sizes
#** bears in greyscale or color
#** bears not your thing? Try [http://placekitten.com/ placekitten] instead!
#* show how to use place
#* write a small program to grab arbitrary square from placekitten by asking for the size on standard in
# JSON file (JavaScript Object Notation)
#* what is json: useful for more structure data
#* import json; json.loads()
#* like Python (except no single quotes)
#* simple lists, dictionaries
#* can reflect more complicated data structures
#* Example file at http://mako.cc/cdsw.json
#* download it and parse it
# Other APIs
#* every API is different, so read the documentation!
#* for popular APIs, there are python modules that help you make requests and parse json!
#* rate limiting
#* authentication
#* text encoding issues
Please note that all contributions to CommunityData are considered to be released under the Attribution-Share Alike 3.0 Unported (see CommunityData:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)