R client for India’s MoSPI Microdata Portal. Download unit-level survey microdata from the National Sample Survey (NSS), Periodic Labour Force Survey (PLFS), Annual Survey of Industries (ASI), Household Consumer Expenditure Survey (HCES), and other Government of India surveys via the NADA API.
Documentation: https://mospir.saketlab.org
Installation
remotes::install_github("saketlab/mospiR")Setup
Register at microdata.gov.in and copy your API key from My Profile > API Key. Add it to ~/.Renviron:
MOSPI_KEY=your-key-here
Then reload with readRenviron("~/.Renviron") or restart R.
Usage
library(mospiR)
api_key <- Sys.getenv("MOSPI_KEY")
# Search datasets by keyword
plfs <- list_datasets(api_key, query = "labour force")
plfs[, c("idno", "title")]
# List files in a dataset
files <- list_files("DDI-IND-NSO-ASI-2020-21", api_key)
files[, c("name", "size")]
# Download one file
download_file("DDI-IND-NSO-ASI-2020-21", "ASI_DATA.zip", "./data", api_key)
# Download all files in a dataset
download_dataset("DDI-IND-NSO-ASI-2020-21", "./data", api_key)Functions
| Function | Description |
|---|---|
list_datasets() |
List all datasets; page = NULL fetches all pages; query filters by title |
list_files() |
Files in a dataset (name, size, base64 token) |
download_file() |
Download one file by name |
download_dataset() |
Download all files in a dataset |
Requests retry up to 4 times with exponential backoff on 401, 429, and 5xx responses.
Available surveys
The portal hosts microdata from NSS rounds 43 through 80, PLFS quarterly rounds, ASI annual rounds, and selected special surveys. See list_datasets(api_key) for the full catalog.
Related packages
- nesstarR – read NSS Nesstar binary files (rounds 64, 66, 68)
- consumptionsurveyindia – analysis-ready HCES data
- healthsurveyindia – NSS Health Survey data