Difference between FEED_TOKEN and token
-
I see the example code in readme as
from smartapi import WebSocket FEED_TOKEN= "your feed token" CLIENT_CODE="your client Id" token="channel you want the information of" #"nse_cm|2885&nse_cm|1594&nse_cm|11536"
I understand the 'token' is actually the channel I want to subscribe to. But how do I get the FEED_TOKEN and what is it?
-
@mandeepV
Can you share code of your screen shot?? -
I dont use the headers myself. I just use the python SDK. so I am unable to step in here to help you out.
-
It shows invalid refresh token when I run below code.
import http.client
import mimetypes
conn = http.client.HTTPSConnection(
" apiconnect.angelbroking.com "
)
payload = ''
headers = headers = {
'Authorization': 'Bearer AUTHORIZATION_TOKEN',
'Accept': 'application/json',
'X-UserType': 'USER',
'X-SourceID': 'WEB',
'X-ClientLocalIP': 'CLIENT_LOCAL_IP',
'X-ClientPublicIP': 'CLIENT_PUBLIC_IP',
'X-MACAddress': 'MAC_ADDRESS',
'X-PrivateKey': 'API_KEY'
}
conn.request("GET",
"/rest/secure/angelbroking/user/
v1/getProfile",
payload,
headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8")) -
refresh token is generated when you generate session.
-
@rajanprabu
Do I have to put anything in the refresh token??
Or I just leave it as it is? -
from smartapi import SmartConnect obj=SmartConnect(api_key="your api key") data = obj.generateSession("Your Client ID","Your Password") refreshToken= data['data']['refreshToken'] #fetch the feedtoken feedToken=obj.getfeedToken()
-
@mandeepV
I dont know hot to put feed token Can you share your working code?? -
@mandeepV They are correct.. it normally gives tvalue once a second and 2-3 price ticks in a second. I search for keys. Have a look at this post by our 007
-
@rajanprabu I receive 3 ticks, do you know how they differ?
Ticks: [{'name': 'tm', 'tvalue': '24/02/2021 10:04:09'}] Ticks: [{'e': 'nse_cm', 'ltp': '2046.15', 'ltq': '16', 'ltt': 'NA', 'name': 'sf', 'tk': '2885'}] Ticks: [{'ap': '2046.93', 'bp': '2046.10', 'bq': '22', 'bs': '21', 'c': '2023.45', 'cng': '22.65', 'e': 'nse_cm', 'lo': '2026.15', 'ltp': '2046.10', 'ltq': '1', 'ltt': '24/02/2021 10:04:09', 'name': 'sf', 'nc': '01.12', 'sp': '2046.15', 'tbq': '384403', 'tk': '2885', 'to': '4707730213.14', 'tsq': '546250', 'v': '2299898'}]
-
@rajanprabu Thanks. Working now.
I used following variable for FEED_TOKEN's value at bottom.
#fetch the feedtoken feedToken=obj.getfeedToken()
-