Documentação da API de Tributação

Visão Geral

Esta API permite consultar a tributação de produtos e serviços no Brasil com base nos dados do IBPT, individualmente ou em massa por estado.

Endpoint da API (Consulta Individual)

https://api-ibpt.seunegocionanuvem.com.br/api_ibpt.php?codigo=22030000&uf=SP

Novo: Baixar Todos os NCMs de um Estado

Obtenha todos os NCMs de uma UF em um único JSON usando:

https://api-ibpt.seunegocionanuvem.com.br/api_ibpt_json.php?uf=SP

Substitua SP pela UF desejada. O retorno contém metadados (versão, uf, total) e um array ncm com todos os registros.

Exemplo de Retorno (resumido):
{
  "versao": "25.2.E",
  "uf": "SP",
  "total": 12146,
  "ncm": [
    {
      "codigo": "00000000",
      "descricao": "PRODUTO NAO ESPECIFICADO NA LISTA DE NCM",
      "nacionalfederal": "13.45",
      "importadosfederal": "15.45",
      "estadual": "18.00",
      "municipal": "0.00",
      "vigenciainicio": "2025-09-20",
      "vigenciafim": "2025-10-31",
      "versao": "25.2.E",
      "fonte": "IBPT/empresometro.com.br",
      "uf": "SP"
    },
    {
      "codigo": "0101",
      "descricao": "Analise e desenvolvimento de sistemas.",
      "nacionalfederal": "13.45",
      "importadosfederal": "15.45",
      "estadual": "0.00",
      "municipal": "3.90",
      "vigenciainicio": "2025-09-20",
      "vigenciafim": "2025-10-31",
      "versao": "25.2.E",
      "fonte": "IBPT/empresometro.com.br",
      "uf": "SP"
    }
  ]
}

Exemplo em PHP (Consulta Individual)

<?php
$codigo = '21069090';
$uf = 'SP';

// Consulta individual
$url = "https://api-ibpt.seunegocionanuvem.com.br/api_ibpt.php?codigo=$codigo&uf=$uf";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept: application/json']);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($httpCode == 200) {
    $data = json_decode($response, true);
    echo "Nacional: {$data['nacionalfederal']}%\n";
} else {
    echo "Erro: " . $response;
}
curl_close($ch);

// Baixar todos os NCMs de uma UF (exemplo)
$ufAll = 'SP';
$urlAll = "https://api-ibpt.seunegocionanuvem.com.br/api_ibpt_json.php?uf=$ufAll";

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $urlAll);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_HTTPHEADER, ['Accept: application/json']);

$responseAll = curl_exec($ch2);
$httpCode2 = curl_getinfo($ch2, CURLINFO_HTTP_CODE);

if ($httpCode2 == 200) {
    $dataAll = json_decode($responseAll, true);
    // Exemplo: salvar em arquivo local
    file_put_contents("ncm_$ufAll.json", json_encode($dataAll, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
    echo "Arquivo ncm_$ufAll.json salvo. Total: " . ($dataAll['total'] ?? 'desconhecido') . "\n";
} else {
    echo "Erro ao baixar todos NCMs: " . $responseAll;
}
curl_close($ch2);
?>

Exemplo em C# (Consulta Individual e Download por UF)

using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

class Program
{
    static async Task Main()
    {
        var ncm = "22030000";
        var uf = "SP";
        var url = $"https://api-ibpt.seunegocionanuvem.com.br/api_ibpt.php?codigo={ncm}&uf={uf}";

        using HttpClient client = new HttpClient();
        try
        {
            var response = await client.GetStringAsync(url);
            var data = JObject.Parse(response);
            Console.WriteLine($"Descrição: {data["descricao"]}");
            Console.WriteLine($"Imposto Nacional: {data["nacionalfederal"]}%");
            Console.WriteLine($"Imposto Importado: {data["importadosfederal"]}%");
            Console.WriteLine($"Estadual: {data["estadual"]}%");
            Console.WriteLine($"Municipal: {data["municipal"]}%");
            Console.WriteLine($"Vigência: {data["vigenciainicio"]} a {data["vigenciafim"]}");
            Console.WriteLine($"UF: {data["uf"]}");
        }
        catch (Exception e)
        {
            Console.WriteLine($"Erro: {e.Message}");
        }

        // Download completo por UF
        var ufAll = "SP";
        var urlAll = $"https://api-ibpt.seunegocionanuvem.com.br/api_ibpt_json.php?uf={ufAll}";
        try
        {
            var jsonAll = await client.GetStringAsync(urlAll);
            // salvar em disco
            System.IO.File.WriteAllText($"ncm_{ufAll}.json", jsonAll);
            Console.WriteLine($"Arquivo ncm_{ufAll}.json salvo.");
        }
        catch (Exception e)
        {
            Console.WriteLine($"Erro ao baixar NCMs por UF: {e.Message}");
        }
    }
}

Exemplo em Delphi (Consulta Individual e Download por UF)

uses
  System.SysUtils, System.Net.HttpClient, System.JSON;

var
  HttpClient: THttpClient;
  Response: IHTTPResponse;
  Data: TJSONObject;
  s: string;
begin
  HttpClient := THttpClient.Create;
  try
    // Consulta individual
    Response := HttpClient.Get('https://api-ibpt.seunegocionanuvem.com.br/api_ibpt.php?codigo=22030000&uf=SP');
    s := Response.ContentAsString;
    Data := TJSONObject.ParseJSONValue(s) as TJSONObject;
    if Assigned(Data) then
    begin
      WriteLn('Descrição: ' + Data.GetValue('descricao').Value);
      WriteLn('Imposto Nacional: ' + Data.GetValue('nacionalfederal').Value + '%');
    end;

    // Download completo por UF
    Response := HttpClient.Get('https://api-ibpt.seunegocionanuvem.com.br/api_ibpt_json.php?uf=SP');
    s := Response.ContentAsString;
    // salvar em arquivo local
    TFile.WriteAllText('ncm_SP.json', s, TEncoding.UTF8);
    WriteLn('Arquivo ncm_SP.json salvo.');
  finally
    HttpClient.Free;
  end;
end.

Pesquisar Tributação (Individual)