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 (
fetchDetailsoption, 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
| Parameter | What it does |
|---|---|
source | licitaciones (tenders), ordenes_compra (purchase orders) or compra_agil (beta) |
dateFrom / dateTo | Chilean calendar days in YYYY-MM-DD format; today by default; 31 days maximum |
tenderStatus | activas, publicada, cerrada, desierta, adjudicada, revocada, suspendida, todos |
purchaseOrderStatus | Official purchase order statuses, such as aceptada or recepcionconforme |
buyerCode / supplierCode | Mercado Público buyer (agency) or supplier code |
codes | Exact codes; all other filters are ignored |
maxItems | Maximum 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 -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
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:
{"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.
{
"mcpServers": {
"better-llama": {
"url": "https://mcp.betterllama.com/mcp",
"headers": {
"X-MercadoPublico-Ticket": "<your key>"
}
}
}
}claude mcp add --transport http better-llama https://mcp.betterllama.com/mcpSetup for Claude, Codex, Gemini CLI, Windsurf, VS Code and other clients: connect your agent.
- Code examples (Python, LangChain, OpenAI Agents SDK, Vercel AI SDK, Mastra, Node.js, n8n and client setup) on GitHub
- Listing on Glama
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).
{
"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
- Chile open data APIs: official sources by API and MCP — map of the official Chilean sources available by API and MCP, how to find the tool with search_tools, one real call per family and an index of every guide.
- Chile economic indicators API: UF, dollar, euro, CPI and TPM — One real call per indicator (UF, dollar, euro, UTM, CPI, TMC, TIP, TPM, Imacec, GDP, unemployment and real exchange rate), from the CMF or the Central Bank, with curl, Python, JavaScript and MCP.
- Chile fuel prices API: gasoline 93, 95, 97, diesel and LPG from Bencina en Línea — CNE data with no sign-up, the cheapest by comuna or near a point, curl, Python and JavaScript examples, and MCP usage.
- Chilexpress API: coverage by comuna, shipping quotes and tracking — covered comunas and sectors with their code and no key, names that differ from the official ones, quotes and tracking with your free keys, and MCP usage.
- Chile earthquakes API: latest quake, magnitude, depth and alerts — Public-domain USGS data with Chile local time, no USGS key, curl and Python examples, and MCP usage.
- Colombia SECOP II API: public procurement contracts and processes — open data from datos.gov.co with no key, curl and Python examples, and MCP usage.
- Peru BCRP API: exchange rate, inflation and rates — BCRPData series with no key, curl and Python examples, and MCP usage.
- Colombia TRM API: today's TRM and the COP/USD rate — Superintendencia Financiera data via datos.gov.co with no key, curl and Python examples, and MCP usage.
- Chile public holidays API: 2026 holidays, business days and RUT — National, regional and local holidays with no key, curl and Python examples, and MCP usage.
- Chile Official Gazette API: laws, decrees and new companies — Laws, decrees, notices and company incorporations with CVE and official PDF, no key, curl and Python examples, and MCP usage.
- Banxico API: Mexico's FIX exchange rate, UDIS and TIIE — Banco de México SIE indicators with no token to request, curl and Python examples, and MCP usage.
- Chile electricity market API: marginal cost, generation and demand — Coordinador Eléctrico Nacional grid data with no user_key to request, curl and Python examples, and MCP usage.
- Chile CMF API: UF value, dollar, UTM and maximum conventional rate — the seven API CMF Bancos series with no API key to request, curl and Python examples, and MCP usage.
- Chile USD/CLP exchange rate API: the observed dollar as JSON — today's rate, daily series by month, range or year and the warning for values published in advance, with CMF data, curl, Python and JavaScript examples, and MCP usage.
- Chile UF API: the Unidad de Fomento value as JSON — today's UF, full month, next month's days already published, range or year, with CMF data and a Central Bank cross-check, curl, Python and JavaScript examples, and MCP usage.
- Central Bank of Chile API: BDE series as JSON — dollar, UF, policy rate, CPI, Imacec, GDP, unemployment and any series by code, series search, curl, Python and JavaScript examples, and MCP usage.
- Chile RUT validation API: check digit as JSON — the modulo 11 algorithm, accepted formats, computing the check digit, batches and privacy, curl, Python and JavaScript examples, and MCP usage.
- Chile communes API: regions, provinces and CUT codes — all 346 communes with CUT codes, region filters, name search, curl, Python and JavaScript examples, and MCP usage.
- Chile business days API: deadlines and business-day counts — business-day deadlines from a notice date, Saturdays as business days, calendar days, business days per month, regional holidays and edge cases, with curl, Python and JavaScript, and MCP usage.
This guide is also available en español.