consultar_transacoes_cartoes
Query quarterly payment card transaction data from Brazil's Central Bank to analyze transaction volumes and values by specific time periods.
Instructions
Consulta estoque e transações de cartões de pagamento por trimestre. Retorna dados sobre quantidade e valor das transações realizadas com cartões.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trimestre | Yes | Ano e trimestre no formato YYYYQ (exemplo: '20234') | |
| top | No | Número máximo de registros a retornar (padrão: 100) | |
| ordenar_por | No | Campo para ordenação (exemplo: 'Trimestre desc') | |
| filtro | No | Filtro OData para refinar a consulta |
Implementation Reference
- src/index.ts:325-348 (handler)Handler for the 'consultar_transacoes_cartoes' tool. Extracts parameters from the request, calls fetchBCBData to query the BCB API for card transactions by trimester, and returns the JSON-formatted data.case "consultar_transacoes_cartoes": { const { trimestre, top = 100, ordenar_por, filtro } = args as { trimestre: string; top?: number; ordenar_por?: string; filtro?: string; }; const data = await fetchBCBData(`Quantidadeetransacoesdecartoes(trimestre=@trimestre)?@trimestre='${trimestre}'`, { formato: "json", top, orderby: ordenar_por, filter: filtro, }); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/index.ts:123-143 (schema)Input schema defining the parameters for the 'consultar_transacoes_cartoes' tool, including required 'trimestre' and optional pagination, ordering, and filtering.inputSchema: { type: "object", properties: { trimestre: { type: "string", description: "Ano e trimestre no formato YYYYQ (exemplo: '20234')", }, top: { type: "number", description: "Número máximo de registros a retornar (padrão: 100)", }, ordenar_por: { type: "string", description: "Campo para ordenação (exemplo: 'Trimestre desc')", }, filtro: { type: "string", description: "Filtro OData para refinar a consulta", }, }, required: ["trimestre"],
- src/index.ts:120-144 (registration)Tool registration in the tools array, including name, description, and schema, used by the ListToolsRequest handler.{ name: "consultar_transacoes_cartoes", description: "Consulta estoque e transações de cartões de pagamento por trimestre. Retorna dados sobre quantidade e valor das transações realizadas com cartões.", inputSchema: { type: "object", properties: { trimestre: { type: "string", description: "Ano e trimestre no formato YYYYQ (exemplo: '20234')", }, top: { type: "number", description: "Número máximo de registros a retornar (padrão: 100)", }, ordenar_por: { type: "string", description: "Campo para ordenação (exemplo: 'Trimestre desc')", }, filtro: { type: "string", description: "Filtro OData para refinar a consulta", }, }, required: ["trimestre"], },
- src/index.ts:37-52 (helper)Helper function that performs the actual API call to the BCB Olinda service, building the URL with OData parameters and handling errors.async function fetchBCBData(endpoint: string, params: QueryParams = {}) { try { const url = buildUrl(endpoint, params); const response = await axios.get(url, { headers: { "Accept": "application/json" } }); return response.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Erro ao consultar API do BCB: ${error.message}`); } throw error; } }