### GET Request Example with Curl Source: https://groww.in/trade-api/docs/curl Demonstrates how to make a GET request to retrieve order details using curl. Includes required headers and query parameters. ```bash # You can also use wget curl -X GET https://api.groww.in/v1/order/detail/{groww_order_id}?segment=CASH \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -H 'X-API-VERSION: 1.0' ``` -------------------------------- ### Install Groww Python SDK Source: https://groww.in/trade-api/docs/python-sdk Install the Groww Python SDK using pip. This is the first step to using the API. ```bash pip install growwapi ``` -------------------------------- ### Install pyotp library Source: https://groww.in/trade-api/docs/python-sdk Install the pyotp library, which is required for the TOTP authentication flow. Use pip for installation. ```bash pip install pyotp ``` -------------------------------- ### API Response Example Source: https://groww.in/trade-api/docs/curl/backtesting This is an example of a successful response from the Get Contracts API, showing a list of available derivative contract symbols for the specified criteria. ```json { "status": "SUCCESS", "payload": { "contracts" : [ "NSE-NIFTY-02Jan25-28500-PE", "NSE-NIFTY-02Jan25-24000-PE", "NSE-NIFTY-02Jan25-26800-PE", "NSE-NIFTY-02Jan25-27450-PE", "NSE-NIFTY-02Jan25-19050-PE", "NSE-NIFTY-02Jan25-22300-PE", "NSE-NIFTY-02Jan25-28150-CE" ] } } ``` -------------------------------- ### API Response Example Source: https://groww.in/trade-api/docs/curl/margin This is an example of a successful response from the API, detailing the various margin components and total requirement for the order. ```json { "status": "SUCCESS", "payload": { "exposure_required": 1000, "span_required": 1000, "option_buy_premium": 140, "brokerage_and_charges": 15, "total_requirement": 2115, "cash_cnc_margin_required": 310, "cash_mis_margin_required": 800, "physical_delivery_margin_requirement": 100 } } ``` -------------------------------- ### Order List Response Example Source: https://groww.in/trade-api/docs/curl/orders This is an example of the JSON response received when fetching the order list. It includes details for each order such as status, quantities, prices, and timestamps. ```json { "status": "SUCCESS", "payload": { "order_list": [ { "groww_order_id": "GMK39038RDT490CCVRO", "trading_symbol": "WIPRO", "order_status": "OPEN", "remark": "Order placed successfully", "quantity": 100, "price": 2500, "trigger_price": 2450, "filled_quantity": 100, "remaining_quantity": 10, "average_fill_price": 2500, "deliverable_quantity": 10, "amo_status": "PENDING", "validity": "DAY", "exchange": "NSE", "order_type": "MARKET", "transaction_type": "BUY", "segment": "CASH", "product": "CNC", "created_at": "2023-10-01T10:15:30", "exchange_time": "2023-10-01T10:15:30", "trade_date": "2019-08-24T14:15:22Z", "order_reference_id": "Ab-654321234-1628190" } ] } } ``` -------------------------------- ### API GET Request Response Structure Source: https://groww.in/trade-api/docs/curl Example JSON response structure for a successful GET request, detailing order information. ```json { "status": "SUCCESS", "payload": { "groww_order_id": "GMK39038RDT490CCVRO", "trading_symbol": "RELIANCE-EQ", "order_status": "OPEN", "remark": "Order placed successfully", "quantity": 100, "price": 2500, "trigger_price": 2450, "filled_quantity": 100, "remaining_quantity": 10, "average_fill_price": 2500, "deliverable_quantity": 10, "amo_status": "PENDING", "validity": "DAY", "exchange": "NSE", "order_type": "MARKET", "transaction_type": "BUY", "segment": "CASH", "product": "CNC", "created_at": "2023-10-01T10:15:30", "exchange_time": "2023-10-01T10:15:30", "trade_date": "2019-08-24T14:15:22Z", "order_reference_id": "Ab-654321234-1628190" } } ``` -------------------------------- ### Response Example for Get Trade List for Order Source: https://groww.in/trade-api/docs/python-sdk/orders This is an example of the JSON response structure when fetching trade details for an order. It includes a list of trades, each with execution price, quantity, and other relevant identifiers. ```json { "trade_list": [ { "price": 250, "isin": "INE075A01022", "quantity": 1, "groww_order_id": "GMK39038RDT490CCVRO", "groww_trade_id": "", "exchange_trade_id": "202402120123456789", "exchange_order_id": "1100000057528630", "trade_status": "EXECUTED", "trading_symbol": "WIPRO", "remark": "Order placed successfully", "exchange": "NSE", "segment": "CASH", "product": "CNC", "transaction_type": "BUY", "created_at": "2019-08-24T14:15:22Z", "trade_date_time": "2019-08-24T14:15:22Z", "settlement_number": "2024052" } ] } ``` -------------------------------- ### Equity Order Update Response Example Source: https://groww.in/trade-api/docs/python-sdk/feed Example of the JSON response structure received for an equity order update. ```json { "qty": 3, "filledQty": 3, "avgFillPrice": "145", "growwOrderId": "GMK250502123553ZXM5BKVXX9LM", "exchangeOrderId": "1100000051248116", "orderStatus": "EXECUTED", "duration": "DAY", "exchange": "NSE", "contractId": "INE221H01019" } ``` -------------------------------- ### User Positions Response Example Source: https://groww.in/trade-api/docs/curl/portfolio This is an example of the JSON response structure you can expect when successfully retrieving user positions. It includes details for each held instrument. ```json { "status": "SUCCESS", "payload": { "positions": [ { "trading_symbol": "RELIANCE", "credit_quantity": 10, "credit_price": 12500, "debit_quantity": 5, "debit_price": 12000, "carry_forward_credit_quantity": 8, "carry_forward_credit_price": 12300, "carry_forward_debit_quantity": 3, "carry_forward_debit_price": 11800, "exchange": "NSE", "symbol_isin": "INE123A01016", "quantity": 15, "product": "CNC", "net_carry_forward_quantity": 10, "net_price": 12400, "net_carry_forward_price": 12200, "realised_pnl": 500 } ] } } ``` -------------------------------- ### Order Details Response Example Source: https://groww.in/trade-api/docs/curl/orders This is an example of the JSON response received when successfully fetching order details. It includes comprehensive information about the order's status, execution, and associated instrument. ```json { "status": "SUCCESS", "payload": { "groww_order_id": "GMK39038RDT490CCVRO", "trading_symbol": "WIPRO", "order_status": "OPEN", "remark": "Order placed successfully", "quantity": 100, "price": 2500, "trigger_price": 2450, "filled_quantity": 100, "remaining_quantity": 10, "average_fill_price": 2500, "deliverable_quantity": 10, "amo_status": "PENDING", "validity": "DAY", "exchange": "NSE", "order_type": "MARKET", "transaction_type": "BUY", "segment": "CASH", "product": "CNC", "created_at": "2023-10-01T10:15:30", "exchange_time": "2023-10-01T10:15:30", "trade_date": "2019-08-24T14:15:22Z", "order_reference_id": "Ab-654321234-1628190" } } ``` -------------------------------- ### Get Available User Margin Source: https://groww.in/trade-api/docs/curl/margin Retrieve your margin details using this API. This example uses curl and includes necessary headers for authentication and API versioning. ```shell curl -X GET https://api.groww.in/v1/margins/detail/user \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {ACCESS_TOKEN}' \ -H 'X-API-VERSION: 1.0' ``` -------------------------------- ### Derivatives Order Update Response Example Source: https://groww.in/trade-api/docs/python-sdk/feed Example of the JSON response structure received for a derivatives order update. ```json { "qty": 75, "price": "130", "filledQty": 75, "avgFillPrice": "110", "growwOrderId": "GMKFO250214150557M2HR6EJF2HSE", "exchangeOrderId": "1400000179694433", "orderStatus": "EXECUTED", "duration": "DAY", "exchange": "NSE", "segment": "FNO", "product": "NRML", "contractId": "NIFTY2522025400CE" } ``` -------------------------------- ### User Profile Response Example Source: https://groww.in/trade-api/docs/curl/user This is an example of the JSON response you will receive when successfully retrieving a user's profile. It includes user identifiers, trading enablement status for NSE and BSE, DDPI status, and active trading segments. ```json { "status": "SUCCESS", "payload": { "vendor_user_id": "d86890d1-c60d-4ebd-9730-4f451670", "ucc": "924189", "nse_enabled": true, "bse_enabled": true, "ddpi_enabled": false, "active_segments": [ "CASH", "FNO", "COMMODITY" ] } } ``` -------------------------------- ### Order Status Response Example Source: https://groww.in/trade-api/docs/curl/orders This is an example of a successful response when querying order status by Groww Order ID. It includes details like order status, filled quantity, and remarks. ```json { "status": "SUCCESS", "payload": { "groww_order_id": "GMK39038RDT490CCVRO", "order_status": "OPEN", "remark": "Order placed successfully", "filled_quantity": 100, "order_reference_id": "Ab-654321234-1628190" } } ``` -------------------------------- ### Market Depth Response Example Source: https://groww.in/trade-api/docs/python-sdk/feed This is an example of the JSON response structure for market depth data, showing buy and sell order books for specified instruments. ```json { "NSE": { "CASH": { "2885": { "tsInMillis": 1746156600.0, "buyBook": { "2": { "price": 1418.7, "qty": 23.0 }, "3": { "price": 1418.6, "qty": 206.0 }, "1": { "price": 1418.8, "qty": 113.0 }, "4": { "price": 1418.5, "qty": 774.0 }, "5": { "price": 1418.4, "qty": 1055.0 } }, "sellBook": { "2": { "price": 1419.0, "qty": 472.0 }, "3": { "price": 1419.3, "qty": 212.0 }, "1": { "price": 1418.9, "qty": 3.0 }, "4": { "price": 1419.4, "qty": 138.0 }, "5": { "price": 1419.5, "qty": 895.0 } } } }, "FNO": { "35241": { "tsInMillis": 1746156600.0, "buyBook": { "2": { "price": 1420.1, "qty": 30.0 }, "3": { "price": 1419.9, "qty": 190.0 }, "1": { "price": 1420.2, "qty": 120.0 }, "4": { "price": 1419.8, "qty": 800.0 }, "5": { "price": 1419.7, "qty": 1100.0 } }, "sellBook": { "2": { "price": 1420.5, "qty": 450.0 }, "3": { "price": 1420.8, "qty": 200.0 }, "1": { "price": 1420.4, "qty": 5.0 }, "4": { "price": 1421.0, "qty": 150.0 }, "5": { "price": 1421.2, "qty": 900.0 } } } } } } ``` -------------------------------- ### Smart Order Response Example Source: https://groww.in/trade-api/docs/python-sdk/smart-orders This is an example of the JSON response structure when listing smart orders. It includes details for each order such as ID, type, status, trading symbol, exchange, and quantity. ```json { "orders": [ { "smart_order_id": "gtt_91a7f4", "smart_order_type": "GTT", "status": "ACTIVE", "trading_symbol": "TCS", "exchange": "NSE", "quantity": 10 } ] } ``` -------------------------------- ### Example Metadata Callback Source: https://groww.in/trade-api/docs/python-sdk/feed This Python snippet shows how to receive and print metadata passed to a callback function when data is received from the Groww Feed. ```python def on_data_received(meta): print("Metadata received:") print(meta) # .... ``` -------------------------------- ### Derivatives Position Update Response Example Source: https://groww.in/trade-api/docs/python-sdk/feed Example of the JSON response received for derivatives position updates, detailing symbol ISIN and exchange-wise position quantities and prices. ```json { "symbolIsin": "NIFTY2550824800CE", "exchangePosition": { "BSE": {}, "NSE": { "creditQty": 300.0, "creditPrice": 3555.0, "debitQty": 75.0, "debitPrice": 5475.0 } } } ``` -------------------------------- ### Smart Order Response Example (GTT) Source: https://groww.in/trade-api/docs/python-sdk/smart-orders This is an example of the JSON response structure when retrieving details for a GTT smart order. It includes order specifics, trigger conditions, and status. ```json { "smart_order_id": "gtt_91a7f4", "smart_order_type": "GTT", "status": "ACTIVE", "trading_symbol": "TCS", "exchange": "NSE", "quantity": 10, "product_type": "CNC", "duration": "DAY", "order": { "order_type": "LIMIT", "price": "3990.00", "transaction_type": "BUY" }, "trigger_direction": "DOWN", "trigger_price": "3985.00", "segment": "CASH", "ltp": 4000.50, "remark": null, "display_name": "TCS Ltd", "child_legs": null, "is_cancellation_allowed": true, "is_modification_allowed": true, "created_at": "2025-09-30T07:00:00", "expire_at": "2026-09-30T07:00:00", "triggered_at": null, "updated_at": "2025-09-30T07:00:00" } ``` -------------------------------- ### Option Chain Response Payload Example Source: https://groww.in/trade-api/docs/python-sdk/live-data This is an example of the JSON response payload returned by the `get_option_chain` method. It includes the underlying's last traded price and detailed data for each strike price, including Call (CE) and Put (PE) options with their respective Greeks. ```json { "underlying_ltp": 25641.7, "strikes": { "23400": { "CE": { "greeks": { "delta": 0.9936, "gamma": 0, "theta": -1.0787, "vega": 0.6943, "rho": 5.1802, "iv": 25.3409 }, "trading_symbol": "NIFTY25N1823400CE", "ltp": 2200, "open_interest": 7, "volume": 5 }, "PE": { "greeks": { "delta": -0.0064, "gamma": 0, "theta": -1.0787, "vega": 0.6943, "rho": -0.0373, "iv": 25.3409 }, "trading_symbol": "NIFTY25N1823400PE", "ltp": 2.05, "open_interest": 7453, "volume": 9339 } }, "23450": { "CE": { "greeks": { "delta": 0.9927, "gamma": 0, "theta": -1.2027, "vega": 0.7774, "rho": 5.1862, "iv": 25.2306 }, "trading_symbol": "NIFTY25N1823450CE", "ltp": 2082.9, "open_interest": 4, "volume": 0 }, "PE": { "greeks": { "delta": -0.0073, "gamma": 0, "theta": -1.2027, "vega": 0.7774, "rho": -0.0424, "iv": 25.2306 }, "trading_symbol": "NIFTY25N1823450PE", "ltp": 2.35, "open_interest": 378, "volume": 74 } } } } ``` -------------------------------- ### Example Holdings Response Source: https://groww.in/trade-api/docs/curl/portfolio This is an example JSON response structure for the 'Get Holdings' API. It details the status of the request and the payload containing holding information. ```json { "status": "SUCCESS", "payload": { "holdings": [ { "isin": "INE545U01014", "trading_symbol": "RELIANCE", "quantity": 10, "average_price": 100, "pledge_quantity": 2, "demat_locked_quantity": 1, "groww_locked_quantity": 1.5, "repledge_quantity": 0.5, "t1_quantity": 3, "demat_free_quantity": 5, "corporate_action_additional_quantity": 1, "active_demat_transfer_quantity": 1 } ] } } ``` -------------------------------- ### POST Request Example with Curl Source: https://groww.in/trade-api/docs/curl Demonstrates how to make a POST request to create an order using curl. Includes required headers and JSON body. ```bash curl -X POST https://api.groww.in/v1/order/create \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {ACCESS_TOKEN}' \ -H 'X-API-VERSION: 1.0' \ -d '{ "validity": "DAY", "exchange": "NSE", "transaction_type": "BUY", "order_type": "MARKET", "price": 0, "product": "CNC", "quantity": 1, "segment": "CASH", "trading_symbol": "IDEA" }' ``` -------------------------------- ### Place a Limit Order using Python SDK Source: https://groww.in/trade-api/docs/python-sdk/orders Use the `place_order` method to register a new order. This example demonstrates placing a limit order for equities. Ensure your Groww API credentials are set up. ```python from growwapi import GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" # Initialize Groww API groww = GrowwAPI(API_AUTH_TOKEN) place_order_response = groww.place_order( trading_symbol="WIPRO", quantity=1, validity=groww.VALIDITY_DAY, exchange=groww.EXCHANGE_NSE, segment=groww.SEGMENT_CASH, product=groww.PRODUCT_CNC, order_type=groww.ORDER_TYPE_LIMIT, # You can also use ORDER_TYPE_MARKET, ORDER_TYPE_STOP_LOSS, ORDER_TYPE_STOP_LOSS_MARKET for different order types transaction_type=groww.TRANSACTION_TYPE_BUY, price=250, # Optional: Price of the stock (for Limit orders) trigger_price=245, # Optional: Trigger price (if applicable) order_reference_id="Ab-654321234-1628190" # Optional: User provided 8 to 20 length alphanumeric reference ID to track the order ) print(place_order_response) ``` -------------------------------- ### Subscribe to Live Data (Async and Sync) Source: https://groww.in/trade-api/docs/python-sdk/feed Demonstrates how to subscribe to live data for equities and derivatives using both asynchronous callbacks and synchronous polling. Requires Groww API credentials and instrument exchange tokens. ```python from growwapi import GrowwFeed, GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" groww = GrowwAPI(API_AUTH_TOKEN) feed = GrowwFeed(groww) def on_data_received(meta): # callback function which gets triggered when data is received print("Data received") print(feed.get_ltp()) # you can fetch exchange_token from instruments.csv file instruments_list = [{"exchange": "NSE", "segment": "CASH", "exchange_token": "2885"}, {"exchange": "NSE", "segment": "FNO", "exchange_token": "35241"}] feed.subscribe_ltp(instruments_list, on_data_received=on_data_received) # This is a blocking call. Nothing after this will run. feed.consume() # OR # you can also fetch data synchronously feed.subscribe_ltp(instruments_list) # live data can also be continuously polled using this method for i in range(10): time.sleep(3) print(feed.get_ltp()) feed.unsubscribe_ltp(instruments_list) ``` -------------------------------- ### Place a Buy Limit Order Source: https://groww.in/trade-api/docs/python-sdk Place your first order using the Groww API. This example demonstrates placing a buy limit order for Wipro on NSE. ```python from growwapi import GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" # Access token generated using step 3., # Initialize Groww API groww = GrowwAPI(API_AUTH_TOKEN) place_order_response = groww.place_order( trading_symbol="WIPRO", quantity=1, validity=groww.VALIDITY_DAY, exchange=groww.EXCHANGE_NSE, segment=groww.SEGMENT_CASH, product=groww.PRODUCT_CNC, order_type=groww.ORDER_TYPE_LIMIT, transaction_type=groww.TRANSACTION_TYPE_BUY, price=250, # Optional: Price of the stock (for Limit orders) trigger_price=245, # Optional: Trigger price (if applicable) order_reference_id="Ab-654321234-1628190" # Optional: User provided 8 to 20 length alphanumeric reference ID to track the order ) print(place_order_response) ``` -------------------------------- ### Fetch Live Data and Place Orders with Groww API Source: https://groww.in/trade-api/docs/python-sdk/instruments Initialize the GrowwAPI, select an instrument using its Groww symbol, and fetch its latest price data. Ensure your API credentials are valid. ```python import pandas as pd from growwapi import GrowwAPI # Initialize GrowwAPI and load instruments # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" # Initialize Groww API groww = GrowwAPI(API_AUTH_TOKEN) # Select an instrument (example: Reliance Industries) selected = groww.get_instrument_by_groww_symbol("NSE-RELIANCE") # Fetch latest price data for the selected instrument ltp_response = groww.get_ltp( exchange_trading_symbols="NSE_" + selected['trading_symbol'], segment=selected['segment'], ) print("Live Data:", ltp_response) ``` -------------------------------- ### Subscribe to Live Index Data with Callback Source: https://groww.in/trade-api/docs/python-sdk/feed Subscribe to live index data and process it using a callback function. Ensure your Groww API credentials are set up and the instruments list is correctly formatted. ```python from growwapi import GrowwFeed, GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" groww = GrowwAPI(API_AUTH_TOKEN) feed = GrowwFeed(groww) def on_data_received(meta): print("Data received") print(feed.get_index_value()) # you can fetch exchange_token from instruments.csv file instruments_list = [{"exchange": "NSE", "segment": "CASH", "exchange_token": "NIFTY"}, {"exchange": "BSE", "segment": "CASH", "exchange_token": "1"}] feed.subscribe_index_value(instruments_list, on_data_received=on_data_received) # This is a blocking call. Nothing after this will run. feed.consume() ``` -------------------------------- ### Get User Positions Request Source: https://groww.in/trade-api/docs/curl/portfolio Use this cURL command to make a GET request to the user positions API. Ensure you replace {ACCESS_TOKEN} with your valid token. ```curl curl -X GET https://api.groww.in/v1/positions/user \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {ACCESS_TOKEN}' \ -H 'X-API-VERSION: 1.0' ``` -------------------------------- ### Python SDK: Fetch User Positions Source: https://groww.in/trade-api/docs/python-sdk/portfolio Initialize the Groww API and fetch all positions for the user. You can also filter positions by specific segments like CASH, FNO, or COMMODITY. ```python from growwapi import GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" # Initialize Groww API groww = GrowwAPI(API_AUTH_TOKEN) # Get all positions (CASH, FNO, and COMMODITY) user_positions_response = groww.get_positions_for_user() # Get positions for specific segment cash_positions_response = groww.get_positions_for_user(segment=groww.SEGMENT_CASH) fno_positions_response = groww.get_positions_for_user(segment=groww.SEGMENT_FNO) commodity_positions_response = groww.get_positions_for_user(segment=groww.SEGMENT_COMMODITY) print(user_positions_response) ``` -------------------------------- ### Response Payload Example for Greeks Data Source: https://groww.in/trade-api/docs/python-sdk/live-data This is an example of the JSON response you will receive when fetching Greeks data. It includes key Greek metrics for the requested FNO contract. ```json { "greeks": { "delta": 0.6006, "gamma": 0.0014, "theta": -8.1073, "vega": 13.1433, "rho": 2.7333, "iv": 8.2383 } } ``` -------------------------------- ### Get User Holdings Source: https://groww.in/trade-api/docs/curl/portfolio Use this cURL command to make a GET request to the holdings API endpoint. Ensure you include the necessary authorization and API version headers. ```curl curl -X GET https://api.groww.in/v1/holdings/user \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {ACCESS_TOKEN}' \ -H 'X-API-VERSION: 1.0' ``` -------------------------------- ### User Margin Details Response Source: https://groww.in/trade-api/docs/curl/margin Example response showing available user margin details, including cash, collateral, and specific margin breakdowns for F&O, equity, and commodities. All prices are in rupees. ```json { "status": "SUCCESS", "payload": { "clear_cash": 5000, "net_margin_used": 35000, "brokerage_and_charges": 200, "collateral_used": 3000, "collateral_available": 7000, "adhoc_margin": 1500, "fno_margin_details": { "net_fno_margin_used": 15000, "span_margin_used": 7000, "exposure_margin_used": 4000, "future_balance_available": 3000, "option_buy_balance_available": 11000, "option_sell_balance_available": 1000 }, "equity_margin_details": { "net_equity_margin_used": 10000, "cnc_margin_used": 5000, "mis_margin_used": 3000, "cnc_balance_available": 9000, "mis_balance_available": 1000 }, "commodity_margin_details": { "commodity_span_margin": 7000, "commodity_exposure_margin": 4000, "commodity_tender_margin": 2000, "commodity_special_margin": 1000, "commodity_additional_margin": 3000, "commodity_unrealised_m2m": 1500, "commodity_realised_m2m": 2500 } } } ``` -------------------------------- ### Response Payload Example for Holdings Source: https://groww.in/trade-api/docs/python-sdk/portfolio This is an example of the JSON payload structure returned when fetching user holdings. It includes details for each holding such as ISIN, trading symbol, quantities, and pricing. ```json "holdings": [ { "isin": "INE545U01014", "trading_symbol": "RELIANCE", "quantity": 10, "average_price": 100, "pledge_quantity": 2, "demat_locked_quantity": 1, "groww_locked_quantity": 1.5, "repledge_quantity": 0.5, "t1_quantity": 3, "demat_free_quantity": 5, "corporate_action_additional_quantity": 1, "active_demat_transfer_quantity": 1 } ] ``` -------------------------------- ### Get User Profile using Python SDK Source: https://groww.in/trade-api/docs/python-sdk/user Initializes the GrowwAPI with your authentication token and retrieves the user's profile information. Ensure you replace 'your_token' with your actual API credentials. ```python from growwapi import GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" # Initialize Groww API groww = GrowwAPI(API_AUTH_TOKEN) user_profile_response = groww.get_user_profile() print(user_profile_response) ``` -------------------------------- ### Get Smart Order Status Request Source: https://groww.in/trade-api/docs/curl/smart-orders Use this cURL command to send a GET request to retrieve the status of a specific smart order. Replace placeholders with your order details. ```curl curl -X GET \ 'https://api.groww.in/v1/order-advance/status/CASH/GTT/internal/gtt_91a7f4' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {ACCESS_TOKEN}' \ -H 'X-API-VERSION: 1.0' ``` -------------------------------- ### Get Available User Margin Details Source: https://groww.in/trade-api/docs/python-sdk/margin Retrieve your available margin details for equity, F&O, and commodity segments. Initialize the GrowwAPI with your authentication token. ```python from growwapi import GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" # Initialize Groww API groww = GrowwAPI(API_AUTH_TOKEN) available_margin_details_response = groww.get_available_margin_details() print(available_margin_details_response) ``` -------------------------------- ### Get Historical Candle Data Source: https://groww.in/trade-api/docs/curl/historical-data Fetches historical candle data for a given instrument and time range. This is the recommended endpoint as the previous 'Get Historical Data' endpoint is deprecated. ```APIDOC ## GET /v1/historical/candle/range ### Description This API can be used to get the historical data of an instrument for a given time range. It provides the historical candles for a given interval. ### Method GET ### Endpoint https://api.groww.in/v1/historical/candle/range ### Parameters #### Query Parameters - **exchange** (string) - Required - Stock exchange - **segment** (string) - Required - Segment of the instrument such as CASH, FNO etc. - **trading_symbol** (string) - Required - Trading Symbol of the instrument as defined by the exchange - **start_time** (string) - Required - Time in yyyy-MM-dd HH:mm:ss or epoch seconds format from which data is required - **end_time** (string) - Required - Time in yyyy-MM-dd HH:mm:ss or epoch seconds format from which data is required - **interval_in_minutes** (string) - Optional - Interval in minutes for which data is required ### Request Example ```json { "example": "curl -X GET https://api.groww.in/v1/historical/candle/range?exchange=NSE&segment=CASH&trading_symbol=WIPRO&start_time=2021-01-01 09:15:00&end_time=2021-01-01 15:15:00 \n -H 'Accept: application/json' \n -H 'Authorization: Bearer {ACCESS_TOKEN}' \n -H 'X-API-VERSION: 1.0'" } ``` ### Response #### Success Response (200) - **candles** (array[array]) - This contains the list of candles. Each candle has candle timestamp (epoch second), open (float), high (float), low (float), close (float) , volume (int) in that order. - **start_time** (string) - Start time in yyyy-MM-dd HH:mm:ss - **end_time** (string) - End time in yyyy-MM-dd HH:mm:ss - **interval_in_minutes** (int) - Interval in minutes #### Response Example ```json { "status": "SUCCESS", "payload": { "candles": [ [ 1633072800, // candle timestamp in epoch second 150.1, // open price 155.0, // high price 145.0, // low price 152.4, // close price 10000 // volume ] ], "start_time": "2025-01-01 15:30:00", "end_time": "2025-01-01 15:30:00", "interval_in_minutes": 5 } } ``` ``` -------------------------------- ### Order Placement Response Source: https://groww.in/trade-api/docs/curl/orders This is an example of a successful response when an order is placed. It includes the Groww order ID, current order status, and the reference ID provided in the request. ```json { "status": "SUCCESS", "payload": { "groww_order_id": "GMK39038RDT490CCVRO", "order_status": "OPEN", "order_reference_id": "Ab-654321234-1628190", "remark": "Order placed successfully" } } ``` -------------------------------- ### Generate SHA-256 Checksum in .NET Source: https://groww.in/trade-api/docs/curl This .NET example demonstrates how to create a SHA-256 checksum by hashing the concatenation of your API secret and the current epoch timestamp. ```.net using System.Security.Cryptography; using System.Text; public class ChecksumGenerator { public static void Main(string[] args) { Console.WriteLine(GenerateChecksum("", GetLatestTimestampInEpochSeconds())); } /// Generates a SHA-256 checksum for the given input string. public static string GenerateChecksum(string secret, string timestamp) { string input = secret + timestamp; byte[] inputBytes = Encoding.UTF8.GetBytes(input); byte[] hashBytes = SHA256.HashData(inputBytes); return Convert.ToHexString(hashBytes).ToLowerInvariant(); } /// Returns the current UTC time in epoch seconds as a string. public static string GetLatestTimestampInEpochSeconds() { return DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); } } ``` -------------------------------- ### Subscribe to Market Depth (Async) Source: https://groww.in/trade-api/docs/python-sdk/feed Subscribe to market depth for specified instruments and receive data via a callback function. Ensure your Groww API token is valid and instruments are correctly formatted. ```python from growwapi import GrowwFeed, GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" groww = GrowwAPI(API_AUTH_TOKEN) feed = GrowwFeed(groww) def on_data_received(meta): print("Data received") print(feed.get_market_depth()) # you can fetch exchange_token from instruments.csv file instruments_list = [{"exchange": "NSE", "segment": "CASH", "exchange_token": "2885"}, {"exchange": "NSE", "segment": "FNO", "exchange_token": "35241"}] feed.subscribe_market_depth(instruments_list, on_data_received=on_data_received) # This is a blocking call. Nothing after this will run. feed.consume() ``` -------------------------------- ### Fetch Option Chain Data with Python SDK Source: https://groww.in/trade-api/docs/python-sdk/live-data Use this snippet to get the option chain for a specific underlying symbol and expiry date. Ensure you have your API authentication token and have initialized the GrowwAPI client. ```python from growwapi import GrowwAPI # Groww API Credentials (Replace with your actual credentials) API_AUTH_TOKEN = "your_token" # Initialize Groww API groww = GrowwAPI(API_AUTH_TOKEN) # Get option chain for NIFTY with specific expiry date option_chain_response = groww.get_option_chain( exchange=groww.EXCHANGE_NSE, underlying="NIFTY", expiry_date="2025-11-28" ) print(option_chain_response) ```