Haystack Pipelines for Brazil CVM Filings
Building Haystack CVM filings pipelines? Treat apicvm as an HTTP tool/fetcher: resolve → list → download/extract, then index markdown or PDFs in Haystack. This is not a managed Haystack connector.
The problem
Retrieval stacks that cite Brazilian filings need:
- Stable document UUIDs for citations
- Filters by ticker, type (
DFP/ITR/FRE), and year - Page-level text without scraping the CVM portal
Haystack handles retrieval; apicvm handles regulatory file access.
Tool sketch (Python)
import os, requests
BASE = os.environ["APICVM_URL"]
H = {"Authorization": f"Bearer {os.environ['APICVM_KEY']}"}
def list_filings(ticker: str, doc_type: str = "FRE", year: int = 2024) -> list[dict]:
r = requests.get(
f"{BASE}/v1/documents",
headers=H,
params={"ticker": ticker, "type": doc_type, "year": year, "perPage": 20},
timeout=60,
)
r.raise_for_status()
return r.json()["data"]
Wire list_filings as a custom Haystack component or tool that returns {id, name, type} rows for downstream fetchers.
RAG path
- List documents for the coverage universe
- Download PDFs with
GET /v1/documents/:id/fileor request async page markdown viaPOST /v1/document-text-extractions - Index chunks with metadata
{ticker, type, year, document_id}
See also LangChain and LlamaIndex.
Current limitations
- Extraction is async via HTTPS callback (Pro); no sync markdown endpoint
- Student keys cannot run text extraction (
403) - Corpus gaps produce empty lists — not always "wrong ticker"
Next steps
Ready to integrate?
Get an API key and start querying Brazilian CVM filings programmatically.