Not able to get the index quote for NIFTY MID SELECT

from snapi_py_client.snapi_bridge import StocknoteAPIPythonBridge

Initialize Samco API bridge

samco = StocknoteAPIPythonBridge()
samco.set_session_token(sessionToken=session_token)
quote = samco.index_quote(‘NIFTY MID SELECT’)
quote_data = json.loads(quote)
print(quote_data) It is giving error {‘serverTime’: ‘18/08/24 23:57:53’, ‘status’: ‘Failure’, ‘statusMessage’: ‘Please enter a valid Index Name.’} Please help

We’ll begin working on your query shortly and will notify you via email or through this forum once it’s resolved.

For temporary use, you can access the quote details for NIFTY MID SELECT using our old domain. Here’s a sample Python code snippet to do that:
import json
from typing import Any
import pandas as pd
from snapi_py_client.snapi_bridge import StocknoteAPIPythonBridge
import requests
import json

samco = StocknoteAPIPythonBridge()
login = json.loads(samco.login(body={
“userId”: “XXXXXX”,
“password”: “XXXX”,
“yob”: “XXXX”
}))
session = login[‘sessionToken’]
print(session)
samco.set_session_token(sessionToken=session)
headers = {
‘Accept’: ‘application/json’,
‘x-session-token’: session
}
r = requests.get(‘https://api.stocknote.com/quote/indexQuote’, params={
‘indexName’: ‘NIFTY MID SELECT’
}, headers=headers)
print(r.json())

This code demonstrates how to retrieve the quote details.

Thanks for the information.

You can now use our new domain, which also provides responses for NIFTY MID SELECT.

import json

from typing import Any

import pandas as pd

from snapi_py_client.snapi_bridge import StocknoteAPIPythonBridge

import requests

import json

samco = StocknoteAPIPythonBridge()

login = json.loads(samco.login(body={

“userId”: “XXXXX”,

“password”: “XXXX”,

“yob” : “XXXXX”

}))

session = login[‘sessionToken’]

print(session)

samco.set_session_token(sessionToken=session)

headers = {

‘Accept’: ‘application/json’,

‘x-session-token’: session

}

r = requests.get(‘https://tradeapi.samco.in/quote/indexQuote’, params={

‘indexName’: ‘NIFTY MID SELECT’

}, headers=headers)

print(r.json())

Response : {‘serverTime’: ‘20/08/24 12:14:04’, ‘msgId’: ‘7bbdded9-8c0a-4ca4-88d8-acfe8c0dbb1a’, ‘status’: ‘Success’, ‘statusMessage’: ‘Index Quote details retrieved successfully’, ‘indexDetails’: [{‘indexName’: ‘NIFTY MID SELECT’, ‘listingId’: ‘-60’, ‘lastTradedTime’: ‘2024-08-20 12:14:03.0’, ‘spotPrice’: 12815.95, ‘changePercentage’: 0.69, ‘averagePrice’: 0, ‘openValue’: 12807.6, ‘highValue’: 12825.85, ‘lowValue’: 12785.75, ‘closeValue’: 12728.6, ‘totalBuyQuantity’: 0, ‘totalSellQuantity’: 0, ‘totalTradedValue’: 0, ‘totalTradedVolume’: 0, ‘change’: 87.35}]}

sir plz help with samco.index_quote

To avoid “Too many requests” errors, you can introduce a 2-second delay between each API call using time.sleep(2). Here’s how you can modify the code:
import time
for _ in range(10):
quote = samco.index_quote(‘NIFTY 50’)
print(quote)
time.sleep(2) # Pause for 2 seconds between each request
This will ensure there is a 2-second gap between consecutive API calls, helping to prevent rate-limiting issues.