Guide · Chilean public procurement

Mercado Público API: how to query Chilean public tenders and purchase orders

Everything you need to pull ChileCompra data into your code or an AI agent: what data is available, how to request the official ticket, and how to query tenders and purchase orders as clean JSON with Better Llama's API.

What data does Mercado Público offer?

Mercado Público is the platform where Chilean government agencies publish their purchases, run by Dirección ChileCompra, the public procurement agency. According to ChileCompra, its API gives access to data on the public purchases made by more than 1,000 government entities: tenders (licitaciones), purchase orders (órdenes de compra), buyers and suppliers.

With that data you can build alerts for new tenders, analyze what each agency buys, follow competitors by supplier code, or feed an AI agent that looks for business opportunities for you.

Two ways to access the ChileCompra API

1. The official Mercado Público API

The official API is free and open to the public. To use it you accept the terms of use, sign in with Clave Única (Chile's government login) at chilecompra.cl/api and request a ticket, a code that is sent to you by email. Queries are GET requests to api.mercadopublico.cl (JSON, JSONP or XML), with dates in ddmmyyyy format and the ticket in the URL.

Keep in mind that the by-date listings return only basic information: for the details you have to query each code separately. Statuses come as numeric codes (for example, “5” = published) and the API rejects concurrent requests, so you need to handle pauses and retries.

2. Better Llama's normalized API (also over MCP)

Our Mercado Público Chile API uses that same official API with your own ticket and does the heavy lifting for you:

  • Fetches the full record for each result (fetchDetails option, on by default).
  • Stable output with the same fields for tenders, purchase orders and Compra Ágil (beta).
  • ISO 8601 UTC dates, statuses in Spanish and English, and a link to the official record.
  • Deduplication, pauses between requests and retries with exponential backoff.
  • Clear errors if the ticket is invalid or the quota runs out; returns whatever was already fetched.
  • Does not expose personal data of public officials or of suppliers who are natural persons.

You can call it over HTTP from any language or as an MCP tool from Claude, Cursor or other agents.

Step by step: search tenders with the API

Step 1. Request your ChileCompra ticket

Go to chilecompra.cl/api, accept the terms of use and sign in with Clave Única. The ticket is generated automatically and sent to your registered email. It is personal: use only your own. Better Llama does not include, share or resell tickets.

Step 2. Connect the MCP server

Use the MCP https://mcp.betterllama.com/mcp in your client, or call it over HTTP with JSON-RPC as in the examples. No account or sign-up during the beta. Your personal key goes in the X-MercadoPublico-Ticket header (read from an environment variable in the examples). The server caps maxItems per call; the default and maximum are on the tool page.

Step 3. Define your query

ParameterWhat it does
sourcelicitaciones (tenders), ordenes_compra (purchase orders) or compra_agil (beta)
dateFrom / dateToChilean calendar days in YYYY-MM-DD format; today by default; 31 days maximum
tenderStatusactivas, publicada, cerrada, desierta, adjudicada, revocada, suspendida, todos
purchaseOrderStatusOfficial purchase order statuses, such as aceptada or recepcionconforme
buyerCode / supplierCodeMercado Público buyer (agency) or supplier code
codesExact codes; all other filters are ignored
maxItemsMaximum number of results returned (50 by default)

With fetchDetails on, each result uses one extra request from your ticket's quota.

Step 4. Call the API with curl

The synchronous endpoint runs the query and returns the JSON array of results directly:

curl
curl -s https://mcp.betterllama.com/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "X-MercadoPublico-Ticket: $MP_TICKET" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "search_chile_public_tenders", "arguments": {"source": "licitaciones", "tenderStatus": "activas", "maxItems": 20}}}'

The same in Python

python
import json
import os
import requests

URL = "https://mcp.betterllama.com/mcp"
HEADERS = {"Accept": "application/json, text/event-stream",
           "X-MercadoPublico-Ticket": os.environ["MP_TICKET"]}
arguments = {
    "source": "licitaciones",
    "dateFrom": "2026-11-02",
    "dateTo": "2026-11-06",
    "tenderStatus": "publicada",
    "buyerCode": "6945",
    "maxItems": 25
}
body = {"jsonrpc": "2.0", "id": 1, "method": "tools/call",
        "params": {"name": "search_chile_public_tenders", "arguments": arguments}}
resp = requests.post(URL, json=body, headers=HEADERS, timeout=120)
resp.raise_for_status()
data = json.loads(resp.json()["result"]["content"][0]["text"])
for item in data["results"]:
    print(item["code"], item["statusEn"], item["buyerName"], item["closesAt"])

Purchase orders

Set source to ordenes_compra and filter by date, status, buyer or supplier. For a single purchase order, use its code:

json
{"ticket": "YOUR-TICKET", "source": "ordenes_compra", "codes": ["1057532-156-AG26"]}

From JavaScript or any other language, a POST with the same JSON-RPC body is enough (for example, with fetch).

Use the Mercado Público API from an AI agent (MCP)

Add the Better Llama MCP server to your client (Claude, Cursor, VS Code or any client with remote MCP). One MCP brings search_chile_public_tenders and the rest of the catalog, with no sign-up during the beta.

Cursor · mcp.json
{
  "mcpServers": {
    "better-llama": {
      "url": "https://mcp.betterllama.com/mcp",
      "headers": {
        "X-MercadoPublico-Ticket": "<your key>"
      }
    }
  }
}
Claude Code
claude mcp add --transport http better-llama https://mcp.betterllama.com/mcp

Setup for Claude, Codex, Gemini CLI, Windsurf, VS Code and other clients: connect your agent.

The key goes in the header X-MercadoPublico-Ticket: it is used only for that request and never stored. If your client does not support headers, pass it as a tool argument.

Then ask, for example: “Find active tenders in the Valparaíso Region for cleaning services and give me the code, agency, estimated amount and closing date.” Set your ticket in the X-MercadoPublico-Ticket header so it never has to appear in the chat.

Beta: free and with no sign-up while we test the service.

Which fields it returns

Each result includes, among others: source, code, name, description, statusCode, statusEs, statusEn, type (L1, LE, LP…), buyerName, buyerCode, buyerRegion, supplierName (empty for natural persons), publishedAt, closesAt, awardedAt, estimatedAmount, totalAmount, currency, relatedTenderCode, itemsCount, officialUrl and dataSource (attribution to Dirección ChileCompra).

json
{
  "source": "licitacion",
  "code": "1509-5-L126",
  "name": "Servicio de aseo dependencias municipales",
  "statusCode": "5", "statusEs": "Publicada", "statusEn": "Published",
  "type": "L1",
  "buyerName": "I MUNICIPALIDAD DE EJEMPLO", "buyerCode": "6945",
  "publishedAt": "2026-11-09T13:00:00.000Z",
  "closesAt": "2026-11-20T18:00:00.000Z",
  "estimatedAmount": 3500000, "currency": "CLP",
  "officialUrl": "https://www.mercadopublico.cl/Procurement/Modules/RFB/DetailsAcquisition.aspx?idlicitacion=1509-5-L126",
  "detailLevel": "full"
}

Illustrative example with fictitious data. Record contents (names, descriptions) come in Spanish, as published by the source.

Pricing

Free during the beta, with no sign-up and a limit of 60 requests per minute per IP. If paid plans come later, we will announce them on betterllama.com first. If the source requires your own key, that key is free and you request it from the provider directly.

Frequently asked questions

Is the Mercado Público API free?

Yes. ChileCompra describes it as a free tool open to the public; you only need to request a ticket with Clave Única at chilecompra.cl/api.00005 per call. Free during the beta, with no sign-up and a limit of 60 requests per minute per IP. If paid plans come later, we will announce them on betterllama.com first.

Do I need my own ChileCompra ticket to use Better Llama's API?

Yes. ChileCompra's terms say the ticket is personal, so you must use your own. It is free, requested with Clave Única at chilecompra.cl/api, and sent in the X-MercadoPublico-Ticket header (or the ticket argument if your client cannot set headers). Better Llama does not store or log it, and the 10,000 requests per day per ticket limit applies.

What is the difference between using the official API directly and Better Llama's API?

The official API returns by-date listings with basic data and statuses as numeric codes. Better Llama's API fetches the full record for each result and returns the same fields for tenders, purchase orders and Compra Ágil, ISO 8601 UTC dates, statuses in Spanish and English, a link to the official record, deduplication and automatic retries.

Can I query Compra Ágil by API?

Our API includes the compra_agil source in beta, on top of ChileCompra's v2 API, which is also in beta. It has not yet been validated with real data in our API and may respond with a 504 error.

Can I use the Mercado Público API from Claude, Cursor or another AI agent?

Yes. Add the Better Llama MCP server (https://mcp.betterllama.com/mcp) to your client and the agent can use search_chile_public_tenders. Set your key in the X-MercadoPublico-Ticket header so it never has to appear in the chat.

Is Better Llama affiliated with ChileCompra?

No. Better Llama is an independent project, not affiliated with, sponsored by or endorsed by Dirección ChileCompra. The data source is Dirección ChileCompra (Mercado Público API).

Other guides

This guide is also available en español.