StockTrendz API
REST API for Indian market data, portfolio sync, and AI-powered pattern analysis. All endpoints return JSON. Protected routes require a JWT Bearer token obtained via /api/auth/login.
JWT Bearer Tokens
Obtain an access_token by calling POST /api/auth/login. Include it in every protected request:
Tokens are also accepted as a cookie named access_token_cookie if you prefer cookie-based auth.
Create a new user account. Returns a JWT access token on success.
| Field | Type | Description |
|---|---|---|
| email* | string | Valid email address |
| password* | string | Min 8 characters |
| nameopt | string | Display name |
access_tokenAuthenticate and receive a JWT access token valid for 7 days.
| Field | Type | Description |
|---|---|---|
| email* | string | Registered email |
| password* | string | Account password |
access_token + user infoReturns live index prices, market status, sector heatmap, and top trading signals. Served from a shared L1/L2 cache — typically responds in <2 ms. No auth required.
| Field | Type | Description |
|---|---|---|
| nifty_price | number | NIFTY 50 last price |
| nifty_change | number | NIFTY % change from prev close |
| banknifty_price | number | BANK NIFTY last price |
| sensex_price | number | BSE SENSEX last price |
| signals | array | Top pattern signals (symbol, pattern, confidence) |
| sectors | array | Sector % changes |
| market.is_open | boolean | True if NSE is currently trading |
| market.as_of_ist | string | Timestamp of data in IST |
Returns live last-traded prices for up to 50 symbols. Falls back to Yahoo Finance when Zerodha is unavailable. No auth required.
| Param | Type | Description |
|---|---|---|
| symbols* | string | Comma-separated instrument IDs, e.g. NSE:TCS,NSE:INFY |
api_key, api_secret, tokens) are used in-memory only and are never written to the database, logs, or disk.
Syncs holdings and positions from Zerodha via KiteConnect. Credentials used in-memory only.
| Field | Type | Description |
|---|---|---|
| api_key* | string | Your Zerodha KiteConnect API key |
| api_secret* | string | Your KiteConnect API secret |
| request_token* | string | One-time token from Zerodha OAuth redirect |
holdings_count, net_positions_countSyncs holdings and positions from ICICI Direct via the Breeze Connect API. Credentials used in-memory only.
api_session: visit https://api.icicidirect.com/apiuser/login?api_key=YOUR_KEY, log in, and copy the api_session value from the redirect URL.
| Field | Type | Description |
|---|---|---|
| api_key* | string | Your ICICI Breeze API key |
| api_secret* | string | Your Breeze API secret |
| api_session* | string | One-time session code from ICICI portal redirect |
holdings_count, positions_countReturns the user's last-synced holdings with P&L figures. Sync first via /api/portfolio/sync or /api/portfolio/icici-sync.
Returns open positions. Optional ?type=day or ?type=net to filter.
P&L summary with up to 365-day trend. Optional ?days=30 (max 365).
| Query Param | Type | Description |
|---|---|---|
| daysopt | integer | Number of days for trend data (default 30, max 365) |
Permanently deletes all stored holdings, positions, and P&L snapshots for the authenticated user. Does not affect Trade Journal entries. Irreversible.
Returns the validity and expiry of the server's shared Zerodha access token. Safe to call publicly.
Returns validity of the server's shared ICICI Breeze token.
Admin-only. Activates the server's shared ICICI Breeze session using a fresh api_session code. Requires ICICI_ADMIN_SECRET if configured.
| Field | Type | Description |
|---|---|---|
| api_session* | string | Session code from ICICI portal redirect URL |
| secretopt | string | Admin secret (ICICI_ADMIN_SECRET) |
Returns database connectivity, L1/L2 cache stats, and warmer status. No auth required.