# PNCP Brazilian Public Procurement Scraper (`aryrabelo/pncp-procurement-scraper`) Actor

Search Brazilian government tenders (licitações) from PNCP — the official Portal Nacional de Contratações Públicas. Public open-data API, no auth, no ToS risk.

- **URL**: https://apify.com/aryrabelo/pncp-procurement-scraper.md
- **Developed by:** [ARY RABELO](https://apify.com/aryrabelo) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.20 / 1,000 resultado de licitaçãos

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## PNCP Brazilian Public Procurement Scraper 🇧🇷

Search and monitor **Brazilian government tenders (licitações)** straight from **PNCP** — the *Portal Nacional de Contratações Públicas*, the official government portal mandated by **Lei 14.133/2021**. Get structured JSON for every procurement: object, value, agency, state, modality, deadlines, and the direct edital link.

Built on PNCP's **official open-data REST API** — 100% public data, **no login, no cookies, no CAPTCHA, no scraping tricks**. It just works, and it keeps working.

---

### 💰 Pricing — $1.20 / 1,000 results

**40% cheaper than the incumbent** (`pncp-licitacoes-brasil`, $2.00/1,000). Pay only for the tenders you actually collect (pay-per-result). No monthly subscription, no proxy surcharge — because this hits a free public API, there are no proxy costs to pass on.

| Actor | Price / 1,000 | Data source |
|---|---|---|
| **This actor** | **$1.20** | Official PNCP Consulta API |
| pncp-licitacoes-brasil | $2.00 | PNCP |

---

### ✅ Why this actor

- **Zero legal risk** — PNCP is official open government data. No ToS violation, no anti-bot arms race, no PII harvesting. Unlike marketplace/social scrapers, this is data the government *publishes for you to consume*.
- **Reliable by design** — the API returns clean JSON. Built-in exponential-backoff retry rides out PNCP's occasional server hiccups (`500 – erro de banco`), so your run finishes even when the portal is flaky.
- **Filter where it counts** — by date range, modality (Pregão Eletrônico, Dispensa, etc.), state (UF), municipality (IBGE code), agency (CNPJ), and free-text keywords on the object.
- **Two modes** — tenders **by publication date**, or only those **currently open for proposals**.

---

### 🔧 Input

| Field | Type | Description |
|---|---|---|
| `queryType` | select | `publicacao` (by publication date) or `proposta` (open for proposals). Default `publicacao`. |
| `dataInicial` | string | `YYYY-MM-DD`. Defaults to 7 days ago. (publicacao only) |
| `dataFinal` | string | `YYYY-MM-DD`. Defaults to today. |
| `modalidades` | array | Modality codes. Required for `publicacao`. Default `[6, 8]` (Pregão Eletrônico + Dispensa). |
| `uf` | string | State filter, e.g. `SP`, `RJ`. Optional. |
| `codigoMunicipioIbge` | string | 7-digit IBGE municipality code. Optional. |
| `cnpj` | string | Agency CNPJ (14 digits). Optional. |
| `keywords` | array | Keep only tenders whose object contains ANY term (accent/case-insensitive). Optional. |
| `includeItems` | boolean | Also fetch each tender's line items. Multiplies requests — off by default. |
| `maxItems` | integer | Hard cap on records collected. Default `1000`. |

#### Modality codes
`1` Leilão Eletrônico · `2` Diálogo Competitivo · `3` Concurso · `4` Concorrência Eletrônica · `5` Concorrência Presencial · `6` Pregão Eletrônico · `7` Pregão Presencial · `8` Dispensa · `9` Inexigibilidade · `10` Manifestação de Interesse · `11` Pré-qualificação · `12` Credenciamento · `13` Leilão Presencial

#### Example input

```json
{
  "queryType": "publicacao",
  "dataInicial": "2026-07-01",
  "dataFinal": "2026-07-09",
  "modalidades": [6, 8],
  "uf": "SP",
  "keywords": ["notebook", "merenda escolar"],
  "maxItems": 500
}
````

***

### 📤 Output

Each dataset item:

```json
{
  "numeroControlePNCP": "00394460000141-1-000123/2026",
  "objeto": "Aquisição de notebooks para escolas municipais",
  "modalidade": "Pregão - Eletrônico",
  "modalidadeId": 6,
  "modoDisputa": "Aberto",
  "situacao": "Divulgada no PNCP",
  "valorTotalEstimado": 150000.5,
  "valorTotalHomologado": null,
  "srp": false,
  "orgaoRazaoSocial": "Prefeitura Municipal de Exemplo",
  "orgaoCnpj": "00394460000141",
  "unidadeNome": "Secretaria de Educação",
  "uf": "SP",
  "municipio": "São Paulo",
  "numeroCompra": "90001/2026",
  "processo": "1234/2026",
  "anoCompra": 2026,
  "sequencialCompra": 123,
  "dataPublicacaoPncp": "2026-07-02T10:00:00",
  "dataAberturaProposta": "2026-07-05T09:00:00",
  "dataEncerramentoProposta": "2026-07-20T14:00:00",
  "linkSistemaOrigem": "https://...",
  "editalUrl": "https://pncp.gov.br/app/editais/00394460000141/2026/123",
  "scrapedAt": "2026-07-09T18:32:38.000Z",
  "itens": null,
  "_raw": { "...": "the full original PNCP record" }
}
```

The full untouched PNCP record is always kept under `_raw`, so no field is ever lost.

***

### 🎯 Who uses this

- **Bidders / suppliers** monitoring new opportunities in their category and region.
- **Bid-management SaaS** and dashboards needing a clean licitações feed.
- **Journalists & researchers** auditing public spending.
- **Analysts** tracking procurement by agency, modality, or value.

***

### ⚖️ Legal

PNCP publishes this data as open government data under Brazil's public transparency and procurement law (Lei 14.133/2021). This actor consumes the official public Consulta API. No authentication is bypassed and no private or personal data is collected.

# Actor input Schema

## `queryType` (type: `string`):

publicacao = tenders by publication date range. proposta = tenders currently OPEN for proposals (up to dataFinal).

## `dataInicial` (type: `string`):

YYYY-MM-DD. Defaults to 7 days ago. Ignored for 'proposta'.

## `dataFinal` (type: `string`):

YYYY-MM-DD. Defaults to today.

## `modalidades` (type: `array`):

PNCP modalidade codes. Required for 'publicacao'. 6=Pregão Eletrônico, 8=Dispensa, 4=Concorrência Eletrônica, 9=Inexigibilidade, 12=Credenciamento. Defaults to \[6, 8].

## `uf` (type: `string`):

Two-letter Brazilian state code to filter by (e.g. SP, RJ, MG). Optional.

## `codigoMunicipioIbge` (type: `string`):

7-digit IBGE code. Look up at servicodados.ibge.gov.br/api/v1/localidades/municipios?nome=YOURCITY. Santarém-PA = 1506807.

## `cnpj` (type: `string`):

14-digit CNPJ of the contracting agency to filter by. Optional.

## `keywords` (type: `array`):

Keep only tenders whose objeto contains ANY of these terms (accent/case-insensitive). Optional.

## `includeItems` (type: `boolean`):

Also fetch each tender's line items (products/services). Multiplies request count — leave off for large runs.

## `maxItems` (type: `integer`):

Stop after this many tender records. Protects your spend.

## Actor input object example

```json
{
  "queryType": "publicacao",
  "dataInicial": "2026-07-01",
  "dataFinal": "2026-07-09",
  "modalidades": [
    6,
    8
  ],
  "uf": "SP",
  "codigoMunicipioIbge": "1506807",
  "keywords": [
    "notebook",
    "merenda escolar",
    "obra"
  ],
  "includeItems": false,
  "maxItems": 1000
}
```

# 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 = {
    "modalidades": [
        6,
        8
    ],
    "keywords": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("aryrabelo/pncp-procurement-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 = {
    "modalidades": [
        6,
        8,
    ],
    "keywords": [],
}

# Run the Actor and wait for it to finish
run = client.actor("aryrabelo/pncp-procurement-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "modalidades": [
    6,
    8
  ],
  "keywords": []
}' |
apify call aryrabelo/pncp-procurement-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=aryrabelo/pncp-procurement-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "PNCP Brazilian Public Procurement Scraper",
        "description": "Search Brazilian government tenders (licitações) from PNCP — the official Portal Nacional de Contratações Públicas. Public open-data API, no auth, no ToS risk.",
        "version": "1.0",
        "x-build-id": "3txlj1jJ0BBJLrZLO"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/aryrabelo~pncp-procurement-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-aryrabelo-pncp-procurement-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/aryrabelo~pncp-procurement-scraper/runs": {
            "post": {
                "operationId": "runs-sync-aryrabelo-pncp-procurement-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/aryrabelo~pncp-procurement-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-aryrabelo-pncp-procurement-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "queryType": {
                        "title": "Query type",
                        "enum": [
                            "publicacao",
                            "proposta"
                        ],
                        "type": "string",
                        "description": "publicacao = tenders by publication date range. proposta = tenders currently OPEN for proposals (up to dataFinal).",
                        "default": "publicacao"
                    },
                    "dataInicial": {
                        "title": "Start date (publicacao only)",
                        "type": "string",
                        "description": "YYYY-MM-DD. Defaults to 7 days ago. Ignored for 'proposta'."
                    },
                    "dataFinal": {
                        "title": "End date",
                        "type": "string",
                        "description": "YYYY-MM-DD. Defaults to today."
                    },
                    "modalidades": {
                        "title": "Modalidade codes",
                        "type": "array",
                        "description": "PNCP modalidade codes. Required for 'publicacao'. 6=Pregão Eletrônico, 8=Dispensa, 4=Concorrência Eletrônica, 9=Inexigibilidade, 12=Credenciamento. Defaults to [6, 8].",
                        "default": [
                            6,
                            8
                        ]
                    },
                    "uf": {
                        "title": "State (UF)",
                        "type": "string",
                        "description": "Two-letter Brazilian state code to filter by (e.g. SP, RJ, MG). Optional."
                    },
                    "codigoMunicipioIbge": {
                        "title": "IBGE municipality code",
                        "pattern": "^[0-9]{7}$",
                        "type": "string",
                        "description": "7-digit IBGE code. Look up at servicodados.ibge.gov.br/api/v1/localidades/municipios?nome=YOURCITY. Santarém-PA = 1506807."
                    },
                    "cnpj": {
                        "title": "Órgão CNPJ",
                        "type": "string",
                        "description": "14-digit CNPJ of the contracting agency to filter by. Optional."
                    },
                    "keywords": {
                        "title": "Keywords",
                        "type": "array",
                        "description": "Keep only tenders whose objeto contains ANY of these terms (accent/case-insensitive). Optional.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "includeItems": {
                        "title": "Include line items",
                        "type": "boolean",
                        "description": "Also fetch each tender's line items (products/services). Multiplies request count — leave off for large runs.",
                        "default": false
                    },
                    "maxItems": {
                        "title": "Max items",
                        "minimum": 1,
                        "maximum": 500000,
                        "type": "integer",
                        "description": "Stop after this many tender records. Protects your spend.",
                        "default": 1000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
