Upstox API not working

Hi I m using Niota for paper trading but real time data are not updating in niota by using upstox API

They use v2 api, and from 22 Aug upstox removed v2, now we have v3

V3 api is also not working after connection, ( using the default v3 sample code.)

access_token ************
response {‘status’: ‘success’, ‘data’: {‘authorizedRedirectUri’: ‘wss://wsfeeder-api.upstox.com/market-data-feeder/v3/upstox-developer-api/feeds?requestId=149c882d-7e2c-4592-9142-31c2057c3923&code=Py0sZ-45378a1c-3de3-4c63-b830-6735a9f6afd7’, ‘authorized_redirect_uri’: ‘wss://wsfeeder-api.upstox.com/market-data-feeder/v3/upstox-developer-api/feeds?requestId=149c882d-7e2c-4592-9142-31c2057c3923&code=Py0sZ-45378a1c-3de3-4c63-b830-6735a9f6afd7’}}
[MarketData] Connection established
[MarketData] {“type”: “market_info”, “currentTs”: “1756115429073”, “marketInfo”: {“segmentStatus”: {“BSE_FO”: “NORMAL_OPEN”, “MCX_INDEX”: “NORMAL_OPEN”, “NSE_INDEX”: “NORMAL_OPEN”, “BCD_FO”: “NORMAL_OPEN”, “BSE_INDEX”: “NORMAL_OPEN”, “BSE_EQ”: “NORMAL_OPEN”, “NCD_FO”: “NORMAL_OPEN”, “NSE_COM”: “NORMAL_OPEN”, “NSE_EQ”: “NORMAL_OPEN”, “NSE_FO”: “NORMAL_OPEN”, “MCX_FO”: “NORMAL_OPEN”}}} but receives no market data.

Hi @YELTHIMAR_37057316 V3 is working correctly. Could you please share the instrument for which you are facing this issue?

@Atul_47255444

i’m using these keys

subscribe

    data = {
        "guid": "13syxu852ztodyqncwt0",
        "method": "sub",
        "data": {
            "mode": "full",
            "instrumentKeys": ["MCX_FO|467014","NSE_INDEX|Nifty Bank", "NSE_INDEX|Nifty 50"]
        }
    }

here is the full code


from __future__ import print_function
import upstox_client

import asyncio
import json
import ssl
import websockets
import requests
import sys
from google.protobuf.json_format import MessageToDict

import MarketDataFeedV3_pb2 as pb

path = "c:\\Trader\\upstox_v3"

sys.path.insert(0, path )


def get_market_data_feed_authorize_v3():
  
    access_token = open(path + "\\upstox_access_token.txt", 'r').read()
    print("access_token", access_token)

    headers = {
        'Accept': 'application/json',
        'Authorization': f'Bearer {access_token}'
    }
    url = 'https://api.upstox.com/v3/feed/market-data-feed/authorize'
    api_response = requests.get(url=url, headers=headers)
    return api_response.json()

def get_portfolio_stream_feed_authorize(api_version, configuration):
    api_instance = upstox_client.WebsocketApi(
        upstox_client.ApiClient(configuration))
    api_response = api_instance.get_portfolio_stream_feed_authorize(api_version)
    return api_response

def decode_protobuf(buffer):
    """Decode protobuf message."""
    feed_response = pb.FeedResponse()
    feed_response.ParseFromString(buffer)
    return feed_response

async def fetch_market_data():
    """Fetch market data using WebSocket and print it."""
    ssl_context = ssl.create_default_context()
    ssl_context.check_hostname = False
    ssl_context.verify_mode = ssl.CERT_NONE

    response = get_market_data_feed_authorize_v3()
    print("response",response)
    async with websockets.connect(response["data"]["authorized_redirect_uri"], ssl=ssl_context) as websocket:
        print('[MarketData] Connection established')

        # subscribe
        data = {
            "guid": "13syxu852ztodyqncwt0",
            "method": "sub",
            "data": {
                "mode": "full",
                "instrumentKeys": ["MCX_FO|467014","NSE_INDEX|Nifty Bank", "NSE_INDEX|Nifty 50"]
            }
        }
        await websocket.send(json.dumps(data))

        while True:
            message = await websocket.recv()
            decoded_data = decode_protobuf(message)
            data_dict = MessageToDict(decoded_data)
            print("[MarketData]", json.dumps(data_dict))


async def fetch_order_updates():
    ssl_context = ssl.create_default_context()
    ssl_context.check_hostname = False
    ssl_context.verify_mode = ssl.CERT_NONE

    print("Loaded upstox_client from:", upstox_client.__file__)

    configuration = upstox_client.Configuration()
    configuration.access_token = open(path + "\\upstox_access_token.txt", 'r').read()

    api_version = '2.0'
    response = get_portfolio_stream_feed_authorize(api_version, configuration)

    async with websockets.connect(response.data.authorized_redirect_uri, ssl=ssl_context) as websocket:
        print('[Orders] Connection established')

        while True:
            message = await websocket.recv()
            print("[Orders]", message)

async def main():
    # Run both tasks concurrently
    await asyncio.gather(
        fetch_market_data()
        ,fetch_order_updates()
    )


if __name__ == "__main__":
    asyncio.run(main())

output:


access_token 
eyJ0eXAiOiJKV1QiLCJrZXlfaWQiOiJza192MS4wIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIiOiI2UEFRM0IiLCJqdGkiOiI2OGFiZGQ0YmQ0OTIxYjRjZDIzYTIwM2UiLCJpc011bHRpQ2xpZW50IjpmYWxzZSwiaXNQbHVzUGxhbiI6ZmFsc2UsImlhdCI6MTc1NjA5Mzc3MSwiaXNzIjoidWRhcGktZ2F0ZXdheS1zZXJ2aWNlIiwiZXhwIjoxNzU2MTU5MjAwfQ.BaWBiz1W_TeAt_OV60YKA4Lz-GApsql_ZZ3nhj5E59s
response {'status': 'success', 'data': {'authorizedRedirectUri': 'wss://wsfeeder-api.upstox.com/market-data-feeder/v3/upstox-developer-api/feeds?requestId=ca5a2b50-7108-49b4-b9f7-76f9c1be2ec8&code=Q0z9C-3da2fec4-be09-4a07-b97d-c411d4e4df59', 'authorized_redirect_uri': 'wss://wsfeeder-api.upstox.com/market-data-feeder/v3/upstox-developer-api/feeds?requestId=ca5a2b50-7108-49b4-b9f7-76f9c1be2ec8&code=Q0z9C-3da2fec4-be09-4a07-b97d-c411d4e4df59'}}      
[MarketData] Connection established
[MarketData] {"type": "market_info", "currentTs": "1756131671419", "marketInfo": {"segmentStatus": {"BSE_FO": "NORMAL_CLOSE", "MCX_INDEX": "NORMAL_OPEN", "BCD_FO": "NORMAL_CLOSE", "BSE_EQ": "CLOSING_END", "NCD_FO": "NORMAL_CLOSE", "NSE_EQ": "CLOSING_END", "NSE_FO": "NORMAL_CLOSE", "MCX_FO": "NORMAL_OPEN"}}}

and i dont see any Market Data expected after this.

Its not working , still get these logs and no market data.
[Data Stream] Connected to V3
[2025-08-26 08:22:27.895210] {“type”: “market_info”, “currentTs”: “1756176747420”, “marketInfo”: {“segmentStatus”: {“BSE_FO”: “NORMAL_CLOSE”, “MCX_INDEX”: “NORMAL_CLOSE”, “NSE_INDEX”: “CLOSING_END”, “BCD_FO”: “NORMAL_CLOSE”, “BSE_INDEX”: “CLOSING_END”, “BSE_EQ”: “CLOSING_END”, “NCD_FO”: “NORMAL_CLOSE”, “US_EQ”: “NORMAL_CLOSE”, “NSE_COM”: “NORMAL_CLOSE”, “NSE_EQ”: “CLOSING_END”, “NSE_FO”: “NORMAL_CLOSE”, “MCX_FO”: “NORMAL_CLOSE”}}}
[PF Stream] Connected

[2025-08-26 08:59:59.887181] {“type”: “market_info”, “currentTs”: “1756179000011”, “marketInfo”: {“segmentStatus”: {“NSE_COM”: “NORMAL_OPEN”}}}

[2025-08-26 09:00:00.030798] {“type”: “market_info”, “currentTs”: “1756179000151”, “marketInfo”: {“segmentStatus”: {“MCX_FO”: “NORMAL_OPEN”}}}

[2025-08-26 09:00:00.032791] {“type”: “market_info”, “currentTs”: “1756179000152”, “marketInfo”: {“segmentStatus”: {“MCX_INDEX”: “NORMAL_OPEN”}}}

[2025-08-26 09:00:00.092630] {“type”: “market_info”, “currentTs”: “1756179000209”, “marketInfo”: {“segmentStatus”: {“NSE_EQ”: “PRE_OPEN_START”}}}

[2025-08-26 09:00:00.100609] {“type”: “market_info”, “currentTs”: “1756179000211”, “marketInfo”: {“segmentStatus”: {“NSE_INDEX”: “PRE_OPEN_START”}}}

[2025-08-26 09:00:00.100609] {“type”: “market_info”, “currentTs”: “1756179000212”, “marketInfo”: {“segmentStatus”: {“NCD_FO”: “NORMAL_OPEN”}}}

[2025-08-26 09:00:00.124064] {“type”: “market_info”, “currentTs”: “1756179000246”, “marketInfo”: {“segmentStatus”: {“NSE_COM”: “NORMAL_OPEN”}}}

[2025-08-26 09:00:00.169935] {“type”: “market_info”, “currentTs”: “1756179000286”, “marketInfo”: {“segmentStatus”: {“NSE_COM”: “NORMAL_OPEN”}}}

[2025-08-26 09:00:00.196863] {“type”: “market_info”, “currentTs”: “1756179000323”, “marketInfo”: {“segmentStatus”: {“NCD_FO”: “NORMAL_OPEN”}}}

[2025-08-26 09:00:00.214815] {“type”: “market_info”, “currentTs”: “1756179000342”, “marketInfo”: {“segmentStatus”: {“BCD_FO”: “NORMAL_OPEN”}}}

[2025-08-26 09:00:00.246730] {“type”: “market_info”, “currentTs”: “1756179000374”, “marketInfo”: {“segmentStatus”: {“BSE_EQ”: “PRE_OPEN_START”}}}

[2025-08-26 09:00:00.247728] {“type”: “market_info”, “currentTs”: “1756179000375”, “marketInfo”: {“segmentStatus”: {“BSE_INDEX”: “PRE_OPEN_START”}}}

[2025-08-26 09:07:05.985628] {“type”: “market_info”, “currentTs”: “1756179426119”, “marketInfo”: {“segmentStatus”: {“BSE_EQ”: “PRE_OPEN_END”}}}

[2025-08-26 09:07:05.986624] {“type”: “market_info”, “currentTs”: “1756179426119”, “marketInfo”: {“segmentStatus”: {“BSE_INDEX”: “PRE_OPEN_END”}}}

[2025-08-26 09:07:39.893345] {“type”: “market_info”, “currentTs”: “1756179460026”, “marketInfo”: {“segmentStatus”: {“NSE_EQ”: “PRE_OPEN_END”}}}

[2025-08-26 09:07:39.894341] {“type”: “market_info”, “currentTs”: “1756179460026”, “marketInfo”: {“segmentStatus”: {“NSE_INDEX”: “PRE_OPEN_END”}}}

[2025-08-26 09:14:59.877983] {“type”: “market_info”, “currentTs”: “1756179900017”, “marketInfo”: {“segmentStatus”: {“BSE_FO”: “NORMAL_OPEN”}}}

[2025-08-26 09:14:59.960830] {“type”: “market_info”, “currentTs”: “1756179900102”, “marketInfo”: {“segmentStatus”: {“NSE_EQ”: “NORMAL_OPEN”}}}

[2025-08-26 09:14:59.962821] {“type”: “market_info”, “currentTs”: “1756179900103”, “marketInfo”: {“segmentStatus”: {“NSE_INDEX”: “NORMAL_OPEN”}}}

[2025-08-26 09:14:59.995772] {“type”: “market_info”, “currentTs”: “1756179900136”, “marketInfo”: {“segmentStatus”: {“NSE_FO”: “NORMAL_OPEN”}}}

[2025-08-26 09:15:00.045599] {“type”: “market_info”, “currentTs”: “1756179900184”, “marketInfo”: {“segmentStatus”: {“NSE_FO”: “NORMAL_OPEN”}}}

[2025-08-26 09:15:00.113456] {“type”: “market_info”, “currentTs”: “1756179900255”, “marketInfo”: {“segmentStatus”: {“BSE_EQ”: “NORMAL_OPEN”}}}

[2025-08-26 09:15:00.114455] {“type”: “market_info”, “currentTs”: “1756179900255”, “marketInfo”: {“segmentStatus”: {“BSE_INDEX”: “NORMAL_OPEN”}}}