Editing Community Data Science Course (Spring 2023)/Week 4 lecture notes
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 42: | Line 42: | ||
** We can draw it out with https://jsonformatter.curiousconcept.com/ | ** We can draw it out with https://jsonformatter.curiousconcept.com/ | ||
** When it's time to do it Python, we can use the <code>.json()</code> function in the requests module! | ** When it's time to do it Python, we can use the <code>.json()</code> function in the requests module! | ||
=== How do we write Python programs that make web request === | |||
To use APIs to build a dataset we will need: | |||
* all our tools from last session: variables, etc [DONE!] | |||
* the ability to open URLs on the web | |||
* the ability to create custom URLS | |||
* the ability to understand (i.e., parse) JSON data that APIs usually give us | |||
* the ability to save to files [DONE!] | |||
== Our first API: Bored API == | == Our first API: Bored API == | ||
Line 67: | Line 76: | ||
** Let's add the type of activity to what we print out | ** Let's add the type of activity to what we print out | ||
** Let's add another parameter (maybe a price range?) | ** Let's add another parameter (maybe a price range?) | ||
== Introducing the OSM Nominatim API == | == Introducing the OSM Nominatim API == | ||
Line 73: | Line 81: | ||
We're going to spend today looking at Open Street Map's api called [http://nominatim.openstreetmap.org/ Nominatim]. | We're going to spend today looking at Open Street Map's api called [http://nominatim.openstreetmap.org/ Nominatim]. | ||
simple request: | |||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> |