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

  1. List documents for the coverage universe
  2. Download PDFs with GET /v1/documents/:id/file or request async page markdown via POST /v1/document-text-extractions
  3. 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.