Simple Flow

Commonly used, simple CAS Parser API flow

Architecture: CAS Parsing

This guide covers integration patterns for parsing CAS statements via the CAS Parser API.

User Flow

┌─────────────────────────────────────────────────────────────────────────────┐
│                                                                             │
│   User Journey                                                              │
│                                                                             │
│   ┌─────────────┐     ┌─────────────┐     ┌─────────────┐     ┌─────────┐  │
│   │             │     │             │     │             │     │         │  │
│   │  User has   │────►│  Uploads    │────►│  Enters     │────►│ Views   │  │
│   │  CAS PDF    │     │  PDF file   │     │  password   │     │ data    │  │
│   │             │     │             │     │             │     │         │  │
│   └─────────────┘     └─────────────┘     └─────────────┘     └─────────┘  │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Data flow:

┌──────────┐          ┌──────────┐          ┌─────────────┐
│  User    │          │ Your App │          │ CAS Parser  │
└────┬─────┘          └────┬─────┘          └──────┬──────┘
     │                     │                       │
     │  Uploads PDF        │                       │
     │  + enters password  │                       │
     │────────────────────►│                       │
     │                     │                       │
     │                     │  PDF + Password       │
     │                     │──────────────────────►│
     │                     │                       │
     │                     │                       │ Detect type
     │                     │                       │ Decrypt
     │                     │                       │ Extract
     │                     │                       │ Transform
     │                     │                       │
     │                     │  Structured JSON      │
     │                     │◄──────────────────────│
     │                     │                       │
     │  Portfolio view     │                       │
     │◄────────────────────│                       │
     │                     │                       │

The API auto-detects the CAS type (CDSL, NSDL, CAMS, or KFintech) and returns a unified JSON response.

Integration Patterns

Pattern A: Server-Side Integration

Your backend calls the CAS Parser API directly.

┌────────────────┐     ┌────────────────┐     ┌────────────────────┐
│                │     │                │     │                    │
│  Your Backend  │────►│  CAS Parser    │────►│   Your Storage     │
│                │     │     API        │     │                    │
└────────────────┘     └────────────────┘     └────────────────────┘
import requests

def parse_cas(pdf_url: str, password: str) -> dict:
    response = requests.post(
        "https://portfolio-parser.api.casparser.in/v4/smart/parse",
        headers={"x-api-key": API_KEY},
        json={"pdf_url": pdf_url, "password": password}
    )
    return response.json()

Pattern B: Frontend Upload with Backend Proxy

User uploads directly in the browser; your backend proxies to CAS Parser.

┌──────────┐     ┌──────────────┐     ┌─────────────┐
│          │     │              │     │             │
│ Browser  │────►│ Your Backend │────►│ CAS Parser  │
│          │     │   (Proxy)    │     │    API      │
└──────────┘     └──────────────┘     └─────────────┘
// Frontend
const formData = new FormData();
formData.append('file', pdfFile);
formData.append('password', password);

await fetch('/api/parse-cas', { method: 'POST', body: formData });
# Backend
@app.route('/api/parse-cas', methods=['POST'])
def parse_cas():
    file = request.files['file']
    password = request.form['password']
    pdf_url = upload_to_storage(file)
    
    return requests.post(
        "https://portfolio-parser.api.casparser.in/v4/smart/parse",
        headers={"x-api-key": API_KEY},
        json={"pdf_url": pdf_url, "password": password}
    ).json()

Pattern C: Portfolio Connect SDK

Pre-built UI widget for consumer apps. See SDK documentation →

┌──────────┐     ┌──────────────┐     ┌─────────────────┐
│          │     │              │     │                 │
│ Browser  │────►│ Your Backend │────►│ Access Token    │
│          │     │              │     │ API             │
└────┬─────┘     └──────────────┘     └─────────────────┘
     │                                        │
     │  ◄─────────────────────────────────────┘
     │     Access token (at_xxx)


┌─────────────────────────────────────────────┐
│        Portfolio Connect Widget              │
│  ┌─────────────────────────────────────┐    │
│  │  Drop your CAS PDF here             │    │
│  │  Password: ••••••••                 │    │
│  │  [Parse Statement]                  │    │
│  └─────────────────────────────────────┘    │
└─────────────────────────────────────────────┘
import { PortfolioConnect } from '@cas-parser/connect';

<PortfolioConnect
  accessToken={accessToken}
  onSuccess={(data) => savePortfolio(data)}
/>

Access tokens are short-lived credentials generated from your API key. They allow frontend usage without exposing the API key.

Supported Statements

Source

Coverage

CDSL

Equities, ETFs, Bonds, Demat MFs, AIFs, etc

NSDL

Equities, ETFs, Bonds, NPS, Insurance, AIFs, Demat MFs etc

CAMS

Mutual Funds (all AMCs serviced by CAMS, KFintech)

KFintech

Mutual Funds (all AMCs serviced by CAMS, KFintech)

API Documentation

Full endpoint documentation, request/response schemas, and sandbox access:

docs.casparser.in/reference →

  • CAS Generator — Request CAS when user doesn't have the PDF

  • Email Import — Import CAS from user's email inbox without manual imports