# Colombia SECOP Procurement Scraper (`barefoot_grade/colombia-secop-scraper`) Actor

Search Colombia's public procurement system (SECOP) for contract awards — counterparties, values, dates and process URLs, from the open-data mirror. Structured records ready for analysis.

- **URL**: https://apify.com/barefoot\_grade/colombia-secop-scraper.md
- **Developed by:** [Philip Kirkbride](https://apify.com/barefoot_grade) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## colombia-secop-scraper

Apify Actor for Colombia's SECOP II public procurement awards: awarded
state contracts (buyer, supplier NIT, amount COP, dates) read from the
national open-data mirror `datos.gov.co` (Socrata dataset `jbjy-vk9h`,
"SECOP II - Contratos Electrónicos") over plain HTTP — no browser, no
proxy, no key (see `docs/FINDINGS.md` for the probe matrix that settled
this lane; the SECOP portals themselves are IP-gated).

### Input

All filters are optional; an unscoped run returns the most recently
signed contracts:

```json
{"keyword": "computador"}
{"buyer": "MINISTERIO DE EDUCACION"}
{"supplier": "900156264"}
{"dateFrom": "2026-08-01", "dateTo": "2026-08-31"}
{"keyword": "aeronaves", "dateFrom": "2026-08-01", "dateTo": "2026-08-31", "maxResults": 500}
```

- `keyword` / `buyer`: text fragments matched case-insensitively against
  the contract object and the buyer entity name (3-char minimum).
- `supplier`: NIT/document number (e.g. `900156264`) **or** name
  fragment (e.g. `NUEVA EPS`).
- `contractId`: exact SECOP contract id, e.g. `CO1.PCCNTR.3524727`.
- `dateFrom` + `dateTo` (ISO `YYYY-MM-DD`, both or neither): inclusive
  window on the contract-signing date.
- `maxResults` (1–5000, default 100): the Actor pages through the
  mirror 1000 rows at a time and slices.

Unpublished drafts (`estado_contrato = Borrador` — no date, placeholder
suppliers) are excluded from every query. The unscoped default also
requires a signing date — Socrata would otherwise sort undated
contracts ahead of the `fecha_de_firma DESC` "latest" page.

### Output

One dataset item per awarded contract: `contractKey`
(`datos.gov.co:contrato:{idContrato}`), `idContrato`,
`referenciaContrato`, `idProceso` (notice ref), `buyerNit`/`buyerName`,
`departamento`/`ciudad`, `supplierDocType`/`supplierNit`/`supplierName`,
`amount` + `currency` (always COP) + `amountPaid` (valor pagado),
`signedAt`/`startDate`/`endDate` (ISO), `objeto` (description),
`tipoContrato`, `modalidad`, `estado`, `url` (SECOP process page),
`sourceQuery`, `source`, `scrapedAt`. Registry placeholders
("No Definido", "Sin Descripcion") are null.

### How it works

1. `GET https://www.datos.gov.co/resource/jbjy-vk9h.json` with SoQL
   params: `$select` (20 columns), `$where` (draft exclusion + scopes;
   text fragments as `upper(field) LIKE '%…%'`, dates on
   `fecha_de_firma`), `$order` (`fecha_de_firma DESC, id_contrato DESC`
   for stable offsets), `$limit`/`$offset` (1000-row pages).
2. Keyless, cookieless, plain datacenter egress — 6.0M-row mirror of
   the contracts table, updated by Colombia Compra Eficiente.
3. Records are normalized to the unified award shape (same conventions
   as the SEACE registry actor: composite key, `sourceQuery`,
   null-for-blank).
4. Slow-lane hardening (issue #189): 180 s read timeout plus a 4-attempt
   2/4/8s-backoff retry on 429/5xx/transport/JSON failures — a cold
   unscoped sort can take minutes before the first byte. If the query
   still fails, the run exits SUCCEEDED with a one-item dataset note
   (`note`/`error`) instead of crashing.

### Run tests

```bash
uv venv .venv && uv pip install -p .venv/bin/python httpx
PYTHONPATH=src .venv/bin/python -m unittest discover -s tests -v
```

Fixtures under `tests/fixtures/` are live captures from 2026-09-05.

### Cost

One JSON request per 1000 records, no proxy: a 40-record date-window
run is ~1 request/~1.5 s — ≈ **$0.0002/run**; a 5000-record pull
(5 pages) is ≈ $0.0006.

# Actor input Schema

## `keyword` (type: `string`):

Free-text fragment matched against the contract's object (objeto del contrato), e.g. 'computador'. Minimum 3 characters.

## `buyer` (type: `string`):

Contracting entity name fragment, e.g. 'MINISTERIO DE EDUCACION'. Minimum 3 characters.

## `supplier` (type: `string`):

Supplier NIT / document number (e.g. '900156264') or name fragment (e.g. 'NUEVA EPS'). Minimum 3 characters.

## `contractId` (type: `string`):

Exact SECOP contract id, e.g. 'CO1.PCCNTR.3524727'.

## `dateFrom` (type: `string`):

Start of the contract-signing date window (ISO YYYY-MM-DD). Provide together with dateTo.

## `dateTo` (type: `string`):

End of the contract-signing date window (ISO YYYY-MM-DD). Provide together with dateFrom.

## `maxResults` (type: `integer`):

Stop after this many award records (the Actor pages through the mirror 1000 rows at a time).

## Actor input object example

```json
{
  "keyword": "",
  "buyer": "",
  "supplier": "",
  "contractId": "",
  "dateFrom": "",
  "dateTo": "",
  "maxResults": 100
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "keyword": "",
    "buyer": "",
    "supplier": "",
    "contractId": "",
    "dateFrom": "",
    "dateTo": "",
    "maxResults": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("barefoot_grade/colombia-secop-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "keyword": "",
    "buyer": "",
    "supplier": "",
    "contractId": "",
    "dateFrom": "",
    "dateTo": "",
    "maxResults": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("barefoot_grade/colombia-secop-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "keyword": "",
  "buyer": "",
  "supplier": "",
  "contractId": "",
  "dateFrom": "",
  "dateTo": "",
  "maxResults": 100
}' |
apify call barefoot_grade/colombia-secop-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,barefoot_grade/colombia-secop-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/712yds15y0y9U0B5t/builds/dpIyafFuPZfCRGa8l/openapi.json
