crafter research / civic-tech

Query ONPE
with one CLI

Agent-first CLI for Peru's election results API. Query mesas, actas, ubigeos, and summaries. Dual JSON/human output. Built for AI agents as primary consumers.

$ bun add -g @crafter/onpe-cli

# Install globally
$ bun add -g @crafter/onpe-cli

# Check API status
$ onpe doctor
  [OK] proceso-activo: EG2026
  [OK] elecciones: 9 elecciones
  [OK] resumen-general: 86664 actas
  [OK] buscar-mesa: mesa 000001 accesible
All checks passed

# Look up any mesa
$ onpe mesa 900001 --json
# NDJSON output for agents

# Drill down geography
$ onpe ubigeos 2 150000
150101  LIMA
150102  ANCON
...
92K+
Mesas
6
Commands
0
Auth required
4
Cligentic blocks

Election data, one command away

Mesa Lookup

Query any mesa by code. Works with regular (000001-088064) and rural centros poblados (900001-904703).

$ onpe mesa 044739
Mesa 044739
  Local:  IE MIGUEL GRAU SEMINARIO
  Habiles: 300  Emitidos: 237
  Estado: Contabilizada (C)

Acta Detail

Full vote breakdown per party with percentages. Includes file IDs for PDF download.

$ onpe acta 12345 --json | jq .detalle
# Returns all party votes, candidates,
# percentages, and acta file references

Ubigeo Navigation

Drill down departments, provinces, and districts. 3 levels matching ONPE's geographic hierarchy.

$ onpe ubigeos 1
010000  AMAZONAS
020000  ANCASH
030000  APURIMAC
...

Election Summary

Real-time totals: actas counted, participation rate, JEE pipeline status.

$ onpe resumen
Actas contabilizadas: 86664 (93.6%)
Total actas:         92767
Participacion:       79.2%

Agent DX first

Built with cligentic blocks for structured agent output. NDJSON to stdout, next-step hints on stderr, typed error codes with recovery suggestions. The agent is the primary consumer.

--json auto-detected when piped
NDJSON for streaming agent consumption
next-steps hints on stderr
Typed error codes with recovery hints
Sec-Fetch headers bypass nginx filter
Zero auth required (public API)