hapi is an agent-first Go CLI for HDX HAPI, packaged as hdx-hapi-cli.
It is intentionally a standalone shell tool, not an MCP server. Agents can call it directly, receive stable machine-readable output, and later wrap it in a Skill or MCP layer if useful.
Install Go (if not already installed), then:
go install github.com/ibagur/cli-hdx/cmd/hapi@latestThe binary lands in ~/go/bin. Add it to your PATH if needed:
echo 'export PATH="$HOME/go/bin:$PATH"' >> ~/.zshrc && source ~/.zshrcgo install github.com/ibagur/cli-hdx/cmd/hapi@latestAdd ~/go/bin to your PATH:
echo 'export PATH="$HOME/go/bin:$PATH"' >> ~/.bashrc && source ~/.bashrcStep 1 — Install Go from go.dev/dl. Use the .msi installer; it sets PATH automatically.
Step 2 — Install hapi from PowerShell or Command Prompt:
go install github.com/ibagur/cli-hdx/cmd/hapi@latestStep 3 — Verify the binary is reachable. Go places binaries in %USERPROFILE%\go\bin. Confirm it is on your PATH:
hapi --helpIf the command is not found, add the directory manually:
# PowerShell (current session only)
$env:PATH += ";$env:USERPROFILE\go\bin"
# To persist across sessions, set via System Properties → Environment Variables
# and add %USERPROFILE%\go\bin to the User PATH entryStep 4 — Set your app identifier (see Configuration below):
$env:HAPI_APP_IDENTIFIER = "your-app-identifier"To persist it, add it to your user environment variables via System Properties, or add the line above to your PowerShell profile ($PROFILE).
git clone https://github.com/ibagur/cli-hdx.git
cd cli-hdx
go build -o hapi ./cmd/hapiGenerate an app identifier from a name and email:
hapi auth init --app-name "my-agent" --email "me@example.org"Or set it directly via environment variable:
# macOS / Linux
export HAPI_APP_IDENTIFIER="..."
# Windows PowerShell
$env:HAPI_APP_IDENTIFIER = "..."Resolution precedence:
- Explicit CLI flag
- Environment variable
- Config file at
~/.config/hapi/config.toml - Built-in default
Supported environment variables:
HAPI_APP_IDENTIFIER(orHDX_APP_IDENTIFIER)HAPI_BASE_URL(orHDX_BASE_URL), defaulthttps://hapi.humdata.org/apiHAPI_API_VERSION(orHDX_API_VERSION), defaultv2HAPI_TIMEOUT(orHDX_TIMEOUT), default30
Minimal config file (~/.config/hapi/config.toml):
app_identifier = "..."
base_url = "https://hapi.humdata.org/api"
api_version = "v2"
limit = 1000The hdx-hapi skill tells an AI agent how to use hapi to answer humanitarian data questions. This is optional helper guidance for agent platforms, not a requirement for installing or using the CLI.
Place the skill in your global Claude skills directory so it is available in any project:
mkdir -p ~/.claude/skills/hdx-hapi
curl -fsSL https://raw.githubusercontent.com/ibagur/cli-hdx/main/.agents/skills/hdx-hapi/SKILL.md \
-o ~/.claude/skills/hdx-hapi/SKILL.mdWindows (PowerShell):
New-Item -ItemType Directory -Force "$env:USERPROFILE\.claude\skills\hdx-hapi"
Invoke-WebRequest `
-Uri "https://raw.githubusercontent.com/ibagur/cli-hdx/main/.agents/skills/hdx-hapi/SKILL.md" `
-OutFile "$env:USERPROFILE\.claude\skills\hdx-hapi\SKILL.md"The skill is picked up automatically on the next Claude Code session. No restart needed.
For project-local installation (only available within that project), place the file at .agents/skills/hdx-hapi/SKILL.md in the project root instead.
Place the skill in your project's agent skills directory:
mkdir -p .agents/skills/hdx-hapi
curl -fsSL https://raw.githubusercontent.com/ibagur/cli-hdx/main/.agents/skills/hdx-hapi/SKILL.md \
-o .agents/skills/hdx-hapi/SKILL.mdCodex picks up skills from .agents/skills/ automatically.
Claude Desktop does not load skill files directly. Copy the skill content into your custom system prompt:
- Open Claude Desktop → Settings → Custom System Prompt
- Open the skill file:
.agents/skills/hdx-hapi/SKILL.md - Paste the full content (everything after the frontmatter
---block) into the system prompt field
You can also clone the repo and reference the path locally so you can keep the prompt in sync with updates.
- Go to ChatGPT → Explore GPTs → Create (or open an existing custom GPT)
- Under Instructions, paste the content of
SKILL.md(after the frontmatter block) - Ensure
hapiis available in your environment if using Code Interpreter, or instruct the GPT to emithapishell commands for you to run locally and paste back the output
For direct ChatGPT sessions without a custom GPT, paste the skill content at the start of a new conversation as a system-level instruction.
Discover available endpoints:
hapi list-endpoints --format tableLook up a country and check what data is available:
hapi metadata locations --name Sudan --format json
hapi metadata availability --location-code SDN --format jsonCurated workflows — the fastest path to an answer:
hapi workflow country-overview --country Sudan --format json
hapi workflow wash-3w --country Nigeria --admin1-name Yobe --format json
hapi workflow funding --country "South Sudan"
hapi workflow food-security --country Mozambique --ipc-phase 3+ --admin-level 1
hapi workflow displacement --country Sudan --type idps --format json
hapi workflow humanitarian-needs --country DRC --sector "Water Sanitation Hygiene" --format json
hapi workflow refugees --country Uganda --format json
hapi workflow population --country Nepal --admin-level 1 --format json
hapi workflow conflict-events --country Sudan --event-type battles --start-date 2026-01-01 --format jsonRaw endpoint access for domains without a workflow:
hapi get coordination-context/national-risk --param location_code=SDN --format json
hapi get food-security-nutrition-poverty/food-prices-market-monitor --param location_code=SDN --format json
hapi get climate/hazards-rainfall --param location_code=SDN --format jsonLimit fields to reduce output size:
hapi workflow conflict-events --country Sudan --fields location_code,admin1_name,event_type,fatalities --format csvFetch all pages (use with care on large datasets):
hapi workflow refugees --country Ethiopia --all-pages --format jsonlOnce the skill is installed, you can ask your agent natural-language questions. The agent resolves the location, queries HAPI, and returns sourced results.
"What is the current food security situation in Sudan by district?"
"How many IDPs are recorded in Ethiopia, broken down by admin1?"
"Show me WASH operational presence in Yobe state, Nigeria."
"What funding has been reported for South Sudan this year?"
"List conflict events in Sudan since January 2026 — battles only."
"What humanitarian needs data is available for DRC in the WASH sector?"
The agent will cite resource_hdx_id, dataset_hdx_title, and reference period fields from each response so you can trace the data back to the source dataset on HDX.
JSON is the default output format. Use --format table when inspecting data interactively.
0: success1: CLI usage or configuration error2: HAPI validation or bad request3: network, timeout, malformed response, or provider unavailable4: no data returned5: partial data with one or more page failures
The v2 registry was checked against the live official OpenAPI document at https://hapi.humdata.org/openapi.json on 2026-05-03. Current HAPI docs and changelog were also reviewed on 2026-05-04 for the expanded v2 registry. The known paths include:
metadata/locationmetadata/data-availabilitycoordination-context/operational-presencecoordination-context/fundingcoordination-context/conflict-eventsfood-security-nutrition-poverty/food-securityfood-security-nutrition-poverty/food-prices-market-monitorfood-security-nutrition-poverty/poverty-rateaffected-people/idpsaffected-people/refugees-persons-of-concernaffected-people/returneesaffected-people/humanitarian-needsgeography-infrastructure/baseline-populationcoordination-context/national-riskclimate/hazards-rainfall
The official changelog also notes the 2025-02-18 endpoint rename and that the renamed endpoints are released under API v2.
Unit tests do not require network access. Live smoke testing is gated by HAPI_APP_IDENTIFIER:
go test ./...
HAPI_APP_IDENTIFIER="..." go test ./internal/integration -run Live