consultar_meios_pagamento_trimestral
Retrieve quarterly data on payment card operations and credit transfers from Brazil's Central Bank. Specify quarter in YYYYQ format to access transaction statistics.
Instructions
Consulta dados trimestrais sobre operações com cartões de pagamento e transferências de crédito. Use o formato YYYYQ para o parâmetro trimestre (exemplo: '20234' para o 4º trimestre de 2023).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trimestre | Yes | Ano e trimestre no formato YYYYQ (exemplo: '20234' para 4º trimestre de 2023) | |
| top | No | Número máximo de registros a retornar (padrão: 100) | |
| skip | No | Número de registros a pular para paginação | |
| filtro | No | Filtro OData para refinar a consulta |
Implementation Reference
- src/index.ts:300-323 (handler)Handler for 'consultar_meios_pagamento_trimestral' tool: extracts parameters from args, fetches data from BCB API endpoint 'MeiosdePagamentosTrimestralDA' using fetchBCBData helper, and returns the JSON response as text content.case "consultar_meios_pagamento_trimestral": { const { trimestre, top = 100, skip, filtro } = args as { trimestre: string; top?: number; skip?: number; filtro?: string; }; const data = await fetchBCBData(`MeiosdePagamentosTrimestralDA(trimestre=@trimestre)?@trimestre='${trimestre}'`, { formato: "json", top, skip, filter: filtro, }); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/index.ts:94-119 (schema)Tool definition including name, description, and input schema with required 'trimestre' parameter (YYYYQ format) and optional top, skip, filtro for pagination and filtering.{ name: "consultar_meios_pagamento_trimestral", description: "Consulta dados trimestrais sobre operações com cartões de pagamento e transferências de crédito. Use o formato YYYYQ para o parâmetro trimestre (exemplo: '20234' para o 4º trimestre de 2023).", inputSchema: { type: "object", properties: { trimestre: { type: "string", description: "Ano e trimestre no formato YYYYQ (exemplo: '20234' para 4º trimestre de 2023)", }, top: { type: "number", description: "Número máximo de registros a retornar (padrão: 100)", }, skip: { type: "number", description: "Número de registros a pular para paginação", }, filtro: { type: "string", description: "Filtro OData para refinar a consulta", }, }, required: ["trimestre"], }, },
- src/index.ts:37-52 (helper)Core helper function that makes HTTP requests to the BCB Olinda API, builds the URL with OData parameters, handles errors, and returns the data. Used by all tool handlers including this one.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; } }
- src/index.ts:24-34 (helper)Helper function to construct the full API URL with OData query parameters like $format, $top, $skip, $filter, $orderby from the input params.function buildUrl(endpoint: string, params: QueryParams = {}): string { const url = new URL(`${API_BASE_URL}/${endpoint}`); if (params.formato) url.searchParams.append("$format", params.formato); if (params.top) url.searchParams.append("$top", params.top.toString()); if (params.skip) url.searchParams.append("$skip", params.skip.toString()); if (params.filter) url.searchParams.append("$filter", params.filter); if (params.orderby) url.searchParams.append("$orderby", params.orderby); return url.toString(); }
- src/index.ts:263-267 (registration)Registration of tool list handler that returns the array of all tools, including 'consultar_meios_pagamento_trimestral', making it discoverable via ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools, }; });