FYERS API Utilize Free of Cost to Automate Trades in Python

Open Fyers Trading Account Please Click Here.

CMD pip Installation Type and Enter: pip install fyers_api

Please Follow the Above Video then go for the Code Below for generation of access token and Programmatic Trading:

Generate Token:

from fyers_api import accessToken
app_id = open('app_id.txt','r').read()
app_secret = open('app_secret.txt','r').read()
app_session = accessToken.SessionModel(app_id, app_secret)
response = app_session.auth()

Place Order:

from fyers_api import fyersModel
token="Your Token "
is_async = False 
fyers = fyersModel.FyersModel(is_async)
token = token,
data = {
"symbol" : "NSE:TATAMOTORS-EQ",
"qty" : 1,
"type" : 2,
"side" : 1,
"productType" : "INTRADAY",
"limitPrice" : 0,
"stopPrice" : 0,
"disclosedQty" : 0,
"validity" : "DAY",
"offlineOrder" : "False",
"stopLoss" : 0,
"takeProfit" : 0

Generate access token directly from the web browser:

import sys
import webbrowser
from fyers_api import accessToken

def getToken(app_id, app_secret):
 The variable `generateTokenUrl` will have a url like 
  1. This function open this url in the browser. 
  2. This will ask you to login and will ask you to approve the app if it is not approved already.
  3. Once that is done, it will redirect to a url (added while app creation) with the access_token. The url will look like
  4. You have to take the access_token from the url and use that token in your going forward.
 appSession = accessToken.SessionModel(app_id,app_secret)

 response = appSession.auth()

 if response["code"] != 200:
  print (response)

 auth_code = response["data"]["authorization_code"]


 generateTokenUrl = appSession.generate_token()

def main():
 app_id = open('app_id.txt','r').read()
 app_secret = open('app_secret.txt','r').read()
 getToken(app_id, app_secret)

if __name__ == '__main__':

If you registered under my referral for opening of trading account and after successful registration when you got the Client ID and Password applied for API activation and still it is not active please do visit to my whatsapp which is available in the video description and ask for the form link will definitely help in get your API active.