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 from npm
$ bun add -g @crafter/onpe-cli

# Who's winning?
$ onpe-cli ranking
  1. ==================== 17.0%  Keiko Fujimori
  2. ==============...... 12.0%  Roberto Sanchez
  3. ==============...... 11.9%  Rafael Lopez Aliaga

# Health check
$ onpe-cli doctor
  + proceso-activo   EG2026
  + elecciones       9 elecciones
  + resumen-general  86901 actas (93.7%)
  + buscar-mesa      mesa 000001 accesible
  4/4 passed
92K+
Mesas
7
Commands
0
Auth required
7
Cligentic blocks

Election data, one command away

National Ranking

Who's winning? Live candidate ranking with party-colored bars, votes, and percentages.

$ onpe-cli ranking
  1. ==================== 17.0% 2,695,457  Keiko Fujimori
  2. ==============...... 12.0% 1,899,064  Roberto Sanchez
  3. ==============...... 11.9% 1,884,279  Rafael Lopez A.
  4. =============....... 11.1% 1,748,580  Jorge Nieto

Mesa Lookup

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

$ onpe-cli mesa 044739
  Mesa 044739  [Contabilizada]
  Local:  IE MIGUEL GRAU SEMINARIO
  Habiles: 300  Emitidos: 237
  Participacion: ===============..... 79.0%

Acta Detail

Full vote breakdown per party with percentages and PDF file references.

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

Election Summary

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

$ onpe-cli resumen
  Contabilizadas ==================== 86901 (93.7%)
  Enviadas JEE   =............... 5757 (6.2%)
  Total actas: 92766  Participacion: 79.2%

Agent DX first

Built with 7 cligentic blocks: json-mode, next-steps, global-flags, error-map, argv, doctor, and banner. NDJSON to stdout, structured hints on stderr, typed errors with recovery suggestions. Zero framework deps.

--json auto-detected when piped
NDJSON for streaming agent consumption
next-steps hints on stderr
Typed errors with fromHttp() + recovery hints
Zero-dep argv parser (no commander needed)
doctor block for health checks