iptuapi 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,338 +1,518 @@
1
1
  /**
2
- * IPTU API - JavaScript/TypeScript SDK
3
- *
4
- * SDK oficial para integração com a IPTU API.
5
- * Suporta retry automático, logging e rate limit tracking.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { IPTUClient } from 'iptuapi';
10
- *
11
- * const client = new IPTUClient('sua_api_key');
12
- * const resultado = await client.consultaEndereco('Avenida Paulista', '1000');
13
- * console.log(resultado);
14
- * ```
15
- *
16
- * @example
17
- * ```typescript
18
- * // Com configuração customizada
19
- * const client = new IPTUClient('sua_api_key', {
20
- * timeout: 60000,
21
- * retries: 5,
22
- * logger: console,
23
- * });
24
- * ```
2
+ * Tipos e interfaces para a IPTU API.
25
3
  */
26
- type Cidade = 'sp' | 'bh' | 'recife';
27
- declare const CidadeEnum: {
28
- readonly SAO_PAULO: Cidade;
29
- readonly BELO_HORIZONTE: Cidade;
30
- readonly RECIFE: Cidade;
31
- };
4
+ interface RetryConfig {
5
+ maxRetries: number;
6
+ initialDelay: number;
7
+ maxDelay: number;
8
+ backoffFactor: number;
9
+ retryableStatusCodes: number[];
10
+ }
11
+ interface ClientConfig {
12
+ baseUrl: string;
13
+ timeout: number;
14
+ retryConfig: RetryConfig;
15
+ }
16
+ interface ClientOptions {
17
+ baseUrl?: string;
18
+ timeout?: number;
19
+ retryConfig?: Partial<RetryConfig>;
20
+ }
32
21
  interface RateLimitInfo {
33
22
  limit: number;
34
23
  remaining: number;
35
- reset: number;
36
- resetDate: Date;
24
+ resetAt: Date;
37
25
  }
38
- interface ConsultaEnderecoParams {
39
- logradouro: string;
40
- numero?: string;
41
- complemento?: string;
42
- cidade?: Cidade;
43
- incluirHistorico?: boolean;
44
- incluirComparaveis?: boolean;
45
- incluirZoneamento?: boolean;
46
- }
47
- interface ConsultaEnderecoResult {
26
+ interface Imovel {
48
27
  sql: string;
49
28
  logradouro: string;
50
- numero?: string;
51
- complemento?: string;
52
- bairro?: string;
29
+ numero: string;
30
+ bairro: string;
53
31
  cep?: string;
54
- area_terreno?: number;
55
- area_construida?: number;
56
- valor_venal_terreno?: number;
57
- valor_venal_construcao?: number;
58
- valor_venal_total?: number;
59
- iptu_valor?: number;
60
- ano_construcao?: number;
61
- tipo_uso?: string;
32
+ areaTerreno?: number;
33
+ areaConstruida?: number;
34
+ valorVenal?: number;
35
+ valorVenalTerreno?: number;
36
+ valorVenalConstrucao?: number;
37
+ anoConstrucao?: number;
38
+ uso?: string;
39
+ padrao?: string;
40
+ testada?: number;
41
+ fracaoIdeal?: number;
42
+ quantidadePavimentos?: number;
43
+ }
44
+ interface Zoneamento {
45
+ zona: string;
46
+ usoPermitido: string;
47
+ coeficienteAproveitamento?: number;
48
+ taxaOcupacao?: number;
49
+ gabarito?: number;
50
+ recuoFrontal?: number;
51
+ legislacao?: string;
52
+ }
53
+ interface Valuation {
54
+ valorEstimado: number;
55
+ valorMinimo: number;
56
+ valorMaximo: number;
57
+ confianca: number;
58
+ valorM2: number;
59
+ metodologia: string;
60
+ dataReferencia: string;
61
+ }
62
+ interface ValuationParams {
63
+ areaTerreno: number;
64
+ areaConstruida: number;
65
+ bairro: string;
66
+ cidade?: string;
62
67
  zona?: string;
63
- historico?: HistoricoItem[];
64
- comparaveis?: ComparavelItem[];
65
- zoneamento?: ZoneamentoResult;
68
+ tipoUso?: string;
69
+ tipoPadrao?: string;
70
+ anoConstrucao?: number;
66
71
  }
67
- interface ConsultaSQLResult {
72
+ interface Comparavel {
68
73
  sql: string;
69
- ano?: number;
70
- valor_venal?: number;
71
- valor_venal_terreno?: number;
72
- valor_venal_construcao?: number;
73
- valor_venal_total?: number;
74
- iptu_valor?: number;
75
- logradouro?: string;
76
- numero?: string;
77
- bairro?: string;
78
- area_terreno?: number;
79
- area_construida?: number;
74
+ logradouro: string;
75
+ bairro: string;
76
+ areaConstruida: number;
77
+ valorVenal: number;
78
+ valorM2: number;
79
+ distanciaKm?: number;
80
80
  }
81
- interface HistoricoItem {
82
- ano: number;
83
- valor_venal_terreno?: number;
84
- valor_venal_construcao?: number;
85
- valor_venal_total?: number;
86
- iptu_valor?: number;
81
+ interface ComparablesParams {
82
+ bairro: string;
83
+ areaMin: number;
84
+ areaMax: number;
85
+ cidade?: string;
86
+ limit?: number;
87
87
  }
88
- interface ComparavelItem {
89
- sql?: string;
90
- logradouro?: string;
91
- numero?: string;
92
- bairro?: string;
93
- area_terreno?: number;
94
- area_construida?: number;
95
- valor_venal_total?: number;
96
- distancia_metros?: number;
88
+ interface ITBIStatus {
89
+ protocolo: string;
90
+ status: string;
91
+ dataSolicitacao: string;
92
+ valorTransacao: number;
93
+ valorVenalReferencia: number;
94
+ baseCalculo: number;
95
+ aliquota: number;
96
+ valorITBI: number;
97
+ dataAprovacao?: string;
97
98
  }
98
- interface ZoneamentoResult {
99
- zona?: string;
100
- zona_descricao?: string;
101
- coeficiente_aproveitamento_basico?: number;
102
- coeficiente_aproveitamento_maximo?: number;
103
- taxa_ocupacao_maxima?: number;
104
- gabarito_maximo?: number;
99
+ interface ITBICalculo {
100
+ sql: string;
101
+ valorTransacao: number;
102
+ valorVenalReferencia: number;
103
+ baseCalculo: number;
104
+ aliquota: number;
105
+ valorITBI: number;
106
+ isencaoAplicavel: boolean;
107
+ fundamentacaoLegal: string;
105
108
  }
106
- interface ValuationParams {
107
- area_terreno: number;
108
- area_construida: number;
109
- bairro: string;
110
- zona: string;
111
- tipo_uso: string;
112
- tipo_padrao: string;
113
- ano_construcao?: number;
114
- cidade?: Cidade;
115
- }
116
- interface ValuationResult {
117
- valor_estimado: number;
118
- valor_minimo?: number;
119
- valor_maximo?: number;
120
- confianca?: number;
121
- metodo?: string;
122
- comparaveis_utilizados?: number;
123
- data_avaliacao?: string;
124
- }
125
- interface BatchValuationResult {
126
- resultados: ValuationResult[];
127
- total_processados: number;
128
- total_erros: number;
129
- erros?: Array<{
130
- index: number;
131
- error: string;
132
- }>;
109
+ interface ITBICalculoParams {
110
+ sql: string;
111
+ valorTransacao: number;
112
+ cidade?: string;
133
113
  }
134
- declare class IPTUAPIError extends Error {
135
- readonly statusCode?: number;
136
- readonly requestId?: string;
137
- readonly responseBody?: Record<string, unknown>;
138
- constructor(message: string, statusCode?: number, requestId?: string, responseBody?: Record<string, unknown>);
139
- get isRetryable(): boolean;
114
+ interface ITBIHistorico {
115
+ protocolo: string;
116
+ dataTransacao: string;
117
+ tipoTransacao: string;
118
+ valorTransacao: number;
119
+ valorITBI: number;
140
120
  }
141
- declare class AuthenticationError extends IPTUAPIError {
142
- constructor(message?: string, requestId?: string, responseBody?: Record<string, unknown>);
121
+ interface ITBIAliquota {
122
+ cidade: string;
123
+ aliquotaPadrao: number;
124
+ aliquotaFinanciamentoSFH: number;
125
+ valorMinimoIsencao: number;
126
+ baseLegal: string;
127
+ vigencia: string;
143
128
  }
144
- declare class ForbiddenError extends IPTUAPIError {
145
- readonly requiredPlan?: string;
146
- constructor(message?: string, requiredPlan?: string, requestId?: string, responseBody?: Record<string, unknown>);
129
+ interface ITBIIsencao {
130
+ tipo: string;
131
+ descricao: string;
132
+ requisitos: string[];
133
+ baseLegal: string;
147
134
  }
148
- declare class NotFoundError extends IPTUAPIError {
149
- constructor(message?: string, requestId?: string, responseBody?: Record<string, unknown>);
135
+ interface Pessoa {
136
+ nome: string;
137
+ documento: string;
138
+ email?: string;
150
139
  }
151
- declare class RateLimitError extends IPTUAPIError {
152
- readonly retryAfter?: number;
153
- readonly limit?: number;
154
- readonly remaining?: number;
155
- constructor(message?: string, retryAfter?: number, limit?: number, remaining?: number, requestId?: string, responseBody?: Record<string, unknown>);
156
- get isRetryable(): boolean;
140
+ interface ITBIGuiaParams {
141
+ sql: string;
142
+ valorTransacao: number;
143
+ comprador: Pessoa;
144
+ vendedor: Pessoa;
145
+ cidade?: string;
157
146
  }
158
- declare class ValidationError extends IPTUAPIError {
159
- readonly errors?: Array<{
160
- field: string;
161
- message: string;
162
- }>;
163
- constructor(message?: string, errors?: Array<{
164
- field: string;
165
- message: string;
166
- }>, requestId?: string, responseBody?: Record<string, unknown>);
147
+ interface ITBIGuia {
148
+ protocolo: string;
149
+ codigoBarras: string;
150
+ linhaDigitavel: string;
151
+ dataEmissao: string;
152
+ dataVencimento: string;
153
+ valorITBI: number;
167
154
  }
168
- declare class ServerError extends IPTUAPIError {
169
- constructor(message?: string, statusCode?: number, requestId?: string, responseBody?: Record<string, unknown>);
170
- get isRetryable(): boolean;
155
+ interface ITBIValidacao {
156
+ protocolo: string;
157
+ valido: boolean;
158
+ pago: boolean;
159
+ dataPagamento?: string;
160
+ valorPago?: number;
171
161
  }
172
- declare class TimeoutError extends IPTUAPIError {
173
- readonly timeoutMs?: number;
174
- constructor(message?: string, timeoutMs?: number);
175
- get isRetryable(): boolean;
162
+ interface ITBISimularParams {
163
+ valorTransacao: number;
164
+ cidade?: string;
165
+ tipoFinanciamento?: 'sfh' | 'nao_sfh';
166
+ valorFinanciado?: number;
176
167
  }
177
- declare class NetworkError extends IPTUAPIError {
178
- readonly originalError?: Error;
179
- constructor(message?: string, originalError?: Error);
180
- get isRetryable(): boolean;
168
+ interface ITBISimulacao {
169
+ valorTransacao: number;
170
+ valorFinanciado: number;
171
+ valorNaoFinanciado: number;
172
+ aliquotaSFH: number;
173
+ aliquotaPadrao: number;
174
+ valorITBIFinanciado: number;
175
+ valorITBINaoFinanciado: number;
176
+ valorITBITotal: number;
177
+ economiaSFH: number;
181
178
  }
182
- interface Logger {
183
- debug?(message: string, ...args: unknown[]): void;
184
- info?(message: string, ...args: unknown[]): void;
185
- warn?(message: string, ...args: unknown[]): void;
186
- error?(message: string, ...args: unknown[]): void;
179
+ interface EvaluateParams {
180
+ /** Numero SQL do imovel (alternativa ao endereco) */
181
+ sql?: string;
182
+ /** Nome da rua/avenida (alternativa ao SQL) */
183
+ logradouro?: string;
184
+ /** Numero do imovel */
185
+ numero?: number;
186
+ /** Apartamento, sala, etc. */
187
+ complemento?: string;
188
+ /** Bairro */
189
+ bairro?: string;
190
+ /** Codigo da cidade (sp, bh) */
191
+ cidade?: string;
192
+ /** Incluir estimativa baseada em ITBI */
193
+ incluirItbi?: boolean;
194
+ /** Incluir lista de imoveis comparaveis */
195
+ incluirComparaveis?: boolean;
187
196
  }
188
- interface RetryConfig {
189
- /** Maximum number of retry attempts (default: 3) */
190
- maxRetries: number;
191
- /** Initial delay in ms between retries (default: 500) */
192
- initialDelay: number;
193
- /** Maximum delay in ms between retries (default: 10000) */
194
- maxDelay: number;
195
- /** Backoff factor (default: 2) */
196
- backoffFactor: number;
197
- /** Status codes that trigger retry (default: [429, 500, 502, 503, 504]) */
198
- retryableStatuses: number[];
197
+ interface AVMEstimate {
198
+ /** Valor estimado em R$ */
199
+ valorEstimado: number;
200
+ /** Valor minimo do intervalo */
201
+ valorMinimo: number;
202
+ /** Valor maximo do intervalo */
203
+ valorMaximo: number;
204
+ /** Valor por m2 */
205
+ valorM2: number;
206
+ /** Nivel de confianca (0-1) */
207
+ confianca: number;
208
+ /** Versao do modelo */
209
+ modeloVersao: string;
199
210
  }
200
- interface IPTUClientOptions {
201
- /** Base URL for the API (default: https://iptuapi.com.br/api/v1) */
202
- baseUrl?: string;
203
- /** Request timeout in milliseconds (default: 30000) */
204
- timeout?: number;
205
- /** Retry configuration */
206
- retry?: Partial<RetryConfig>;
207
- /** Logger instance for debugging */
208
- logger?: Logger;
209
- /** Enable request logging (default: false) */
210
- logRequests?: boolean;
211
- /** Enable response logging (default: false) */
212
- logResponses?: boolean;
213
- /** Custom User-Agent header */
214
- userAgent?: string;
211
+ interface ITBIMarketEstimate {
212
+ /** Valor estimado em R$ */
213
+ valorEstimado: number;
214
+ /** Valor minimo da faixa */
215
+ faixaMinima: number;
216
+ /** Valor maximo da faixa */
217
+ faixaMaxima: number;
218
+ /** Valor por m2 (mediana) */
219
+ valorM2Mediana: number;
220
+ /** Total de transacoes analisadas */
221
+ totalTransacoes: number;
222
+ /** Periodo considerado */
223
+ periodo: string;
224
+ /** Fonte dos dados */
225
+ fonte: string;
226
+ }
227
+ interface FinalValuation {
228
+ /** Valor estimado final */
229
+ estimado: number;
230
+ /** Valor minimo */
231
+ minimo: number;
232
+ /** Valor maximo */
233
+ maximo: number;
234
+ /** Metodo utilizado (blend_avm_itbi, avm_only, itbi_only) */
235
+ metodo: string;
236
+ /** Peso do AVM no calculo (0-1) */
237
+ pesoAvm: number;
238
+ /** Peso do ITBI no calculo (0-1) */
239
+ pesoItbi: number;
240
+ /** Nivel de confianca */
241
+ confianca: number;
242
+ /** Nota explicativa */
243
+ nota?: string;
215
244
  }
245
+ interface PropertyEvaluation {
246
+ /** Se a avaliacao foi bem sucedida */
247
+ success: boolean;
248
+ /** Dados cadastrais do imovel */
249
+ imovel: Record<string, unknown>;
250
+ /** Avaliacao pelo modelo ML (AVM) */
251
+ avaliacaoAvm?: AVMEstimate;
252
+ /** Avaliacao por transacoes ITBI reais */
253
+ avaliacaoItbi?: ITBIMarketEstimate;
254
+ /** Valor final combinado */
255
+ valorFinal: FinalValuation;
256
+ /** Imoveis comparaveis */
257
+ comparaveis?: Record<string, unknown>;
258
+ /** Metadados da avaliacao */
259
+ metadata: {
260
+ processadoEm: string;
261
+ fontes: string[];
262
+ cidade: string;
263
+ };
264
+ }
265
+ type Cidade = 'sp' | 'bh' | 'recife' | 'poa' | 'fortaleza' | 'curitiba' | 'rj' | 'brasilia';
266
+
267
+ /**
268
+ * Cliente principal para a IPTU API.
269
+ */
270
+
271
+ /**
272
+ * Cliente para interagir com a IPTU API.
273
+ */
216
274
  declare class IPTUClient {
217
275
  private readonly apiKey;
218
- private readonly baseUrl;
219
- private readonly timeout;
220
- private readonly retryConfig;
221
- private readonly logger?;
222
- private readonly logRequests;
223
- private readonly logResponses;
224
- private readonly userAgent;
225
- private _rateLimit?;
226
- private _lastRequestId?;
227
- constructor(apiKey: string, options?: IPTUClientOptions);
228
- /** Rate limit info from last request */
229
- get rateLimit(): RateLimitInfo | undefined;
230
- /** Request ID from last request (useful for support) */
231
- get lastRequestId(): string | undefined;
232
- private log;
276
+ private readonly config;
277
+ private _rateLimitInfo;
278
+ private _lastRequestId;
279
+ /**
280
+ * Cria uma nova instancia do cliente.
281
+ *
282
+ * @param apiKey - Chave de API para autenticacao
283
+ * @param options - Opcoes de configuracao
284
+ */
285
+ constructor(apiKey: string, options?: ClientOptions);
286
+ /**
287
+ * Retorna informacoes do rate limit da ultima requisicao.
288
+ */
289
+ get rateLimitInfo(): RateLimitInfo | null;
290
+ /**
291
+ * Retorna o ID da ultima requisicao.
292
+ */
293
+ get lastRequestId(): string | null;
294
+ /**
295
+ * Executa uma requisicao HTTP com retry.
296
+ */
297
+ private makeRequest;
298
+ /**
299
+ * Atualiza informacoes de rate limit a partir dos headers.
300
+ */
301
+ private updateRateLimitInfo;
302
+ /**
303
+ * Converte resposta HTTP em excecao apropriada.
304
+ */
305
+ private handleError;
306
+ /**
307
+ * Aguarda um tempo em milissegundos.
308
+ */
233
309
  private sleep;
234
- private calculateDelay;
235
- private extractRateLimit;
236
- private handleErrorResponse;
237
- private request;
238
310
  /**
239
- * Busca dados de IPTU por endereço.
311
+ * Consulta imoveis por endereco.
240
312
  *
241
- * @param params - Parâmetros da consulta
242
- * @returns Dados do imóvel encontrado
243
- * @throws {NotFoundError} Se o imóvel não for encontrado
244
- * @throws {ValidationError} Se os parâmetros forem inválidos
245
- * @throws {AuthenticationError} Se a API Key for inválida
246
- * @throws {RateLimitError} Se exceder o limite de requisições
313
+ * @param logradouro - Nome da rua/avenida
314
+ * @param numero - Numero do imovel
315
+ * @param cidade - Codigo da cidade (sp, bh, recife)
316
+ * @returns Lista de imoveis encontrados
247
317
  */
248
- consultaEndereco(params: ConsultaEnderecoParams): Promise<ConsultaEnderecoResult>;
249
- consultaEndereco(logradouro: string, numero?: string, cidade?: Cidade): Promise<ConsultaEnderecoResult>;
318
+ consultaEndereco(logradouro: string, numero: string, cidade?: Cidade): Promise<Imovel[]>;
250
319
  /**
251
- * Busca dados de IPTU por número SQL (contribuinte).
320
+ * Consulta imovel por numero SQL/Indice Cadastral.
321
+ * Requer plano Starter ou superior.
252
322
  *
253
- * @param sql - Número SQL do imóvel
254
- * @param cidade - Cidade da consulta
255
- * @param options - Opções adicionais
256
- * @returns Dados completos do imóvel
323
+ * @param sql - Numero SQL (SP), Indice Cadastral (BH) ou Sequencial (Recife)
324
+ * @param cidade - Codigo da cidade (sp, bh, recife)
325
+ * @returns Lista de imoveis encontrados
257
326
  */
258
- consultaSQL(sql: string, cidade?: Cidade, options?: {
259
- incluirHistorico?: boolean;
260
- incluirComparaveis?: boolean;
261
- }): Promise<ConsultaSQLResult>;
327
+ consultaSQL(sql: string, cidade?: Cidade): Promise<Imovel[]>;
262
328
  /**
263
- * Busca imóveis por CEP.
329
+ * Consulta imoveis por CEP.
264
330
  *
265
- * @param cep - CEP do imóvel
266
- * @param cidade - Cidade da consulta
267
- * @returns Lista de imóveis no CEP
331
+ * @param cep - CEP do endereco
332
+ * @param cidade - Codigo da cidade (sp, bh, recife)
333
+ * @returns Lista de imoveis encontrados
268
334
  */
269
- consultaCEP(cep: string, cidade?: Cidade): Promise<ConsultaEnderecoResult[]>;
335
+ consultaCEP(cep: string, cidade?: Cidade): Promise<Imovel[]>;
270
336
  /**
271
337
  * Consulta zoneamento por coordenadas.
272
338
  *
273
339
  * @param latitude - Latitude do ponto
274
340
  * @param longitude - Longitude do ponto
275
- * @returns Dados de zoneamento
341
+ * @returns Informacoes de zoneamento
342
+ */
343
+ consultaZoneamento(latitude: number, longitude: number): Promise<Zoneamento>;
344
+ /**
345
+ * Calcula estimativa de valor de mercado.
346
+ * Requer plano Pro ou superior.
347
+ *
348
+ * @param params - Parametros da avaliacao
349
+ * @returns Avaliacao de mercado
350
+ */
351
+ valuationEstimate(params: ValuationParams): Promise<Valuation>;
352
+ /**
353
+ * Busca imoveis comparaveis.
354
+ * Requer plano Pro ou superior.
355
+ *
356
+ * @param params - Parametros da busca
357
+ * @returns Lista de imoveis comparaveis
276
358
  */
277
- consultaZoneamento(latitude: number, longitude: number): Promise<ZoneamentoResult>;
359
+ valuationComparables(params: ComparablesParams): Promise<Comparavel[]>;
278
360
  /**
279
- * Estima o valor de mercado do imóvel usando ML.
280
- * Disponível apenas para planos Pro e Enterprise.
361
+ * Avalia imovel por endereco OU SQL.
362
+ * Combina dados do modelo AVM (ML) com transacoes ITBI reais.
363
+ * Requer plano Pro ou superior.
281
364
  *
282
- * @param params - Parâmetros do imóvel
283
- * @returns Estimativa de valor
284
- * @throws {ForbiddenError} Se o plano não permitir
365
+ * @param params - Parametros da avaliacao (sql OU logradouro+numero)
366
+ * @returns Avaliacao completa do imovel
285
367
  */
286
- valuationEstimate(params: ValuationParams): Promise<ValuationResult>;
368
+ valuationEvaluate(params: EvaluateParams): Promise<PropertyEvaluation>;
287
369
  /**
288
- * Valuation em lote (até 100 imóveis).
289
- * Disponível apenas para plano Enterprise.
370
+ * Consulta status de transacao ITBI.
290
371
  *
291
- * @param imoveis - Lista de imóveis para avaliar
292
- * @returns Resultados de valuation para cada imóvel
372
+ * @param protocolo - Numero do protocolo ITBI
373
+ * @param cidade - Codigo da cidade (sp, bh, recife)
374
+ * @returns Status da transacao
293
375
  */
294
- valuationBatch(imoveis: ValuationParams[]): Promise<BatchValuationResult>;
376
+ itbiStatus(protocolo: string, cidade?: Cidade): Promise<ITBIStatus>;
295
377
  /**
296
- * Busca imóveis comparáveis para análise.
378
+ * Calcula valor do ITBI.
297
379
  *
298
- * @param bairro - Nome do bairro
299
- * @param areaMin - Área mínima em m²
300
- * @param areaMax - Área máxima em m²
301
- * @param options - Opções adicionais
302
- * @returns Lista de imóveis comparáveis
380
+ * @param params - Parametros do calculo
381
+ * @returns Calculo do ITBI
303
382
  */
304
- valuationComparables(bairro: string, areaMin: number, areaMax: number, options?: {
305
- tipoUso?: string;
306
- cidade?: Cidade;
307
- limit?: number;
308
- }): Promise<ComparavelItem[]>;
383
+ itbiCalcular(params: ITBICalculoParams): Promise<ITBICalculo>;
309
384
  /**
310
- * Histórico de valores IPTU de um imóvel.
385
+ * Consulta historico de transacoes ITBI de um imovel.
386
+ * Requer plano Starter ou superior.
311
387
  *
312
- * @param sql - Número SQL do imóvel
313
- * @param cidade - Cidade da consulta
314
- * @returns Lista com histórico anual
388
+ * @param sql - Numero SQL do imovel
389
+ * @param cidade - Codigo da cidade (sp, bh, recife)
390
+ * @returns Lista de transacoes historicas
315
391
  */
316
- dadosIPTUHistorico(sql: string, cidade?: Cidade): Promise<HistoricoItem[]>;
392
+ itbiHistorico(sql: string, cidade?: Cidade): Promise<ITBIHistorico[]>;
317
393
  /**
318
- * Consulta dados de empresa por CNPJ.
394
+ * Consulta aliquotas ITBI vigentes.
319
395
  *
320
- * @param cnpj - CNPJ da empresa
321
- * @returns Dados cadastrais
396
+ * @param cidade - Codigo da cidade (sp, bh, recife)
397
+ * @returns Aliquotas vigentes
322
398
  */
323
- dadosCNPJ(cnpj: string): Promise<Record<string, unknown>>;
399
+ itbiAliquotas(cidade?: Cidade): Promise<ITBIAliquota>;
324
400
  /**
325
- * Correção monetária pelo IPCA.
401
+ * Consulta isencoes ITBI disponiveis.
326
402
  *
327
- * @param valor - Valor a corrigir
328
- * @param dataOrigem - Data do valor original (YYYY-MM)
329
- * @param dataDestino - Data destino (default: atual)
330
- * @returns Valor corrigido e fator de correção
403
+ * @param cidade - Codigo da cidade (sp, bh, recife)
404
+ * @returns Lista de isencoes disponiveis
331
405
  */
332
- dadosIPCACorrigir(valor: number, dataOrigem: string, dataDestino?: string): Promise<{
333
- valor_corrigido: number;
334
- fator: number;
335
- }>;
406
+ itbiIsencoes(cidade?: Cidade): Promise<ITBIIsencao[]>;
407
+ /**
408
+ * Gera guia de pagamento ITBI.
409
+ * Requer plano Starter ou superior.
410
+ *
411
+ * @param params - Parametros da guia
412
+ * @returns Guia de pagamento gerada
413
+ */
414
+ itbiGuia(params: ITBIGuiaParams): Promise<ITBIGuia>;
415
+ /**
416
+ * Valida autenticidade de uma guia ITBI.
417
+ *
418
+ * @param protocolo - Numero do protocolo da guia
419
+ * @param cidade - Codigo da cidade (sp, bh, recife)
420
+ * @returns Resultado da validacao
421
+ */
422
+ itbiValidarGuia(protocolo: string, cidade?: Cidade): Promise<ITBIValidacao>;
423
+ /**
424
+ * Simula calculo de ITBI.
425
+ *
426
+ * @param params - Parametros da simulacao
427
+ * @returns Resultado da simulacao
428
+ */
429
+ itbiSimular(params: ITBISimularParams): Promise<ITBISimulacao>;
430
+ }
431
+
432
+ /**
433
+ * Excecoes customizadas para a IPTU API.
434
+ */
435
+ interface ErrorDetails {
436
+ error: string;
437
+ message: string;
438
+ statusCode?: number;
439
+ requestId?: string;
440
+ retryable: boolean;
441
+ [key: string]: unknown;
442
+ }
443
+ /**
444
+ * Excecao base para todos os erros da IPTU API.
445
+ */
446
+ declare class IPTUAPIError extends Error {
447
+ readonly statusCode?: number;
448
+ readonly requestId?: string;
449
+ readonly responseData: Record<string, unknown>;
450
+ constructor(message: string, statusCode?: number, requestId?: string, responseData?: Record<string, unknown>);
451
+ isRetryable(): boolean;
452
+ toJSON(): ErrorDetails;
453
+ }
454
+ /**
455
+ * Erro de autenticacao (401). API Key invalida ou ausente.
456
+ */
457
+ declare class AuthenticationError extends IPTUAPIError {
458
+ constructor(message?: string, requestId?: string);
459
+ }
460
+ /**
461
+ * Erro de autorizacao (403). Plano nao permite acesso ao recurso.
462
+ */
463
+ declare class ForbiddenError extends IPTUAPIError {
464
+ readonly requiredPlan?: string;
465
+ constructor(message?: string, requiredPlan?: string, requestId?: string);
466
+ toJSON(): ErrorDetails;
467
+ }
468
+ /**
469
+ * Erro de recurso nao encontrado (404).
470
+ */
471
+ declare class NotFoundError extends IPTUAPIError {
472
+ readonly resource?: string;
473
+ constructor(message?: string, resource?: string, requestId?: string);
474
+ toJSON(): ErrorDetails;
475
+ }
476
+ /**
477
+ * Erro de rate limit excedido (429).
478
+ */
479
+ declare class RateLimitError extends IPTUAPIError {
480
+ readonly retryAfter: number;
481
+ constructor(message?: string, retryAfter?: number, requestId?: string);
482
+ isRetryable(): boolean;
483
+ toJSON(): ErrorDetails;
484
+ }
485
+ /**
486
+ * Erro de validacao de parametros (400, 422).
487
+ */
488
+ declare class ValidationError extends IPTUAPIError {
489
+ readonly errors: Record<string, string[]>;
490
+ constructor(message?: string, errors?: Record<string, string[]>, statusCode?: number, requestId?: string);
491
+ toJSON(): ErrorDetails;
492
+ }
493
+ /**
494
+ * Erro interno do servidor (5xx). Retryable.
495
+ */
496
+ declare class ServerError extends IPTUAPIError {
497
+ constructor(message?: string, statusCode?: number, requestId?: string);
498
+ isRetryable(): boolean;
499
+ }
500
+ /**
501
+ * Erro de timeout na requisicao.
502
+ */
503
+ declare class TimeoutError extends IPTUAPIError {
504
+ readonly timeoutSeconds?: number;
505
+ constructor(message?: string, timeoutSeconds?: number, requestId?: string);
506
+ isRetryable(): boolean;
507
+ toJSON(): ErrorDetails;
508
+ }
509
+ /**
510
+ * Erro de conexao de rede.
511
+ */
512
+ declare class NetworkError extends IPTUAPIError {
513
+ readonly originalError?: Error;
514
+ constructor(message?: string, originalError?: Error);
515
+ isRetryable(): boolean;
336
516
  }
337
517
 
338
- export { AuthenticationError, type BatchValuationResult, type Cidade, CidadeEnum, type ComparavelItem, type ConsultaEnderecoParams, type ConsultaEnderecoResult, type ConsultaSQLResult, ForbiddenError, type HistoricoItem, IPTUAPIError, IPTUClient, type IPTUClientOptions, type Logger, NetworkError, NotFoundError, RateLimitError, type RateLimitInfo, type RetryConfig, ServerError, TimeoutError, ValidationError, type ValuationParams, type ValuationResult, type ZoneamentoResult, IPTUClient as default };
518
+ export { type AVMEstimate, AuthenticationError, type Cidade, type ClientConfig, type ClientOptions, type ComparablesParams, type Comparavel, type EvaluateParams, type FinalValuation, ForbiddenError, IPTUAPIError, IPTUClient, type ITBIAliquota, type ITBICalculo, type ITBICalculoParams, type ITBIGuia, type ITBIGuiaParams, type ITBIHistorico, type ITBIIsencao, type ITBIMarketEstimate, type ITBISimulacao, type ITBISimularParams, type ITBIStatus, type ITBIValidacao, type Imovel, NetworkError, NotFoundError, type Pessoa, type PropertyEvaluation, RateLimitError, type RateLimitInfo, type RetryConfig, ServerError, TimeoutError, ValidationError, type Valuation, type ValuationParams, type Zoneamento };