SurveySolutionsAPIv2 is a comprehensive, production-ready R
interface to the World Bank’s Survey
Solutions Computer-Assisted Personal
Interviewing (CAPI) and Computer-Assisted Web Interviewing (CAWI)
platform.
Built on modern httr2, this package
supersedes the previous httr-based implementation
(SurveySolutionsAPI). It covers the full current REST API (v1 and v2)
as well as complementary GraphQL queries and mutations, providing a
robust foundation for survey operations, quality control dashboards, and
automated data pipelines.
httr2 Architecture: Fast, resilient HTTP communications
with structured error handling via cli and automatic retries for
transient server errors.ConditionExpression), Designer validations (val), and categorical
answer options (answers).include_raw = FALSE produces pure
atomic data.table outputs that serialize cleanly with
data.table::fwrite(), with an opt-in include_raw = TRUE to retain
raw JSON nodes.exportClass).suso_createUSER()), preloaded sample assignments, and offline
basemap management.DT and plotly.install.packages("SurveySolutionsAPIv2")
You can install the latest release directly from GitHub:
# install.packages("remotes")
# remotes::install_github("michael-cw/SurveySolutionsAPIv2")
install.packages("SurveySolutionsAPIv2", repos = c('https://michael-cw.r-universe.dev', 'https://cloud.r-project.org'))
Configure your Survey Solutions server credentials securely using
suso_set_key(). Credentials can be supplied directly or loaded from
environment variables:
library(SurveySolutionsAPIv2)
# Set credentials for the active session
suso_set_key(
suso_server = Sys.getenv("SUSO_SERVER", "https://your-server.mysurvey.solutions"),
suso_user = Sys.getenv("SUSO_USER", "api_user"),
suso_password = Sys.getenv("SUSO_PASSWORD", "secret_pass"),
workspace = "primary"
)
# Test connectivity (returns HTTP 200 on success)
suso_PwCheck()
Retrieve all questionnaires available in the active workspace:
# List questionnaires
quest_list <- suso_getQuestDetails(operation.type = "list")
print(quest_list[, .(Title, Variable, Version, QuestionnaireId)])
Parse the entire questionnaire into four structured data.table
components:
# Extract questionnaire metadata
q_struct <- suso_getQuestDetails(
questID = quest_list$QuestionnaireId[1],
version = quest_list$Version[1],
operation.type = "structure",
include_raw = FALSE # Clean flat tables, ready for data.table::fwrite
)
# Access questions, validations, and answer options
questions <- q_struct$q
validations <- q_struct$val
codebook <- q_struct$answers
Distribute assignments to field enumerators with preloaded sample data:
suso_createASS(
questID = quest_list$QuestionnaireId[1],
version = quest_list$Version[1],
df = list(
ResponsibleName = "interviewer01",
Quantity = 10
)
)
Trigger, monitor, download, and parse export data with a single function:
# Export all approved interviews as Tabular data
survey_data <- suso_export(
questID = quest_list$QuestionnaireId[1],
version = quest_list$Version[1],
type = "Tabular",
workStatus = "ApprovedByHeadquarters",
addTranslation = TRUE
)
# The returned exportClass object contains labeled data tables
summary(survey_data)
Comprehensive documentation and tutorials are available on the companion pkgdown website:
exportClass attributes, and
parallel processing.This project is licensed under the MIT License — see the LICENSE file for details.