The Internation Organization for Migration IOM provides a publicly accessible API specifically for the Displacement Tracking Matrix (DTM). It is designed to allow humanitarian organizations, researchers, and developers to programmatically access displacement data.
As of early 2026, the system has moved toward API Version 3 (v3), which offers more granular data than previous versions.
Key Features of the DTM API
- Data Scope: It primarily provides non-sensitive Internally Displaced Person (IDP) figures.
- Aggregation Levels: Data is available at the country level (Admin 0), state/province level (Admin 1), and smaller subnational areas (Admin 2).
- Newer Metrics (v3): Includes demographic disaggregation (sex/age), origins of displacement, and primary reasons for movement (e.g., conflict, natural disaster).
- Accessibility: Most global IDP datasets are also mirrored on the Humanitarian Data Exchange (HDX), which provides its own API for these collections.
Data Sensitivity Note
It is important to note that for protection reasons, the API does not provide sensitive individual-level data or biometrics. If you require highly detailed or sensitive datasets for humanitarian response, you must contact the DTM Global Support team directly to establish a formal Data Sharing Agreement (DSA).
The API
How to Access the API
To use the official IOM DTM API, you typically follow these steps:
- Registration: Visit the DTM API Registration Portal to sign up for an account.
- Subscription: Select the API version (v3 is recommended) and click Subscribe to generate a Primary Key.
- Authentication: Include your subscription key in
the request header (usually as
Ocp-Apim-Subscription-Key) for all API calls.
Accessing the API Using R
To analyze IOM DTM data in R, you will need a setup that handles API authentication, JSON parsing, and geospatial mapping. Since the DTM API delivers data in a structured format, R’s “Tidyverse” ecosystem is the most efficient choice for this workflow.
1. Essential R Libraries
You should install and load the following packages to manage the data pipeline:
httr2orhttr: For making the GET requests to the IOM API and passing your subscription key in the header.jsonlite: To flatten the JSON responses into R data frames.tidyverse(dplyr, ggplot2, tidyr): For cleaning the data and creating visualizations.sf: Essential if you plan to join the displacement metrics with shapefiles for spatial analysis.
# Installation
install.packages(c("httr2", "jsonlite", "tidyverse", "sf"))2. API Authentication Setup
The IOM API requires an Ocp-Apim-Subscription-Key.
For security, do not hardcode this key into your scripts. Instead, use
an .Renviron file:
- In your R console, run
usethis::edit_r_environ(). - Add the line:
IOM_API_KEY="your_key_here". - Restart R.
- Access it in your script using
Sys.getenv("IOM_API_KEY").
3. Constructing the Request
The DTM API v3 uses specific endpoints for different data types (e.g., IDP estimates vs. Flow Monitoring). A standard setup to fetch country-level data looks like this:
library(httr2)
library(jsonlite)
# Define the base URL for DTM API v3
base_url <- "https://api.dtm.iom.int/v3/GetIDPData"
# Create and perform the request
req <- request(base_url) %>%
req_headers("Ocp-Apim-Subscription-Key" = Sys.getenv("IOM_API_KEY")) %>%
req_perform()
# Parse the JSON response
dtm_data <- resp_body_json(req, simplifyVector = TRUE)4. Data Workflow Logic
When analyzing displacement data, your R script should follow a specific logical flow to ensure the metrics are interpreted correctly:
Temporal Alignment: Displacement data is often updated in “rounds.” Ensure you are filtering for the most recent round to avoid double-counting.
Spatial Joining: Use the
sfpackage to join DTM metrics with administrative boundaries (Admin 1 or Admin 2) downloaded from sources like GADM or Humanitarian Data Exchange (HDX).Handling Nulls: DTM datasets often contain “No Data” or “0” values for specific sectors; your R code must explicitly handle these to avoid skewing averages.
5. Recommended Integrated Development Environment (IDE)
RStudio Desktop is the standard. If you are handling
very large global DTM datasets, ensure you have allocated enough memory
in your R session, or consider using the arrow package if
you are reading massive .csv exports from the DTM portal
rather than using the API.
Python
For those working in Python, there is an official
package called dtmapi (available via PyPI) that simplifies
the process:
from dtmapi import DTMApi
# Initialize with your key
api = DTMApi(subscription_key="YOUR_API_KEY")
# Example: Fetch all available countries
countries = api.get_all_countries()