Documentation Index
Fetch the complete documentation index at: https://mintlify.com/georgejohnsonoff-business/spendwiselygeorge/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Portfolio API provides real-time valuation of your mutual fund holdings by fetching current NAV (Net Asset Value) data from MFApi and calculating total portfolio value.Get Portfolio
Calculates current portfolio value based on stored holdings and live NAV data
How It Works
Example Request
Response
Array of holdings with current valuations
Total portfolio value across all holdings (rounded to 2 decimal places)
Portfolio Item Fields
AMFI scheme code for the mutual fund
Full name of the mutual fund scheme
Number of units held
Current Net Asset Value per unit
Total value of this holding (units × NAV, rounded to 2 decimals)
Example Response
Empty Portfolio
When no holdings are configured:NAV Data Source
The API fetches NAV data from MFApi, a public API for Indian mutual funds:Endpoint Format
Example MFApi Response
The API always uses the most recent NAV (first item in the
data array).Calculation Logic
For each holding:Example Calculation
Error Handling
Failed NAV Fetch
If NAV data cannot be fetched for a fund:- Error is logged to console:
"Error fetching {code}: {error}" - Fund is excluded from portfolio response
- Total value calculation continues with remaining funds
Common Failure Scenarios
| Scenario | Behavior |
|---|---|
| Invalid scheme code | Fund skipped, error logged |
| MFApi network error | Fund skipped, error logged |
| MFApi returns empty data | Fund skipped, error logged |
| Missing scheme_name | Fund skipped, error logged |
Example with Partial Failure
If holdings.json contains:Data Dependencies
Holdings File
Portfolio calculation requires holdings in./holdings.json:
Create holdings using the POST /api/holdings endpoint.
Network Requirements
- Internet connection required to fetch NAV data
- Access to api.mfapi.in must be allowed
- No authentication required for MFApi
Performance Considerations
API Calls
The endpoint makes one MFApi request per holding:- 5 holdings = 5 API calls
- 10 holdings = 10 API calls
Caching Recommendations
For production deployments, consider:- Caching NAV data for 15-30 minutes
- Implementing batch NAV fetching
- Pre-calculating portfolio values
Use Cases
Dashboard Display
Performance Tracking
Compare current value against purchase value to calculate returns:Finding Scheme Codes
Use MFApi to search for scheme codes:Refer to MFApi documentation for complete scheme listings.
Next Steps
Manage Holdings
Add or update your mutual fund holdings
View Transactions
Track your transaction history