Authentication
Obtain JWT Token
Endpoint: POST /token/
Description: Obtain a JWT token using email and password.
Request:
Headers:
- Content-Type: application/json
Body:
{ "email": "user@example.com", "password": "yourpassword" }
Response:
200 OK:
{ "access": "your_access_token", "refresh": "your_refresh_token" }
401 Unauthorized: Invalid credentials
Order Placement API
Place an Order
Endpoint: POST /place_order/
Description: Place an order for a specific instrument.
Request:
Headers:
- Authorization: Bearer <access_token>
- Content-Type: application/json
Body:
{ "instrument": "instrument_key", "price": 100.5, "quantity": 10, "order_type": "BUY", "product_type": "Intraday", "type": "Market", "stoploss": 0, // Optional, default is 0 "target": 0 // Optional, default is 0 }
Instrument Keys: Download
Response:
200 OK:
{ "message": "Order placed successfully" }
400 Bad Request: Market closed, invalid parameters, or order rejected
{ "error": "Order Rejected" }
404 Not Found: Instrument not found
{ "error": "Instrument not found" }
405 Method Not Allowed: Invalid request method
{ "error": "Method not allowed" }
Position API
Get Positions
Endpoint: GET /positions/
Description: Retrieve the Intraday positions for the logged-in user
Request:
Headers:
- Authorization: Bearer <access_token>
- Content-Type: application/json
Response:
200 OK:
[ { "quantity": 10, "last_traded_quantity": 5, "symbol": "ABC123", "instrument_key": "XYZ789", "lot_size": 1, "segment": "NSE", "token": 123456, "product": "Intraday", "buy_price": 100.0, "sell_price": 105.0, "created_at": "2024-07-31T12:34:56Z", "realised_pnl": 50.0, "unrealised_pnl": 10.0, "is_holding": true, "is_closed": false, "last_traded_datetime": "2024-07-31T12:34:56Z" } ]
401 Unauthorized: Invalid or missing token
Holdings API
Get Holdings
Endpoint: GET /holdings/
Description: Retrieve the holdings for the logged-in user
Request:
Headers:
- Authorization: Bearer <access_token>
- Content-Type: application/json
Response:
200 OK:
[ { "quantity": 10, "last_traded_quantity": 5, "symbol": "ABC123", "instrument_key": "XYZ789", "lot_size": 1, "segment": "NSE", "token": 123456, "product": "Intraday", "buy_price": 100.0, "sell_price": 105.0, "created_at": "2024-07-31T12:34:56Z", "realised_pnl": 50.0, "unrealised_pnl": 10.0, "is_holding": true, "is_closed": false, "last_traded_datetime": "2024-07-31T12:34:56Z" } ]
401 Unauthorized: Invalid or missing token