API Documentation

Complete reference for all endpoints. Use these APIs from ChatGPT, Postman, curl, or any HTTP client. Base URL: https://localhost:7050

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
ParameterTypeRequiredDefaultDescription
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
curl -k "https://localhost:7050/api/candles?symbol=JUBLFOOD-EQ&timeInterval=1&token=18096"
Example: Get NIFTY 50 index 5-min candles
curl -k "https://localhost:7050/api/candles?symbol=NIFTY&timeInterval=5&token=26000"
Example: Get SENSEX 15-min candles
curl -k "https://localhost:7050/api/candles?symbol=SENSEX&timeInterval=15&token=26001"
Example: Get candles for specific date range
curl -k "https://localhost:7050/api/candles?symbol=RELIANCE-EQ&timeInterval=1&token=2885&from=2026-10-08&to=2026-10-09"
Example: Get ORIRAIL candles
curl -k "https://localhost:7050/api/candles?symbol=orirail-EQ&timeInterval=1&token=764818"
Response Format
{ "status": true, "data": [ { "time": 1728456300000, "open": 425.50, "high": 426.10, "low": 425.00, "close": 425.80, "volume": 12450 }, { "time": 1728456360000, "open": 425.80, "high": 426.50, "low": 425.60, "close": 426.20, "volume": 8320 } ] }
Response Fields
statusbooleanWhether the API call succeeded
dataarrayArray of candle objects, sorted by time ascending
data[].timelongUnix timestamp in milliseconds (divide by 1000 for seconds)
data[].opennumberOpening price of the candle
data[].highnumberHighest price during the candle interval
data[].lownumberLowest price during the candle interval
data[].closenumberClosing price of the candle
data[].volumenumberNumber of shares traded during the candle interval
How to derive LTP (Last Traded Price): The 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.
Important: Only intraday intervals (1, 3, 5, 15, 30, 60 minutes) work. Daily, Weekly, Monthly intervals return empty {"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
curl -k "https://localhost:7050/api/investments"
Response
[ { "id": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4", "symbol": "JUBLFOOD", "token": "18096", "qty": 45, "price": 460.05, "date": "2026-09-30", "addedAt": "2026-09-30T00:00:00Z" }, { "id": "b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5", "symbol": "JUBLFOOD", "token": "18096", "qty": 3, "price": 426.00, "date": "2026-10-08", "addedAt": "2026-10-08T00:00:00Z" }, { "id": "c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6", "symbol": "ORIRAIL", "token": "764818", "qty": 40, "price": 125.00, "date": "2026-09-30", "addedAt": "2026-09-30T00:00:00Z" } ]
Response Fields
idstringUnique ID (32 hex chars, auto-generated)
symbolstringStock symbol (e.g., JUBLFOOD, ORIRAIL)
tokenstringNSE token for the stock
qtyintegerNumber of shares purchased in this lot
pricedecimalPurchase price per share
datestringPurchase date (YYYY-MM-DD)
addedAtstringWhen the entry was added (ISO 8601)
Note: Same stock can have multiple entries (different lots/purchases). Group by 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)
FieldTypeRequiredDescription
symbolstringRequiredStock symbol (e.g., "JUBLFOOD", "RELIANCE")
tokenstringRequiredNSE token for the stock
qtyintegerRequiredNumber of shares (must be > 0)
pricedecimalRequiredPurchase price per share (must be > 0)
datestringRequiredPurchase date (YYYY-MM-DD)
Example: Add 10 shares of RELIANCE at ₹2850
curl -k -X POST "https://localhost:7050/api/investments" \ -H "Content-Type: application/json" \ -d '{ "symbol": "RELIANCE", "token": "2885", "qty": 10, "price": 2850.00, "date": "2026-10-09" }'
Example: Add JUBLFOOD shares
curl -k -X POST "https://localhost:7050/api/investments" \ -H "Content-Type: application/json" \ -d '{"symbol":"JUBLFOOD","token":"18096","qty":5,"price":430.00,"date":"2026-10-09"}'
Response (Created investment with auto-generated ID)
{ "id": "f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2", "symbol": "RELIANCE", "token": "2885", "qty": 10, "price": 2850.00, "date": "2026-10-09", "addedAt": "2026-10-09T10:30:00.0000000Z" }
Validation: Returns 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
curl -k -X DELETE "https://localhost:7050/api/investments/a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
Response
{ "success": true }
Returns 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
curl -k -X DELETE "https://localhost:7050/api/investments/symbol/JUBLFOOD"
Response
{ "success": true }
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 NameSymbol (for API)TokenExample curl
Nifty 50 IndexNIFTY26000
Sensex IndexSENSEX26001
Reliance IndustriesRELIANCE-EQ2885
TCSTCS-EQ11536
HDFC BankHDFCBANK-EQ1333
InfosysINFY-EQ1594
Jubilant FoodWorksJUBLFOOD-EQ18096
SBISBIN-EQ3045
Tata MotorsTATAMOTORS-EQ3456
ITCITC-EQ1660
Orient Rail (ORIRAIL)orirail-EQ764818
How to find token for any stock: Open the stock chart on 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:

ChatGPT Prompt — Copy & Paste This
I have a local stock price API running at https://localhost:7050. Here's how to use it: ## Get Live Stock Candle Data GET https://localhost:7050/api/candles?symbol={SYMBOL}-EQ&timeInterval={INTERVAL}&token={TOKEN} Parameters: - symbol: Stock symbol with -EQ suffix (e.g., JUBLFOOD-EQ, RELIANCE-EQ). For indices use NIFTY or SENSEX (no suffix). - token: NSE token ID (unique per stock). Common tokens: - NIFTY 50: token=26000, symbol=NIFTY - SENSEX: token=26001, symbol=SENSEX - RELIANCE: token=2885 - TCS: token=11536 - HDFCBANK: token=1333 - INFY: token=1594 - JUBLFOOD: token=18096 - SBIN: token=3045 - TATAMOTORS: token=3456 - ITC: token=1660 - ORIRAIL: token=764818 - timeInterval: 1, 3, 5, 15, 30, or 60 (minutes). Default: 1. Daily/Weekly don't work. - from: Optional date filter (YYYY-MM-DD) - to: Optional date filter (YYYY-MM-DD) Response: { "status": true, "data": [ { "time": 1728456300000, "open": 425.50, "high": 426.10, "low": 425.00, "close": 425.80, "volume": 12450 }, ... ] } - time is Unix ms. Last candle's close = current LTP. Volume in shares. ## Get My Portfolio GET https://localhost:7050/api/investments Returns: [{ "id": "...", "symbol": "JUBLFOOD", "token": "18096", "qty": 45, "price": 460.05, "date": "2026-09-30" }, ...] ## Add Investment POST https://localhost:7050/api/investments Body: { "symbol": "RELIANCE", "token": "2885", "qty": 10, "price": 2850, "date": "2026-10-09" } ## Delete Investment DELETE https://localhost:7050/api/investments/{id} DELETE https://localhost:7050/api/investments/symbol/{symbol} (deletes ALL lots of that stock) ## How to calculate P&L: 1. Get investments from GET /api/investments 2. For each unique symbol, get live price from GET /api/candles (last candle's close) 3. P&L = (currentPrice - purchasePrice) * qty 4. For multiple lots of same stock, calculate each lot separately then sum Please use these APIs to answer my stock-related questions. Always show data in Indian Rupees (₹).
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.

Limitation: ChatGPT can only access your API if your app is running AND accessible. If running on 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, OR
3. Copy the curl commands, run them yourself, and paste the output into ChatGPT for analysis.
Data Format & Response Schema
Candle Data Schema
{ "status": boolean, // true if data fetched successfully "data": [ // array of OHLCV candle objects { "time": number, // Unix timestamp in MILLISECONDS "open": number, // Opening price (₹) "high": number, // Highest price in interval (₹) "low": number, // Lowest price in interval (₹) "close": number, // Closing price (₹) "volume": number // Shares traded in interval } ] } // Derived values from candle data: // LTP (Last Traded Price) = data[last].close // Day Open = data[first_today].open // Day High = max(all today's candles' high) // Day Low = min(all today's candles' low) // Day Volume = sum(all today's candles' volume) // Prev Close = last candle of previous day's close // VWAP = sum((H+L+C)/3 * volume) / sum(volume)
Investment Schema
{ "id": "string", // 32-char hex, auto-generated "symbol": "string", // Stock symbol (uppercase) "token": "string", // NSE token ID "qty": number, // Shares purchased (integer) "price": number, // Purchase price per share (₹) "date": "string", // Purchase date "YYYY-MM-DD" "addedAt": "string" // ISO 8601 timestamp when added } // P&L Calculation: // unrealizedPL = (currentPrice - purchasePrice) * qty // returnPct = (currentPrice - purchasePrice) / purchasePrice * 100 // For multiple lots: totalInvested = sum(qty * price), totalValue = sum(qty * currentPrice)
Error Handling
HTTP StatusMeaningWhen
200 OKSuccessData returned successfully
200 with {"data":[]}No dataMarket closed, wrong token, or invalid interval (D/W/M)
400 Bad RequestInvalid inputPOST /api/investments with empty symbol, qty ≤ 0, or price ≤ 0
404 Not FoundNot foundDELETE /api/investments/{id} with non-existent ID
500 Internal Server ErrorServer errorNSE 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.

Quick Copy — All API Endpoints
# === CANDLE DATA === # Get 1-min candles for a stock GET https://localhost:7050/api/candles?symbol=JUBLFOOD-EQ&timeInterval=1&token=18096 # Get 5-min candles for Nifty 50 GET https://localhost:7050/api/candles?symbol=NIFTY&timeInterval=5&token=26000 # Get 15-min candles for Sensex GET https://localhost:7050/api/candles?symbol=SENSEX&timeInterval=15&token=26001 # Get candles with date range GET https://localhost:7050/api/candles?symbol=RELIANCE-EQ&timeInterval=1&token=2885&from=2026-10-08&to=2026-10-09 # === INVESTMENTS === # Get all investments GET https://localhost:7050/api/investments # Add new investment POST https://localhost:7050/api/investments Content-Type: application/json {"symbol":"RELIANCE","token":"2885","qty":10,"price":2850,"date":"2026-10-09"} # Delete investment by ID DELETE https://localhost:7050/api/investments/{id} # Delete all lots of a stock DELETE https://localhost:7050/api/investments/symbol/JUBLFOOD