NSE India API Live Analysis Variations Index Gainers in Python

India VIX in Decision Making Fetching Data Directly from NSE India API


Follow the Instructions from the Video then go for the Code Input:

 
import requests
import pandas as pd

url='https://www.nseindia.com/api/equity-stockIndices?index=INDIA VIX'

headers={
    'User-Agent' : 'Mozilla/5.0'

}

response=requests.get(url,headers=headers)
data=response.json()
print(data)


df=pd.concat([pd.DataFrame(data['data'])[['symbol','lastPrice']]])
print(df)

Most Active Securities by Volume NSE India API Live Analysis


Follow the Instructions from the Video then go for the Code Input:

  
import requests
import pandas as pd  

url='https://www.nseindia.com/api/live-analysis-most-active-securities?index=volume'
headers={
    'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebkit/537.36',
    'Accept-Language' : 'en-US, en; q=0.9'
}

response=requests.get(url,headers=headers)
data=response.json()
    


df=pd.concat([pd.DataFrame(data['data'])[['symbol','lastPrice','totalTradedVolume']] ])
df_sorted=df.sort_values('lastPrice').reset_index(drop=True)
print(df_sorted.to_string(index=False))

Most Active Securities by Value NSE India API Live Analysis


Follow the Instructions from the Video then go for the Code Input:

  
import requests   
import pandas as pd  

url='https://www.nseindia.com/api/live-analysis-most-active-securities?index=value'

headers={
    'User-Agent' : 'Mozilla/5.0'

}

response=requests.get(url,headers=headers)
data=response.json()


df=pd.concat([pd.DataFrame(data['data'])[['symbol','lastPrice','totalTradedValue','lastUpdateTime']]])
df_sorted=df.sort_values('lastPrice').reset_index(drop=True)

print(df_sorted.to_string(index=False))

NSE India API Live Analysis Variations Index Gainers in Python


Follow the Instructions from the Video then go for the Code Input:

  
import json
import pandas as pd  

with open('gain.json','r') as f:
    data=json.load(f)
    
categories=['NIFTY', 'BANKNIFTY','NIFTYNEXT50','SecGtr20','SecLwr20','FOSec','allSec']

df=pd.concat([pd.DataFrame(data[cat]['data'])[['symbol','ltp']] for cat in categories if cat in data])
df_sorted=df.sort_values('ltp').reset_index(drop=True)
print(df_sorted.to_string(index=False))

Read NSE Gainers Data Directly from NSE India API


Follow the Instructions from the Video then go for the Code Input:

  
import requests
import pandas as pd  

url='https://www.nseindia.com/api/live-analysis-variations?index=gainers'
headers={
    'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebkit/537.36',
    'Accept-Language' : 'en-US, en; q=0.9'
}

response=requests.get(url,headers=headers)
data=response.json()
    
categories=['FOSec']

df=pd.concat([pd.DataFrame(data[cat]['data'])[['symbol','ltp']] for cat in categories if cat in data])
df_sorted=df.sort_values('ltp').reset_index(drop=True)
print(df_sorted.to_string(index=False))