Skip to content

Commit c251b72

Browse files
update of APIs session
1 parent 58b26bd commit c251b72

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

-21.1 KB
Binary file not shown.
5.37 KB
Binary file not shown.

1-foundations/4-api-and-dataviz/foundations-s4-api.ipynb

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010
"<a href=\"https://colab.research.google.com/github/worldbank/dec-python-course/blob/main/1-foundations/4-api-and-dataviz/foundations-s4-api.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
1111
]
1212
},
13-
{
14-
"cell_type": "code",
15-
"execution_count": null,
16-
"metadata": {},
17-
"outputs": [],
18-
"source": [
19-
"import pandas as pd"
20-
]
21-
},
2213
{
2314
"cell_type": "markdown",
2415
"metadata": {},
@@ -74,7 +65,7 @@
7465
"- Your web browser then renders the HTML information in the response and shows it to you\n",
7566
"- A familiar example:\n",
7667
"\n",
77-
"`https://www.worldbank.org/en/home`"
68+
"`https://www.worldbank.org/ext/en/home`"
7869
]
7970
},
8071
{
@@ -107,7 +98,7 @@
10798
"metadata": {},
10899
"outputs": [],
109100
"source": [
110-
"url = 'https://www.worldbank.org/en/home'"
101+
"url = 'https://www.worldbank.org/ext/en/home'"
111102
]
112103
},
113104
{
@@ -323,6 +314,15 @@
323314
"Furthermore, we can transform the list inside `data['people']` into a Pandas dataframe for further analysis."
324315
]
325316
},
317+
{
318+
"cell_type": "code",
319+
"execution_count": null,
320+
"metadata": {},
321+
"outputs": [],
322+
"source": [
323+
"import pandas as pd"
324+
]
325+
},
326326
{
327327
"cell_type": "code",
328328
"execution_count": null,
@@ -417,7 +417,7 @@
417417
"source": [
418418
"# Coding a simple API client\n",
419419
"\n",
420-
"- An API \"client\" is a piece of code that facilitates the interaction with an API\n",
420+
"- An **API client** is a piece of code that facilitates the interaction with an API\n",
421421
"- In the example with the astronauts, we had to go through several coding steps to execute the request, obtain the JSON data, and load it into a Pandas data frame\n",
422422
"- All of those steps could be packed in a Python function that simplified the process of interacting with the API. That function is an API client\n",
423423
"- In fact, in exercise 1 you were inadvertently creating an API client!\n",
@@ -630,7 +630,7 @@
630630
"metadata": {},
631631
"outputs": [],
632632
"source": [
633-
"query = geolocator.geocode('1818 H St NW, Washington DC')"
633+
"query = geolocator.geocode('1818 H St NW, Washington DC, USA')"
634634
]
635635
},
636636
{
@@ -648,7 +648,7 @@
648648
"cell_type": "markdown",
649649
"metadata": {},
650650
"source": [
651-
"`query` is an ad-hoc variable type for this library."
651+
"`query` has an ad-hoc variable type from this library."
652652
]
653653
},
654654
{
@@ -781,7 +781,7 @@
781781
"cell_type": "markdown",
782782
"metadata": {},
783783
"source": [
784-
"Programming this complicated client is not needded at all to interact with the The World Bank API. It has a dedicated client Python library that greatly facilitates its use.\n",
784+
"Programming this complicated client is not needed at all to interact with the The World Bank API. It has a dedicated client Python library that greatly facilitates its use.\n",
785785
"- Release blog post [here](https://blogs.worldbank.org/opendata/introducing-wbgapi-new-python-package-accessing-world-bank-data)\n",
786786
"- Documentation [here](https://pypi.org/project/wbgapi/)\n",
787787
"- Examples [here](https://nbviewer.org/github/tgherzog/wbgapi/blob/master/examples/wbgapi-cookbook.ipynb)"
@@ -883,7 +883,8 @@
883883
"## Python API client libraries - Main takeaways\n",
884884
"\n",
885885
"- API client libraries greatly facilitate the use of APIs. You don't have to code your own client anymore!\n",
886-
"- You need to review the library documentation to know how to use them\n",
886+
" - However, not all APIs have a client library.\n",
887+
"- You always need to review the library documentation and explore its use to know how to use them\n",
887888
"- The resulting variables from client libraries might not be in JSON format\n",
888889
" + `geopy` returned an ad-hoc variable class\n",
889890
" + `wb.data.DataFrame` returned a Pandas dataframe, which is very convenient for further data analysis\n",

0 commit comments

Comments
 (0)