Check the Setup
- Python 3.10 or newer
- A notebook environment such as Jupyter or Google Colab
- An internet connection
Official refugee, asylum-seeker, displacement, statelessness, return, and resettlement statistics for building humanitarian trend and flow tools.
Report a ProblemFrom Source to Product Signal
UNHCR's database reports forcibly displaced and stateless populations by year, origin, and asylum location. Start with refugees for two countries across five years. End-of-year stocks are not annual flows, categories differ, and some values are estimates or supplied by other authorities.
Install the packages, then run the notebook cell.
python -m pip install pandas requests
import pandas as pd
import requests
response = requests.get(
"https://api.unhcr.org/population/v1/population/",
params={
"yearFrom": 2020,
"yearTo": 2024,
"coo": "AFG,UKR",
"coa_all": "true",
"cf_type": "ISO",
"limit": 100,
},
timeout=30,
)
response.raise_for_status()
population = pd.DataFrame(response.json()["items"])
print(population[["year", "coo_name", "refugees", "asylum_seekers"]].head(20))Test a Useful Signal
Compare reported refugee and asylum-seeker stocks originating from Afghanistan and Ukraine from 2020 through 2024.
UNHCR is an intergovernmental source. Last verified 2026-09-27. Temporal coverage: 1951-present.