# Brazil Tax Code Lookup: NCM, CEST, CFOP, NBS, CNAE, IBGE (`brasil-data/brazil-tax-code-lookup`) Actor

Look up and cross-reference official Brazilian tax tables in one call: NCM (with hierarchy and linked CEST), CEST, CFOP, NBS, LC 116, CNAE 2.3, IBGE municipalities and IBS/CBS reform codes (CST, cClassTrib). Exact, prefix or accent-insensitive search. For AI agents, ERPs and developers.

- **URL**: https://apify.com/brasil-data/brazil-tax-code-lookup.md
- **Developed by:** [Brasil Data](https://apify.com/brasil-data) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 lookup 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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Brazil Tax Code Lookup (NCM, CEST, CFOP, NBS, LC 116, CNAE, IBGE)

Look up and cross-reference the official Brazilian tax tables in a single call. Send a list of codes or free texts and get back each code's official description, its hierarchy, cross-references to the other tables and the source it came from.

| Table (`table`) | What it is | Official source |
|---|---|---|
| `ncm` | Mercosur goods nomenclature (8 digits) with section > chapter > heading > subheading > item | Portal Único Siscomex (Receita Federal / SECEX) |
| `cest` | Tax-substitution codes (ICMS-ST) with the NCM codes listed for each one | CONFAZ, Convênio ICMS 142/2018 |
| `cfop` | Fiscal operation codes, with the explanatory note for each code | CONFAZ, Annex II of Convênio s/nº of 1970 (Ajuste SINIEF 3/2024 plus later amendments) |
| `nbs` | Brazilian services nomenclature (9 digits) | Receita Federal reform calculator, open data |
| `lc116` | Municipal service list (ISS) of Lei Complementar 116/2003 | Planalto, consolidated text of the law |
| `cnae` | CNAE 2.3 economic activities, from section down to subclass | IBGE / CONCLA API |
| `municipality` | IBGE municipality codes (7 digits) with state and region | IBGE Localidades API |
| `reform_class` | IBS/CBS tax-reform CST and cClassTrib codes, with legal basis and reduction percentages | Receita Federal reform calculator, open data |

**Who it is for:** AI agents filling in invoices (NF-e / NFS-e), ERP and e-commerce integrations, accounting tools, and developers who need reliable Brazilian code tables without scraping half a dozen government sites.

### Why use it

- **One call, many tables.** `auto` mode works out which table a code belongs to from its format. `8471.30.12` is an NCM code, `5.102` a CFOP, `01.07` an LC 116 subitem and `3550308` a municipality.
- **Cross-references nobody else joins.**
  - NCM to its linked CEST codes, most specific match first.
  - CEST to the NCM codes it lists.
  - CST to its cClassTrib codes.
  - LC 116 item to its subitems.
  - CNAE level to its child levels.
- **Hierarchy included.** An NCM result includes its section, chapter, heading and subheading, plus a readable `description_path`, so a bare item called "-- Outros" still makes sense.
- **Validity handled.** CEST entries that are revoked or not yet in force (for example, new wording that takes effect next month) are flagged in `record_status` as `in_force`, `revoked` or `scheduled`, with `valid_from` and `valid_to` dates.
- **Fast and cheap.** The tables are bundled as a versioned snapshot inside the Actor, so a run does not depend on government sites being up. The example input finishes in a few seconds.
- **Traceable.** Every record carries `source_name`, `source_url`, `source_version` and `retrieved_at`.

### Input

```json
{
  "queries": ["8471.30.12", "5102", "01.07", "6201-5/01", "parafuso"],
  "table": "auto",
  "search_mode": "auto",
  "include_related": true,
  "language": "en",
  "max_results_per_query": 10
}
```

- `queries`: codes, typed with or without punctuation, or free text. Text search ignores accents and case and matches word prefixes, so `informatica suport` finds "Suporte técnico em informática". For municipalities, a trailing state code narrows the search: `campinas sp`. Up to 1000 queries per run.
- `table`: one of `auto` (all tables), `ncm`, `cest`, `cfop`, `nbs`, `lc116`, `cnae`, `municipality` or `reform_class`. In `auto` mode the same digits can match several tables: `5102` returns CFOP 5.102 and NCM heading 51.02. Punctuation narrows the match (`5.102` matches only the CFOP), or set `table` to restrict the search.
- `search_mode`:
  - `auto` (default): exact match for codes, text search for words.
  - `exact`: the code itself.
  - `prefix`: every code that starts with the query. `8471` with `table: ncm` returns all codes under heading 84.71.
  - `text`: search in the official descriptions.
- `include_related`: adds cross-references (default `true`).
- `language`: language of the status messages, `en` or `pt`. Official descriptions are always returned in Portuguese, exactly as published. No machine translation is applied.
- `max_results_per_query`: from 1 to 200, default 10.

### Output (one dataset item per record)

```json
{
  "query": "8471.30.12",
  "status": "found",
  "table": "ncm",
  "code": "8471.30.12",
  "description": "De peso inferior a 3,5 kg, com tela de área superior a 140 cm², mas inferior a 560 cm²",
  "description_language": "pt-BR",
  "level": "subitem",
  "record_status": "in_force",
  "valid_from": "2022-04-01",
  "valid_to": null,
  "match_type": "exact",
  "hierarchy": [
    {"table": "ncm", "level": "section", "code": "XVI", "description": null, "chapters": "84-85"},
    {"table": "ncm", "level": "chapter", "code": "84", "description": "Reatores nucleares, caldeiras, máquinas, ..."},
    {"table": "ncm", "level": "heading", "code": "84.71", "description": "Máquinas automáticas para processamento de dados ..."},
    {"table": "ncm", "level": "subheading_2", "code": "8471.30", "description": "- Máquinas automáticas ... portáteis ..."},
    {"table": "ncm", "level": "item", "code": "8471.30.1", "description": "Capazes de funcionar sem fonte externa de energia"}
  ],
  "details": {"legal_act": "Res Gecex 272/2021", "description_path": "Máquinas automáticas ... > ... > De peso inferior a 3,5 kg ..."},
  "related": [
    {"table": "cest", "code": "21.028.00", "description": "Máquinas automáticas para processamento de dados, portáteis ...",
     "relation": "cest_for_ncm", "record_status": "in_force", "matched_ncm": "8471.30"}
  ],
  "source_name": "NCM - Nomenclatura Comum do Mercosul (Portal Único Siscomex, Receita Federal/SECEX)",
  "source_version": "Resolução Gecex nº 926/2026 (Vigente em 25/10/2026)",
  "source_url": "https://portalunico.siscomex.gov.br/classif/api/publico/nomenclatura/download/json?perfil=PUBLICO",
  "retrieved_at": "2026-10-25T03:17:26+00:00",
  "data_license": "Brazilian official act (Resolução Gecex) / federal open data",
  "terms_note": "Official act / public-sector open data ..."
}
```

When a query matches nothing, the Actor returns a free item so you know it was processed:

```json
{"query": "9999.99.99", "status": "not_found", "code": null, "message": "No record found for this query in the selected table(s)."}
```

A query that does not fit the selected table's format gets `status: "invalid_format"` and a hint. For example, `table: cfop` with `51023` returns "CFOP codes have 4 digits...".

### Pricing (pay per event)

| Event | Price | When |
|---|---|---|
| `lookup-result` | **US$ 0.001** per record returned | Each item with `status: "found"` |

`not_found` and `invalid_format` items are **never charged**. The run stops producing results as soon as your maximum charge per run is reached. At this price, 1,000 lookups cost US$ 1.

### Limits and caveats

- **Data freshness.** The data is a snapshot built from the official sources. `source_version` and `retrieved_at` on every item tell you which version you got. The snapshot is refreshed about monthly.
- **NCM to CEST links are mechanical.** A CEST applies only when both the NCM code and the CEST description fit the product. Some CEST codes (for example, door-to-door sales in segment 28) list whole NCM chapters.
- **NCM section titles are not included.** Only the section's roman numeral and chapter range are returned, because no open, machine-readable official source for the titles was found.
- **Hierarchy descriptions for NBS headings** and the NBS ↔ LC 116 ↔ cClassTrib correlation come from the national NFS-e standard. They are present only when that optional dataset is bundled. Otherwise those fields are `null` or empty.
- **No NCM to cClassTrib table.** No open table maps NCM codes to cClassTrib, so the Actor does not guess one. Use the official reform calculator to validate a specific NCM/cClassTrib pair.
- **Not tax advice.** The official publication prevails in case of divergence.

### Use with AI agents (MCP)

Every public Apify Actor is available as a tool through the Apify MCP server (`mcp.apify.com`), so Claude, ChatGPT, Cursor and other MCP clients can call this Actor directly. An agent can send `{"queries": ["<code or description>"], "table": "auto"}` and read `status`, `code`, `description`, `hierarchy` and `related`. Prefer exact codes when you have them. Use text search ("parafuso", "suporte informatica") to find candidates, then confirm by code. The output fields are stable, in English snake_case, and every record cites its official source.

### Português (resumo)

Consulta e cruzamento das tabelas fiscais oficiais brasileiras em uma chamada:

- NCM, com seção, capítulo e posição, e os CEST vinculados;
- CEST, do Convênio ICMS 142/2018;
- CFOP, do Anexo II do Convênio s/nº de 1970;
- NBS;
- lista de serviços da LC 116/2003;
- CNAE 2.3;
- municípios do IBGE;
- CST e cClassTrib do IBS/CBS.

Funciona com busca por código exato, por prefixo ou por texto sem acento. As descrições vêm exatamente como foram publicadas, em português. Cada registro traz a fonte oficial (`source_url`, `source_version`, `retrieved_at`).

O preço é US$ 0,001 por registro encontrado. Consulta sem resultado ou com formato inválido não é cobrada.

Os dados são um retrato versionado das fontes oficiais, atualizado mensalmente. Em caso de divergência, vale a publicação oficial. Isto não é consultoria tributária.

# Actor input Schema

## `queries` (type: `array`):

Codes or free texts to look up, one per line. Codes may be typed with or without punctuation (8471.30.12 or 84713012, 5.102 or 5102, 6201-5/01, 3550308). Texts are matched without accents (e.g. 'parafuso', 'sao paulo', 'suporte informatica'). Maximum 1000 per run.

## `table` (type: `string`):

Which table to search. 'auto' searches all tables and may return the same code from several tables (e.g. 5102 is CFOP 5.102 and NCM heading 51.02); pick a table to restrict.

## `search_mode` (type: `string`):

'auto' = exact code match for code-like queries and text search otherwise. 'exact' = exact code. 'prefix' = every code starting with the query (e.g. 8471 -> all NCM under heading 84.71). 'text' = accent-insensitive word search in official descriptions.

## `include_related` (type: `boolean`):

Add related records: NCM -> linked CEST codes, CEST -> listed NCM codes, CST -> cClassTrib codes, LC 116 item -> subitems, CNAE -> child levels (and NBS <-> LC 116 / cClassTrib when the optional NFS-e correlation is bundled). Hierarchy (e.g. NCM section/chapter/heading, municipality -> state) is always returned.

## `language` (type: `string`):

Language of status messages. Official descriptions are always returned in Portuguese (pt-BR) exactly as published; no machine translation is applied.

## `max_results_per_query` (type: `integer`):

Upper limit of records returned for each query (relevant for prefix and text search). Each returned record is one billable result.

## Actor input object example

```json
{
  "queries": [
    "8471.30.12",
    "5.102",
    "01.07",
    "6201-5/01",
    "3550308",
    "200003",
    "parafuso"
  ],
  "table": "auto",
  "search_mode": "auto",
  "include_related": true,
  "language": "en",
  "max_results_per_query": 10
}
```

# Actor output Schema

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

Official tax-table records (and not-found/invalid queries, free) in the default dataset.

# 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 = {
    "queries": [
        "8471.30.12",
        "5102",
        "01.07"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("brasil-data/brazil-tax-code-lookup").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 = { "queries": [
        "8471.30.12",
        "5102",
        "01.07",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("brasil-data/brazil-tax-code-lookup").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 '{
  "queries": [
    "8471.30.12",
    "5102",
    "01.07"
  ]
}' |
apify call brasil-data/brazil-tax-code-lookup --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,brasil-data/brazil-tax-code-lookup"
        }
    }
}
```

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/9IDYzQTDdndfFGoee/builds/1vYAHDq5wVrBIDVaY/openapi.json
