API Documentation
Complete reference for all endpoints. Use these APIs from ChatGPT, Postman, curl, or any HTTP client. Base URL: https://localhost:7050
Table of Contents
GET /api/candles — Stock Candle Data
Fetches live OHLCV (Open, High, Low, Close, Volume) candle data for any stock or index listed on NSE India. Data is proxied from NSE's charting API through the backend to avoid CORS issues.
GET https://localhost:7050/api/candles?symbol=JUBLFOOD-EQ&timeInterval=1&token=18096
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| symbol | string | Required | — | Stock symbol with suffix. For equities: SYMBOL-EQ (e.g., JUBLFOOD-EQ, RELIANCE-EQ). For indices: NIFTY or SENSEX (no suffix). |
| token | string | Required | 0 |
NSE token ID for the stock/index. Each stock has a unique numeric token. See Tokens Reference below. |
| timeInterval | string | Optional | 1 |
Candle interval in minutes. Valid values: 1, 3, 5, 15, 30, 60. Daily/Weekly/Monthly do NOT work on NSE charting API. |
| from | string | Optional | — | Start date filter (ISO format: 2026-10-01). If omitted, returns all available data from NSE. |
| to | string | Optional | — | End date filter (ISO format: 2026-10-09). If omitted, defaults to current time. |
Example: Get JUBLFOOD 1-min candles
Example: Get NIFTY 50 index 5-min candles
Example: Get SENSEX 15-min candles
Example: Get candles for specific date range
Example: Get ORIRAIL candles
Response Format
Response Fields
close of the last candle in the array is the most recent price. The open of the first candle is the day's opening price. Math.max(...data.map(d => d.high)) gives the day high.
{"data":[]}. The API returns data for the last ~5 trading sessions.
GET /api/investments — Get All Investments
Returns all investments (portfolio holdings) stored in the JSON file. Each entry represents a single purchase lot.
GET https://localhost:7050/api/investments
Example
Response
Response Fields
symbol to aggregate. To get current P&L, fetch live price from /api/candles and compare with purchase price.
POST /api/investments — Add Investment
Adds a new investment/purchase lot to the portfolio. The ID is auto-generated. Symbol is auto-uppercased.
POST https://localhost:7050/api/investments
Request Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
| symbol | string | Required | Stock symbol (e.g., "JUBLFOOD", "RELIANCE") |
| token | string | Required | NSE token for the stock |
| qty | integer | Required | Number of shares (must be > 0) |
| price | decimal | Required | Purchase price per share (must be > 0) |
| date | string | Required | Purchase date (YYYY-MM-DD) |
Example: Add 10 shares of RELIANCE at ₹2850
Example: Add JUBLFOOD shares
Response (Created investment with auto-generated ID)
400 Bad Request if symbol is empty, qty ≤ 0, or price ≤ 0.
DELETE /api/investments/{id} — Delete by ID
Deletes a single investment lot by its unique ID.
DELETE https://localhost:7050/api/investments/{id}
Example
Response
404 Not Found if no investment with that ID exists.DELETE /api/investments/symbol/{symbol} — Delete All Lots of a Stock
Deletes ALL investment lots for a given stock symbol. Use with caution — this removes every purchase entry for that stock.
DELETE https://localhost:7050/api/investments/symbol/JUBLFOOD
Example
Response
Stock Tokens Reference
Each stock/index on NSE has a unique numeric token. You need both the symbol and token to fetch candle data. For equities, append -EQ to the symbol when calling /api/candles.
| Stock Name | Symbol (for API) | Token | Example curl |
|---|---|---|---|
| Nifty 50 Index | NIFTY | 26000 | |
| Sensex Index | SENSEX | 26001 | |
| Reliance Industries | RELIANCE-EQ | 2885 | |
| TCS | TCS-EQ | 11536 | |
| HDFC Bank | HDFCBANK-EQ | 1333 | |
| Infosys | INFY-EQ | 1594 | |
| Jubilant FoodWorks | JUBLFOOD-EQ | 18096 | |
| SBI | SBIN-EQ | 3045 | |
| Tata Motors | TATAMOTORS-EQ | 3456 | |
| ITC | ITC-EQ | 1660 | |
| Orient Rail (ORIRAIL) | orirail-EQ | 764818 |
nseindia.com, inspect the network tab in DevTools, and look for the symbolHistoricalData request — the token parameter is in the URL.
Pages & Routes
All the front-end pages available in this application:
- / — DashboardSearch any stock by symbol & token, view candlestick chart, price stats
- /Home/Nifty50 — Nifty 50 LiveLive Nifty 50 index chart (token: 26000)
- /Home/Sensex — Sensex LiveLive Sensex index chart (token: 26001)
- /Home/Comparator — Stock ComparatorCompare any stock vs Nifty/Sensex with correlation, beta, impact analysis
- /Home/MyInvestments — My InvestmentsPortfolio tracker with live P&L, add/delete holdings
- /Home/Analysis?symbol=X&token=Y — AnalysisDeep technical analysis with RSI, MACD, signals, predictions
- /Home/Documentation — API DocsThis page
How ChatGPT Can Use These APIs
If you want ChatGPT (or any AI assistant) to fetch live stock data from this app, give it these instructions. Copy the prompt below and paste it into ChatGPT:
Step-by-Step: How ChatGPT Uses It
Step 1: Copy the prompt above and paste it into ChatGPT (use GPT-4 with browsing/code interpreter enabled).
Step 2: Ask ChatGPT something like: "What's the current price of JUBLFOOD?"
Step 3: ChatGPT will call GET /api/candles?symbol=JUBLFOOD-EQ&timeInterval=1&token=18096, read the last candle's close price, and tell you.
Step 4: Ask: "Show me my portfolio P&L" — it will call GET /api/investments, then fetch live prices for each stock, and calculate profit/loss.
Step 5: Ask: "Add 20 shares of TCS at ₹3500 bought on 2026-10-09" — it will POST to /api/investments.
localhost, ChatGPT cannot reach it directly. You would need to either:1. Deploy the app to a public server, OR
2. Use a tunnel like
ngrok (ngrok http 7050) to expose it temporarily, OR3. Copy the curl commands, run them yourself, and paste the output into ChatGPT for analysis.
Data Format & Response Schema
Candle Data Schema
Investment Schema
Error Handling
| HTTP Status | Meaning | When |
|---|---|---|
200 OK | Success | Data returned successfully |
200 with {"data":[]} | No data | Market closed, wrong token, or invalid interval (D/W/M) |
400 Bad Request | Invalid input | POST /api/investments with empty symbol, qty ≤ 0, or price ≤ 0 |
404 Not Found | Not found | DELETE /api/investments/{id} with non-existent ID |
500 Internal Server Error | Server error | NSE API unreachable, timeout, or unexpected error. Response: {"error":"message"} |
Common Issues & Solutions
Empty data array: Check that you're using an intraday interval (1/3/5/15/30/60), not D/W/M. Also verify the token is correct.
SSL certificate error: Use -k flag with curl to skip certificate verification (dev environment).
Market hours: NSE trades 9:15 AM - 3:30 PM IST, Monday-Friday. Outside these hours, the last available data is returned.
Data is stale: The charting API returns ~5 days of intraday history. Older data is not available through this endpoint.