United Nations (UNHCR) Refugee Data


MicroProject Overview

The United Nations High Commissioner for Refugees (UNHCR) is a United Nations agency mandated to aid and protect refugees, forcibly displaced communities, and stateless people, and to assist in their voluntary repatriation, local integration or resettlement to a third country.

The UNHCR has a database of refugees and internally displaced persons (IDPs) around the world. The data is updated daily and includes information on the number of refugees and IDPs, the countries they are from, the countries they are in, and the number of people who have been displaced by conflict or natural disasters.

They also have a public API that allows you to access the data programmatically. This microproject explores using the API with the requests Python library.

Data Science Skills

In this microproject, you will explore the United Nations High Commissioner for Refugees dataset and strengthen the following Data Science skills:

  • Using the requests library to access a public API and working with the JSON response data,
  • Using the .join on a string to join a list of elements together,
  • Creating a URL-encoded string using urllib.parse.quote
  • Manipulating DataFrame dtypes by using pd.to_numeric

Let's nerd out!

MicroProject in Visual Studio Code
MicroProject in Visual Studio Code
Using Python requests library to read a public, JSON API
Using Python requests library to read a public, JSON API
Bar Chart of refugees for 2003-2022
Bar Chart of refugees for 2003-2022
United Nations High Commissioner for Refugees (UNHCR) Global Public API
United Nations High Commissioner for Refugees (UNHCR) Global Public API

First Time Doing a MicroProject?

Each MicroProject starts with a notebook that we provide to you to get started! You will need to configure a git repository to connect to our `microprojects` remote where we release the starter notebook.


Fetch the Initial Files

In your terminal, navigate to your GitHub repository and merge the initial files by running the following commands:

git fetch microprojects
git merge microprojects/microproject-united-nations-refugee-data --allow-unrelated-histories -m "Merging initial files"

Complete the Notebook

If the commands above were successful, you have merged in the initial files to start on the MicroProject.

  • Find the new microproject-united-nations-refugee-data folder.
  • Open microproject-united-nations-refugee-data.ipynb and complete the MicroProject!

Commit and Grade Your Notebook

Once you have finished your notebook, you must use the built-in GitHub Action to preform automated grading of your MicroProject notebook! You will need to commit your work and then manually run the GitHub Action.

Commit Your Work

To commit your notebook, run the standard git commands in your terminal:

git add -u
git commit -m "microproject completed"
git push

Grade Your Notebook

To grade your notebook, you will need to visit your GitHub repository in your browser.

  • Visit your GitHub repository in your browser
  • Click on the "Actions" tab
  • Under "Workflows", find the workflow for this microproject
  • Click the "Run Workflow" in the blue box, and then the green "Run Workflow"
  • After about 10 seconds, you should see a new job that has started running
    • You can click on the job to watch it run in real-time
    • It will take ~1 minute to run and grade
  • Once the running is complete, the autograding summary will be available!