Overview
The Fundamental Data API retrieves comprehensive financial statements, quarterly results, and key financial ratios for stocks. This endpoint processes ISINs from the master map and returns balance sheets, P&L statements, and ratio analysis. Source File:fetch_fundamental_data.py
Endpoint Details
https://open-web-scanx.dhan.co/scanx/fundamentalPOSTapplication/jsonRequest Headers
Request Payload
Array of ISIN codes (up to 100 per request for optimal performance)
Batch Processing
The implementation uses batching for efficiency:Example Request
Response Structure
API response status - “success” or error message
Array of fundamental data objects for each ISIN
Data Object Fields
ISIN code of the security
Trading symbol (enriched from master_isin_map.json)
Company display name (enriched from master_isin_map.json)
Quarterly financial results
Financial ratios including P/E, P/B, ROE, ROCE, Debt/Equity, etc.
Balance sheet items
P&L statement items
Cash flow statement items
Example Response
Implementation Details
Configuration
Number of ISINs processed per API request
Request timeout in seconds
Delay between batches in seconds to avoid rate limiting
master_isin_map.json - Generated by Dhan ScanX APIfundamental_data.json (~35 MB for full market)Processing Flow
- Load Master Map: Read ISINs from
master_isin_map.json - Create Batches: Split ~2,775 ISINs into batches of 100
- API Requests: Send POST requests for each batch
- Enrich Data: Add Symbol and Name from master map
- Consolidate: Merge all batch results
- Save Output: Write to
fundamental_data.json
Code Example
Error Handling
The API returns different status codes:- 200: Success - data returned in response
- 400: Bad request - invalid ISIN format
- 500: Server error - retry with exponential backoff
- Timeout: Request exceeded 30 seconds
Retry Logic
Performance Metrics
- Total ISINs: ~2,775 (entire NSE equity market)
- Total Batches: ~28 (at 100 per batch)
- Total Time: ~15-20 seconds (with 0.5s delay)
- Output Size: ~35 MB
- Success Rate: >99% for valid ISINs
Output File Structure
Thefundamental_data.json file contains an array of enriched fundamental data objects:
Use Cases
- Fundamental Screening: Filter stocks by financial ratios
- Quarterly Results Analysis: Track revenue and profit growth
- Financial Health Check: Analyze debt ratios and cash flows
- Valuation Models: Use P/E, P/B for relative valuation
- Earnings Tracking: Monitor EPS trends across quarters
Dependencies
Required Files:master_isin_map.json(generated by Dhan ScanX API)
- Earnings performance processors
- Advanced metrics calculators
- Stock screening tools
Notes
- Some ISINs may not have fundamental data available (newly listed stocks, delisted stocks)
- Quarterly results are updated within 24-48 hours of official filing
- Historical data availability varies by company (typically 5-10 years)
- TTM (Trailing Twelve Months) metrics are automatically calculated
- The API is rate-limited - use batch processing with delays as shown in implementation