Access Brazil CVM Filings with C#

Need a C# CVM filings API client for Brazilian public companies? apicvm is plain HTTPS JSON. Use HttpClient, a Bearer token, and the /v1/* routes — there is no official .NET SDK.

The problem

.NET services often hit the same friction as other backends:

  • Scrapers that break when the CVM portal UI changes
  • Local ZIP parsers without stable document UUIDs
  • One-off scripts that never become a shared library

A small HTTP wrapper against a fixed contract is easier to keep in ASP.NET Core, worker services, or Azure Functions.

Setup

export APICVM_URL='https://apicvm.dev'
export APICVM_KEY='apicvm_...'   # from /signup

.NET 6+ is enough. The examples below use HttpClient and System.Text.Json.

Resolve a ticker

using System.Net.Http.Headers;
using System.Text.Json;
using System.Web;

var baseUrl = Environment.GetEnvironmentVariable("APICVM_URL")!;
var key = Environment.GetEnvironmentVariable("APICVM_KEY")!;

using var http = new HttpClient { BaseAddress = new Uri(baseUrl) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", key);

var q = HttpUtility.UrlEncode("PETR4");
var json = await http.GetStringAsync($"/v1/companies/resolve?query={q}&by=ticker");
using var doc = JsonDocument.Parse(json);
Console.WriteLine(doc.RootElement.ToString());

List DFP documents

var listUrl = "/v1/documents?ticker=PETR4&type=DFP&year=2024&perPage=20";
var listJson = await http.GetStringAsync(listUrl);
using var list = JsonDocument.Parse(listJson);

foreach (var row in list.RootElement.GetProperty("data").EnumerateArray())
{
    Console.WriteLine($"{row.GetProperty("id")} {row.GetProperty("name")}");
}

perPage max is 50. Paginate with page until meta.lastPage. See Paginate and filter CVM documents.

Download a PDF

var docId = "..."; // UUID from list response
var bytes = await http.GetByteArrayAsync($"/v1/documents/{docId}/file");
await File.WriteAllBytesAsync("petr4-dfp.pdf", bytes);

File download does not consume extraction credits.

curl cross-check

curl -H "Authorization: Bearer $APICVM_KEY" \
  "$APICVM_URL/v1/companies/resolve?query=PETR4&by=ticker"

Same contract as Java, Go, and curl.

Errors and rate limits

Map status codes in your exception hierarchy: 401 auth, 404 missing document, 429 rate limit. Read X-RateLimit-Remaining when fan-out across tickers. Details: Handle errors and rate limits.

Current limitations

  • Text extraction (POST /v1/document-text-extractions) is async via HTTPS callback — not a sync Task return value.
  • Student keys cannot extract markdown (403).
  • perPage max is 50.
  • Corpus coverage depends on ingestion lag; resolve before hard-coding CNPJ.

Next steps

Ready to integrate?

Get an API key and start querying Brazilian CVM filings programmatically.