New Feature Announcement: Enhanced Real-Time Market Data with our Market Data API!


  • Hi @admin ,

    we are not getting data from the past two days from the below mentioned endpoint.

    Requesting you to please look into the issue and fix it ASAP.

    https://apiconnect.angelbroking.com/rest/secure/angelbroking/market/v1/quote/

    Thanks & Regards
    Pavan Kumar Dakarapu


  • @admin I am getting bad request error with Market Data API

    <html>
    <head><title>400 Bad Request</title></head>
    <body bgcolor="white">
    <center><h1>400 Bad Request</h1></center>
    <hr><center>nginx/1.14.1</center>
    </body>
    </html>
    

    endpoint: https://apiconnect.angelbroking.com/rest/secure/angelbroking/market/v1/quote
    method: post
    payload:

    payload = {
        "mode": "LTP",
        "exchangeTokens": {
            "NSE": "3045"
        }
    }
    payload=json.dumps(payload)
    
    connection=http.client.HTTPSConnection("apiconnect.angelbroking.com")
    url="rest/secure/angelbroking/market/v1/quote/"
    connection. Request("POST", url, body=json_data, headers=headers)
    

    language: python
    Can anyone help with this?


  • https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json.

    This link is returning null. there is no data received from this link. can some one help?


  • @admin Thanks for the new API but the endpoint is not returning the expected data for the index. I tried the API on Nifty using the following payload but I couldn't get the open price, the open price was 0.

    Payload

    '{"mode":"OHCL","exchangeTokens":{"NSE":["26000"]}}'
    

    Response

    close: 16483.85
    exchange: 'NSE'
    high: 0
    low: 0
    ltp: 19460.2
    open: 0
    symbolToken: '26000'
    tradingSymbol: 'NIFTY'
    

    Is there anything I'm missing or is Smart API yet to support open prices for index scripts like Nifty?
    Looking forward to your answer.


  • @admin tried with the same code but for nse stocks and it worked like a charm...
    👏 👏


  • @admin Really happy for the short turnaround... I can run the code now but getting only ping since its out of market hours... Will run it tomorrow and see how it works and update in the thread and hope the subscribe and unsubscribe inside the on_open() function works too 😃

    ####### Websocket V2 sample code #######
    
    from SmartApi.smartWebSocketV2 import SmartWebSocketV2
    from logzero import logger
    from cred import username, apikey, pwd, token
    import pyotp
    from SmartApi import SmartConnect
    import time
    
    
    obj = SmartConnect(api_key=apikey)
    data = obj.generateSession(username, pwd, pyotp.TOTP(token).now())
    print(data)
    refreshToken = data['data']['refreshToken']
    res = obj.getProfile(refreshToken)
    print(res['data']['exchanges'])
    
    AUTH_TOKEN = data['data']['jwtToken']
    API_KEY = apikey
    CLIENT_CODE = username
    FEED_TOKEN = obj.getfeedToken()
    correlation_id = "xxxxxxxxxx"
    
    
    action = 1
    mode =3
    token_list = [
        {
            "exchangeType": "5",
            "tokens": ["234877"]
        }
    ]
    
    sws = SmartWebSocketV2(AUTH_TOKEN, API_KEY, CLIENT_CODE, FEED_TOKEN)
    
    
    def on_data(wsapp, message):
        logger.info("Ticks: {}".format(message))
        # close_connection()
    
    
    def on_open(wsapp):
        logger.info("on open")
        sws.subscribe(correlation_id, mode, token_list)
        #sws.unsubscribe(correlation_id, mode, token_list)
    
    
    def on_error(wsapp, error):
        logger.error(error)
    
    
    def on_close(wsapp):
        logger.info("Close")
    
    
    def close_connection():
        sws.close_connection()
    
    
    def subscribe():
        sws.subscribe(correlation_id, mode, token_list)
    
    
    # Assign the callbacks.
    sws.on_open = on_open
    sws.on_data = on_data
    sws.on_error = on_error
    sws.on_close = on_close
    
    
    sws.connect()
    

  • Hi @Vignesha

    The correlation_id in the web_socket_2 example script is a 10-digit alphanumeric reference provided by the client. It helps track requests and error responses. You can generate a unique ID and include it in your API requests for easier tracking.

    Regarding the authentication and other mandatory headers, here's a summary:

    Authorization: This header expects a JWT authentication token obtained from the LoginbyPassword API.
    x-api-key: Your API key
    x-client-code: Your client code (Angel One trading account ID)
    x-feed-token: Feed token from the LoginbyPassword API for for subscribing to data feeds.

    For more details, refer to the WebSocket 2.0 documentation at https://smartapi.angelbroking.com/docs/WebSocket2.

    If you have further questions, please discuss them on the WebSocket 2.0 SDK release thread [https://smartapi.angelbroking.com/topic/3660/upgraded-smartapi-libraries-to-support-websocket-2-0-python-java-sdk-and-node-js-library].

    Let me know if you need any more assistance!


  • @admin Thanks for the update... this seems to be a lot better...
    Is this being documented in the documentation? If not it would be better to do as I have not seen things like correlation_id in the new web_Socket_2 example script

    I guess its like a reference character of 10 digits provided by meself/customer that we can use to check the status of connection?

    Would be great if all this are explained and on how to get this

    AUTH_TOKEN = "Your Auth_Token"
    API_KEY = "Your Api_Key"
    CLIENT_CODE = "Your Client Code"
    FEED_TOKEN = "Your Feed_Token"
    correlation_id = "abc123"


  • @Ashok Yes, all exchanges are supported.


  • @admin Will it support all exchange segments? NFO, MCX ?