|
10 | 10 | "<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>" |
11 | 11 | ] |
12 | 12 | }, |
13 | | - { |
14 | | - "cell_type": "code", |
15 | | - "execution_count": null, |
16 | | - "metadata": {}, |
17 | | - "outputs": [], |
18 | | - "source": [ |
19 | | - "import pandas as pd" |
20 | | - ] |
21 | | - }, |
22 | 13 | { |
23 | 14 | "cell_type": "markdown", |
24 | 15 | "metadata": {}, |
|
74 | 65 | "- Your web browser then renders the HTML information in the response and shows it to you\n", |
75 | 66 | "- A familiar example:\n", |
76 | 67 | "\n", |
77 | | - "`https://www.worldbank.org/en/home`" |
| 68 | + "`https://www.worldbank.org/ext/en/home`" |
78 | 69 | ] |
79 | 70 | }, |
80 | 71 | { |
|
107 | 98 | "metadata": {}, |
108 | 99 | "outputs": [], |
109 | 100 | "source": [ |
110 | | - "url = 'https://www.worldbank.org/en/home'" |
| 101 | + "url = 'https://www.worldbank.org/ext/en/home'" |
111 | 102 | ] |
112 | 103 | }, |
113 | 104 | { |
|
323 | 314 | "Furthermore, we can transform the list inside `data['people']` into a Pandas dataframe for further analysis." |
324 | 315 | ] |
325 | 316 | }, |
| 317 | + { |
| 318 | + "cell_type": "code", |
| 319 | + "execution_count": null, |
| 320 | + "metadata": {}, |
| 321 | + "outputs": [], |
| 322 | + "source": [ |
| 323 | + "import pandas as pd" |
| 324 | + ] |
| 325 | + }, |
326 | 326 | { |
327 | 327 | "cell_type": "code", |
328 | 328 | "execution_count": null, |
|
417 | 417 | "source": [ |
418 | 418 | "# Coding a simple API client\n", |
419 | 419 | "\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", |
421 | 421 | "- 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", |
422 | 422 | "- 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", |
423 | 423 | "- In fact, in exercise 1 you were inadvertently creating an API client!\n", |
|
630 | 630 | "metadata": {}, |
631 | 631 | "outputs": [], |
632 | 632 | "source": [ |
633 | | - "query = geolocator.geocode('1818 H St NW, Washington DC')" |
| 633 | + "query = geolocator.geocode('1818 H St NW, Washington DC, USA')" |
634 | 634 | ] |
635 | 635 | }, |
636 | 636 | { |
|
648 | 648 | "cell_type": "markdown", |
649 | 649 | "metadata": {}, |
650 | 650 | "source": [ |
651 | | - "`query` is an ad-hoc variable type for this library." |
| 651 | + "`query` has an ad-hoc variable type from this library." |
652 | 652 | ] |
653 | 653 | }, |
654 | 654 | { |
|
781 | 781 | "cell_type": "markdown", |
782 | 782 | "metadata": {}, |
783 | 783 | "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", |
785 | 785 | "- Release blog post [here](https://blogs.worldbank.org/opendata/introducing-wbgapi-new-python-package-accessing-world-bank-data)\n", |
786 | 786 | "- Documentation [here](https://pypi.org/project/wbgapi/)\n", |
787 | 787 | "- Examples [here](https://nbviewer.org/github/tgherzog/wbgapi/blob/master/examples/wbgapi-cookbook.ipynb)" |
|
883 | 883 | "## Python API client libraries - Main takeaways\n", |
884 | 884 | "\n", |
885 | 885 | "- 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", |
887 | 888 | "- The resulting variables from client libraries might not be in JSON format\n", |
888 | 889 | " + `geopy` returned an ad-hoc variable class\n", |
889 | 890 | " + `wb.data.DataFrame` returned a Pandas dataframe, which is very convenient for further data analysis\n", |
|
0 commit comments