Skip to content

Using API to Retrieve Data from the World Bank #128

Closed

Description

@HumphreyYang

I found that we used static datasets of the World Bank dataset in our lecture. I think packages like wbapi can help us retrieve data conveniently from the World Bank API, and it worked very well when I wrote the lecture on business cycles.

Therefore, I think using the same set of tools across this lecture series can make the lecture more consistent. It also gives us the leverage to show more diverse datasets from different sources and helps us to keep our lectures up to date whenever new data comes out without replacing a lot of static datasets.

Please kindly let me know what are your opinions on this (CC @mmcky and @jstac).

Activity

  1. jstac commented on Mar 10, 2023

    @jstac
    Contributor

    @mmcky For context, @HumphreyYang made some good points about using APIs rather than storing our own smaller versions of data sets. We thought it would be helpful to have an issue where we can discuss this point.

    In some cases, we stored our own data because no API was available. I think @shlff 's lecture on inequality fits this pattern.

    Are there other cases where we could have used an API? What policy should we adopt?

    Using APIs gives some added value by helping students get started on their own data projects...

  2. mmcky commented on Mar 16, 2023

    @mmcky
    Contributor

    Thanks for your thoughts on this @HumphreyYang.

    Our experience in the past with using API based data retrieval is it introduces some stochastic errors into the build process. From time to time the API will time out or change and cause build errors.

    In the case of the wbapi I have used it to good effect -- it is one of the higher quality services and could be worth teaching explicitly (as a side benefit of the lecture) so I would be OK if we used the wbapi python application to fetch the wb datasets.

    But it really needs to be constrained to these high quality and maintained sources.

    The pandas_datareader app has historically been error prone as interfaces to things like Yahoo would be slow to update when yahoo changed its API. This would cause build errors until the reader was updated. This is the main reason we typically use locally stored datasets -- to improve robustness.

    In some cases, we stored our own data because no API was available. I think @shlff 's lecture on inequality fits this pattern.

    There are a lot of these cases really. The long_run_growth lecture will be the same using the Maddison dataset.

    Using APIs gives some added value by helping students get started on their own data projects...

    This is a good point @jstac and probably worth the risk for high quality data fetching tools such as wbapi

  3. jstac commented on Mar 16, 2023

    @jstac
    Contributor

    Thanks for those thoughts @mmcky .

    @HumphreyYang , thanks for opening the discussion. It sounds like we have a good rule of thumb to proceed. (If you are happy please close the issue.)

  4. HumphreyYang commented on Mar 16, 2023

    @HumphreyYang
    MemberAuthor

    Thanks for your thoughtful suggestions @mmcky.

    Would you suggest I store the data I used in #24 from pandas_datareader in a static format?

    I think in the case of FRED, unlike Yahoo, it seldom changes its API as an institution, and it has worked out fine in my previous uses. How about if I keep this issue open, and revert back to static datasets if we have a build issue caused by pandas_datareader?

    Please let me know if you think it is a good plan.

    Many thanks in advance.

  5. jstac commented on Apr 23, 2023

    @jstac
    Contributor

    @mmcky Could you please close this or move it to meta?

  6. mmcky commented on May 30, 2023

    @mmcky
    Contributor

    @HumphreyYang let's go ahead and use the api approach. It isn't always fragility in the api but sometimes build issues caused by frequent access and multiple builds causing 403 responses etc. Let's give this a go and if we get build errors we can move back to static assets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions