Anonymous user
Community Data Science Workshops (Spring 2014)/Saturday May 3rd lecture: Difference between revisions
Community Data Science Workshops (Spring 2014)/Saturday May 3rd lecture (view source)
Revision as of 13:21, 3 May 2014
, 10 years ago→Lecture Outline
imported>Mako No edit summary |
imported>Mako |
||
Line 2:
# API
#* definition of API: just an
#* 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)
#* 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, different types
Line 16 ⟶ 24:
#* urllib2 and urlopen
#* interpolate variables into a string using % and %()s
#* JSON file (JavaScript Object Notation)▼
#** what is json▼
#** 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▼
#* open a file and write to it▼
# [http://placekitten.com/ placekitten.com]
#* API that takes specially crafted URLs and gives appropriately sized picture of kittens
Line 31:
#* show how to use place
#* write a small program to grab arbitrary square from placekitten by asking for the size on standard in
▲#* Example file at http://mako.cc/cdsw.json
▲#* open a file and write to it
# Wikipedia API
#* explain MediaWiki, exists on other wikis
|