Closed pravin2 closed 1 year ago
Hi, Do not just copy the login code from finvasia. Flattrade has different method/code for this purpose. Go to the test_api.py and check the way to implement it. Good luck. Sanjau
I have followed the steps as defined in https://pi.flattrade.in/docs:
from api_helper import NorenApiPy
import requests
api = NorenApiPy()
data = '{"api_key":"myapikey", "request_code":"17284599fd003f7c.49f13ed680ceaa9f8566e7818c61ac10bf25410d9a8a29cea0b61fec3dfafa4e&client=FTXXXXXX", "api_secret":"myapisecretkey"}'
response = requests.post('https://authapi.flattrade.in/trade/apitoken', data=data)
print(response)
api.set_session(userid= "FTXXXXXX", password = "XXXXXX", usertoken= response)
print(api.get_limits())
I am getting error:
<Response [200]>
{'stat': 'Not_Ok', 'emsg': 'Session Expired : Invalid Session Key'}
Please let me know if anything needs to be corrected in the above sequence as I am not getting the result.
I have followed the steps as defined in https://pi.flattrade.in/docs:
- I have created API Key from https://wall.flattrade.in/ where I have given redirect url as http://127.0.0.1?
- I pasted link https://auth.flattrade.in/?app_key=myapikey to browser and keyed in my Flattrade credentials. After that, I was redirected to blank page where I got below link on address bar http://127.0.0.1/?code=17284599fd003f7c.49f13ed680ceaa9f8566e7818c61ac10bf25410d9a8a29cea0b61fec3dfafa4e&client=FTXXXXXX
- I copied the code and pasted myapikey and myapisecretkey along with in my Python code for POST method:
from api_helper import NorenApiPy import requests api = NorenApiPy() data = '{"api_key":"myapikey", "request_code":"17284599fd003f7c.49f13ed680ceaa9f8566e7818c61ac10bf25410d9a8a29cea0b61fec3dfafa4e&client=FTXXXXXX", "api_secret":"myapisecretkey"}' response = requests.post('https://authapi.flattrade.in/trade/apitoken', data=data) print(response) api.set_session(userid= "FTXXXXXX", password = "XXXXXX", usertoken= response) print(api.get_limits())
I am getting error:
<Response [200]> {'stat': 'Not_Ok', 'emsg': 'Session Expired : Invalid Session Key'}
Please let me know if anything needs to be corrected in the above sequence as I am not getting the result.
Yes, thats a wrong request code. you need to use only below : 17284599fd003f7c.49f13ed680ceaa9f8566e7818c61ac10bf25410d9a8a29cea0b61fec3dfafa4e
do not include the texts after & sign i.e &client=FTXXXXXX. Hope it will solve the issue. do let me know if you still have problem. Sanju
As suggested, I tried in the market hours, but unfortunately no success. Getting same error. Any clues?
you can check it any time (except 6.30 am to7.30 am, maintenance time; i suppose), it will work.
oh i didnt noticed it earlier. usertoken is not the response. as you mentioned like as below , is not right method.
~~data = '{"api_key":"myapikey", "request_code":"17284599fd003f7c.49f13ed680ceaa9f8566e7818c61ac10bf25410d9a8a29cea0b61fec3dfafa4e&client=FTXXXXXX", "api_secret":"myapisecretkey"}' response = requests.post('https://authapi.flattrade.in/trade/apitoken', data=data)~~
The sequence as follows :
Suggestion : Go through this document And this documents Sanju.
Quite complicated login process Thanks for quick response. It worked.
Quite complicated login process Thanks for quick response. It worked.
Hi, Good to know. Being a good contributor, Now you need to Close this issue. Good luck. Sanju
Getting Attribute Error from api_helper import NorenApiPy import credflt
api = NorenApiPy()
api.login(userid=credflt.user, password=credflt.pwd, twoFA=credflt.factor2, vendor_code=credflt.vc, api_secret=credflt.api_key, imei=credflt.imei)
print(api.get_limits())
Getting below error: AttributeError: 'NorenApiPy' object has no attribute '_NorenApi__username'