Editing DS4UX (Spring 2016)/Day 5 lecture
From CommunityData
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: | ||
<div style="font-family:Rockwell,'Courier Bold',Courier,Georgia,'Times New Roman',Times,serif; min-width:10em;"> | |||
<div style="float:left; width:100%; margin-right:2%;"> | |||
{{Link/Graphic/Main/2 | |||
|highlight color= 27666b | |||
|color=460c40 | |||
|link= | |||
|image= | |||
|text-align=left | |||
|top font-size= 1.1em | |||
|top color=FFF | |||
|line color=FFF | |||
|top text=This page is a work in progress. | |||
|bottom font-size= 1em | |||
|bottom color= FFF | |||
|bottom text= | |||
|line= none | |||
}}</div></div> | |||
<div style="clear:both;"></div> | |||
[[File:Highfivekitten.jpeg|200px|thumb|In which you learn how to use Python and web APIs to meet the likes of her!]] | [[File:Highfivekitten.jpeg|200px|thumb|In which you learn how to use Python and web APIs to meet the likes of her!]] | ||
Line 24: | Line 46: | ||
== Lecture 1: What is an API? == | == Lecture 1: What is an API? == | ||
''RAY: the content below is just for your reference. You can delete it or replace it as you see fit! [[User:Jtmorgan|Jtmorgan]] ([[User talk:Jtmorgan|talk]]) 16:57, 21 April 2016 (EDT)'' | |||
* API: a structured way for programs to talk to each other (aka an interface for programs) | * API: a structured way for programs to talk to each other (aka an interface for programs) | ||
* Web APIs: like a website your programs can visit (you:a website::your program:a web API) | * Web APIs: like a website your programs can visit (you:a website::your program:a web API) | ||
=== How do we use an API to fetch datasets? === | === How do we use an API to fetch datasets? === | ||
Line 58: | Line 76: | ||
** kittens of different sizes | ** kittens of different sizes | ||
** kittens in greyscale or color | ** kittens in greyscale or color | ||
* Now we | * Now we write a small program to grab an arbitrary square from placekitten by asking for the size on standard in: [http://mako.cc/teaching/2014/cdsw-autumn/placekitten_raw_input.py placekitten_raw_input.py] | ||
== Lecture 2: Using data from APIs in Python == | == Lecture 2: Using data from APIs in Python == | ||
''RAY: the content below is just for your reference. You can delete it or replace it as you see fit! [[User:Jtmorgan|Jtmorgan]] ([[User talk:Jtmorgan|talk]]) 16:57, 21 April 2016 (EDT)'' | |||
=== How do we write Python programs that make web requests? === | === How do we write Python programs that make web requests? === | ||
Line 75: | Line 95: | ||
* what is json: useful for more structured data | * what is json: useful for more structured data | ||
* import json; | * import json; json.loads() | ||
* like Python (except no single quotes) | * like Python (except no single quotes) | ||
* simple lists, dictionaries | * simple lists, dictionaries | ||
* can reflect more complicated data structures | * can reflect more complicated data structures | ||
* Example file at http://mako.cc/cdsw.json | |||
* You can parse data directly with <code>.json()</code> on a <code>requests</code> call | * You can parse data directly with <code>.json()</code> on a <code>requests</code> call | ||
=== Using other APIs === | === Using other APIs === | ||
Line 98: | Line 114: | ||
== | == Exercise 2: How do we use APIs to get data from Wikipedia? == | ||
* Brief intro to Wikipedia | * Brief intro to Wikipedia | ||
* Overview of what you can get from | * Overview of what you can get from the Wikipedia API | ||
* | * Harry Potter examples | ||
* Introduce | * Introduce coding challenges | ||
[[Category:DS4UX (Spring 2016)]] | [[Category:DS4UX (Spring 2016)]] |