For journalism, civil society and academia

Concrete tools to
investigate public spending.

If you work in investigative journalism, civil-society organizations, or academic research, this guide summarizes how to leverage our API and public products to answer concrete questions about the Peruvian State.

Why this public layer exists

The MEF Open Data contains extraordinary information but is scattered across multiple portals, formats and raw files. Our public-good branch exists to solve that:

  • We normalize and consolidate data from SIAF, SSI, SEACE, Infobras and Invierte.pe into one coherent model.
  • We expose aggregated data via REST API with free SQL — no auth, no paywall.
  • We publish visualizations, rankings and dashboards ready to cite.
  • We document our method and publish code for the critical pieces.

Economic sustainability comes from the B2G side with contracted State entities — that preserves editorial independence of what we publish openly.

Real use cases

Four questions, with the SQL to answer them.

The queries below work as-is against the /api/insights/query POST endpoint. Modify codes, dates or filters to your needs.

1

Monitor budget execution of a public entity

Question: How much budget has the Ministry of Health executed this year vs. what was approved?

Compares approved PIM vs. accrued spending month by month. Useful for stories on structural under-execution.

SQL — DuckDB
SELECT
  anio,
  ROUND(SUM(MTO_PIM) / 1e9, 1)        AS pim_bn,
  ROUND(SUM(DEVENGADO_) / 1e9, 1)     AS dev_bn,
  ROUND(SUM(DEVENGADO_) * 100
      / NULLIF(SUM(MTO_PIM), 0), 1)   AS execution_pct
FROM mef_historico
WHERE PLIEGO LIKE '011%'   -- 011: MINISTRY OF HEALTH
GROUP BY anio
ORDER BY anio
2

Compare execution across regions

Question: Which regional governments execute investment budgets best?

Useful for reports on territorial inequality and identifying who leaves money unspent.

SQL — DuckDB
SELECT
  PLIEGO        AS regional_government,
  ROUND(SUM(MTO_PIM) / 1e9, 2)        AS investment_pim_bn,
  ROUND(SUM(DEVENGADO_) * 100
      / NULLIF(SUM(MTO_PIM), 0), 1)   AS execution_pct
FROM mef_historico
WHERE NIVEL = 'R. GOBIERNOS REGIONALES'
  AND CATEGORIA_GASTO = '6. CAPITAL'
  AND anio = (SELECT MAX(anio) FROM mef_historico)
GROUP BY PLIEGO
ORDER BY investment_pim_bn DESC
3

Detect chronic under-execution

Question: Which entities execute less than 50% of their budget for several years in a row?

Identifies structural management issues. Under-execution for 3+ years indicates a deeper problem — not a bad year.

SQL — DuckDB
WITH annual_execution AS (
  SELECT
    anio,
    PLIEGO,
    SUM(DEVENGADO_) * 100
      / NULLIF(SUM(MTO_PIM), 0)  AS execution_pct
  FROM mef_historico
  WHERE anio BETWEEN 2020 AND 2024
  GROUP BY anio, PLIEGO
)
SELECT
  PLIEGO,
  ROUND(AVG(execution_pct), 1)    AS avg_execution_pct,
  COUNT(*)                        AS years_evaluated
FROM annual_execution
WHERE execution_pct < 50
GROUP BY PLIEGO
HAVING COUNT(*) >= 3
ORDER BY avg_execution_pct ASC
4

Region in numbers

Question: How does my region compare to the national average?

For regional journalism: "your region receives X while the national average is Y" with verifiable data.

SQL — DuckDB
SELECT
  DEPARTAMENTO_META            AS region,
  ROUND(SUM(MTO_PIM) / 1e9, 2) AS pim_bn,
  ROUND(SUM(DEVENGADO_) * 100
      / NULLIF(SUM(MTO_PIM), 0), 1) AS execution_pct
FROM mef_historico
WHERE anio = (SELECT MAX(anio) FROM mef_historico)
  AND DEPARTAMENTO_META NOT LIKE '00%'
GROUP BY DEPARTAMENTO_META
ORDER BY pim_bn DESC

Tip

To see all entity codes, government levels, sectors and regions available, query GET /api/insights/dimensions

Field manual

Three typical research workflows

How to monitor an entity

  1. Identify the code in /dimensions
  2. Use Query 1 with that code
  3. Refresh daily to detect sudden PIM changes
  4. Cross-check with news: any budget modification that explains it?

How to detect anomalies

  1. Multi-year (Query 3) reveals structural under-execution
  2. Entities below 50% for 3+ years are candidates
  3. Validate with SSI: are projects also delayed physically?
  4. Cross-check with apps5.mineco.gob.pe before publishing

How to compare regions

  1. Query 2 (absolute) or Query 4 (per capita)
  2. Filter by CATEGORIA_GASTO for current / capital / debt
  3. The public ranking does this without SQL
  4. For maps, use the DEPARTAMENTO_META column

Attribution

How to cite Gestión Pública Perú

If you publish news stories, papers, reports or analyses based on data accessible through our public products, please attribute the source. It gives you methodological credibility with editors and reviewers.

Citation in a news story

Source: Gestión Pública Perú — gestionpublicaperu.com.pe · Primary data from Peru's MEF.

Citation in paper / thesis (APA)

Gestión Pública Perú. (2026). MEF Insights API — Historical Public Spending [Dataset]. Retrieved from https://gestionpublicaperu.com.pe/en/open

In social media

Data via @gestionpublicaperu — gestionpublicaperu.com.pe

Detailed license in the Terms of Use · Section 6 (Spanish only).

Direct research support

Need a complex query, validation of a finding, or help understanding a dataset? We reply within 48 hours to researchers and press.