What is FYERS API

Fyers API is a set of REST-like APIs that provide integration with our in-house trading platform with which you can build your own customized trading applications. You can place fresh single or multiple orders, modify and cancel existing orders in real-time. You can also get account related information such as orderbook, tradebook, net positions, holdings, and funds.

We have ensured maximum security for our APIs which prevent unauthorised transactions. All API requests and received only over HTTPS protocol.

You can read more about when we introduced FYERS APIs here

Community

We have a dedicated community to discuss, share and raise feature requests on FYERS API. Our goal is to empower the AlgoTrading community in India with the most robust and easy to integrate APIs.

You can interact with us on our dedicated topic on FYERS API on FYERS Community

Request & Response Structure

Authorization Headers

Once the authentication is completed, you will receive an access_token. For all of the following requests, you will be required to send a combination of appId and access_token (api_id:access_token) in the HTTP Authorization header.

  curl -H “Authorization: api_id:access_token”
  curl -H “Authorization: aaa-99:bbb” 

Success

Response Attributes
s string “ok”
code int 200
message string “”
Additional key object / list / int / string Each request will contain its own key based on the request

Failure

The error response attributes will contain the following

Response Attributes
s string “error”
code int Negative integer to identify the specific error
message string Error message to identify error
HTTP Header int Refer to the error codes table

Data Types

The error response attributes will contain the following

Data Types
int Request was successful
float Bad request. The request is invalid or certain other errors
string Authorization error. User could not be authenticated
bool Permission error. User does not have the necessary permissions

HTTP Status Codes

Status Code Meaning
200 Request was successful
400 Bad request. The request is invalid or certain other errors
401 Authorization error. User could not be authenticated
403 Permission error. User does not have the necessary permissions
429 Rate limit exceeded. Users have been blocked for exceeding the rate limit.
500 Internal server error.

Rate Limit

Timeframe Rate Limit
Per Second 10
Per Minute 200
Per Day 10000

User blocking

The user will be blocked for the rest of the day if the per minute rate limit is exceeded more than 3 times in the day.

Permission Templates

You can provide different app permissions for each application at the time of creation.

Permission Template Basic Transactions Info Order Placement
List of activities allowed
  1. Profile Details
  2. Logout App
  3. Logout
  1. Basic Included
  2. Orders
  3. Positions
  4. Trades
  5. Holdings
  6. Funds
  7. Market Status
  1. Transactions Info Included
  2. Order Placement
  3. Order Modification
  4. Order Cancellation
  5. Exit Positions
  6. Convert Positions

App Creation

Individual Apps

These are apps which are created for your own personal usage. These apps can be used only by the creator of the app and no other client can login and make use of this particular app.

To create an app, you need to follow the following steps:

  1. Login to API Dashboard
  2. Click on Create App
  3. Provide the following details
    • App Name
    • Redirect URL
    • Description (Optional)
    • App Permissions - Refer Permissions Template
    • Image (Optional)

Third Party Apps

These apps are used by platform providers which would allow end users to login to the app and make use of the functionality. These apps are created by third party application providers to enable FYERS clients to use their applications.

To create a common app, you can get in touch with us here.

Redirect URI

The user will be redirected to the redirect uri after successfully logging in using the FYERS credentials. The redirect uri should be in your control as the auth token is sensitive information.

Authentication & Login Flow - User Apps

Authentication Steps

The login flow is as follows:

  1. Navigate to the Login API endpoint
  2. After successful login, user is redirected to the redirect uri with the auth_code
  3. POST the auth_code and appIdHash (SHA-256 of api_id + app_secret) to Validate Authcode API endpoint
  4. Obtain the access_token use that for all the subsequent requests

Diagram

Request Parameters for Step 1

You need to navigate the user to the FYERS login url with the correct get parameters

Request Attributes
Attribute Data Type Description
client_id string This is the app_id which you have received after creating the app.
Eg: “qwerty-100”
redirect_uri string This is where the user will be redirected after successful login.
Eg: https://trade.fyers.in/api-login/redirect-uri/index.html
This should be the same as what was provided at the time of app creation
response_type string This value must always be “code”
state (Optional) string You send a random value. The same value will be returned after successful login to the redirect uri.
Eg: “abcdefg”
Response Attributes
Attribute Data Type Description
s string ok / error
code int This is the code to identify specific responses
message string This is the message to identify the specific error responses
auth_code string String value which will be used to generate the access_token
state string This value is returned as is from the first request
https://api.fyers.in/api/v2/generate-authcode?client_id=sample_client_id&  redirect_uri=sample_redirect_uri&response_type=code&state=sample_state 

Request Parameters for Step 2

Request Attributes
Attribute Data Type Description
grant_type string This value must always be “authorization_code
appIdHash string SHA-256 of api_id + app_secret
Eg: SHA-256 of app_id:app_secret is
7c7120d2b5004f8de22d8dc2da0453b4d7e6211e37a4108b83712
66ecff00498
You can use this online tool for reference
code string This is the auth_code which is received from the first step
Response Attributes
Attribute Data Type Description
s string ok / error
code int This is the code to identify specific responses
message string This is the message to identify the specific error responses
access_token string This value will be used for all the subsequent requests.

Example request

Curl Request Method:-
curl -H "Content-Type: application/json" -X POST -d '{"grant_type":"authorization_code","appIdHash":"d8f152a3c455add2bd636a2ec6ff893394c8cc4e84d439d95951510b032500e3","code":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE2MDEyOTExNDIsImV4cCI6MTYwMTI5MTQ0MiwibmJmIjoxNjAxMjkxMTQyLCJhdWQiOlsieDoyIiwieDoxIiwieDowIl0sInN1YiI6ImF1dGhfY29kZSIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJub25jZSI6IiIsImFwcF9pZCI6IklESTdYTkpDWU0iLCJ1dWlkIjoiOWQ4N2MxZjk5MWEzNDI1YWIxYWJjYTg5ODgxYTcyZjAiLCJpcEFkZHIiOiIxMDMuNTcuODIuMTA4Iiwic2NvcGUiOiIifQ.ypHzr332QEWv3tidrdtqU2k42Z4EyqT-nTBIZAhpKI4"}'
https://api.fyers.in/api/v2/validate-authcode 

Sample success response

{
  "s": "ok",
  "code": 200,
  "message": "",
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.     eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE2MDEyOTExNjAsImV4cCI6MTYwMTMzOTQwMCwibmJmIjoxNjAxMjkxMTYwLCJhdWQiOlsieDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCZmNjT1l6WVdtVnpvNldNVUJ1OTBnV29GbkJKUWViS2p2LUg4NDY5dEV4cWdWNWNmWVdJQ1Q0eWFTTUJiN0hhVmJBUFJESzgtbzhYQUZpX2w4OERzVXdudllWTjc2R25BYV9HZEFvdTc1LVZ1c29Rbz0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDJ9.5FnygsaTu9ySRk1b2VYhYtjH1L9wQ9rtX0F1vLvf5x0"
}

Best Practices

These are the recommended best practises that you should follow while using the APIs

  1. Never share your app_secret with anyone
  2. Never share your access_token with anyone
  3. Do not provide trading permissions unless you want to use the app to place orders
  4. Provide a redirect_uri which is in your control rather than a public endpoint such as google.com
  5. You should send a random value in the state parameter and verify whether the same value has been returned to you

Authentication & Login Flow - Third Party Apps

There are 2 different authentication flows for Third Party Apps

OAuth2 - Auth Flow

This is a simple OAuth 2 Authentication Flows.

  • This is recommended for applications which have a backend server which can authenticate the second step
  • This is not recommended for Single Page Applications (SPA)
  • Diagram


  • Request Parameters for Step 1

    You need to navigate the user to the FYERS login url with the correct get parameters
    Request Attributes
    Attribute Data Type Description
    client_id string This is the app_id which you have received after creating the app.
    Eg: “qwerty-102”
    redirect_uri string This is where the user will be redirected after successful login.
    Eg:
    https://trade.fyers.in/api-login/redirect-uri/index.html
    This should be the same as what was provided at the time of app creation
    response_type string This value must always be “code”
    state (Optional) string You send a random value. The same value will be returned after successful login to the redirect uri.
    Eg: “abcdefg”
    Response Attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string This is the message to identify the specific error responses
    auth_code string String value which will be used to generate the access_token
    state string This value is returned as is from the first request
  • Request Parameters for Step 2

    Request Attributes
    Attribute Data Type Description
    grant_type string This value must always be “authorization_code”
    appIdHash string SHA-256 of api_id + app_secret
    Eg: SHA-256 of app_id:app_secret is
    c7120d2b5004f8de22d8dc2da0453b4d7e6211e37a4108b8371266ecff00498
    You can use this online tool for reference
    code string This is the auth_code which is received from the first step
    Response Attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string This is the message to identify the specific error responses
    access_token string This value will be used for all the subsequent requests.

.

Example request:-

https://api.fyers.in/api/v2/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&state=sample_state

.

Curl Request Method:-
curl -H "Content-Type: application/json" -X POST -d 
'{
       "grant_type":"authorization_code","appIdHash":"d8f152a3c455add2bd636a2ec6ff893394c8cc4e84d439d95951510b032500e3","code":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE2MDEyOTExNDIsImV4cCI6MTYwMTI5MTQ0MiwibmJmIjoxNjAxMjkxMTQyLCJhdWQiOlsieDoyIiwieDoxIiwieDowIl0sInN1YiI6ImF1dGhfY29kZSIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJub25jZSI6IiIsImFwcF9pZCI6IklESTdYTkpDWU0iLCJ1dWlkIjoiOWQ4N2MxZjk5MWEzNDI1YWIxYWJjYTg5ODgxYTcyZjAiLCJpcEFkZHIiOiIxMDMuNTcuODIuMTA4Iiwic2NvcGUiOiIifQ.ypHzr332QEWv3tidrdtqU2k42Z4EyqT-nTBIZAhpKI4"
 }' https://api.fyers.in/api/v2/validate-authcode 

.

Sample Success Response:-
{
  "s": "ok",
  "code": 200,
  "message": "",
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE2MDEyOTExNjAsImV4cCI6MTYwMTMzOTQwMCwibmJmIjoxNjAxMjkxMTYwLCJhdWQiOlsieDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCZmNjT1l6WVdtVnpvNldNVUJ1OTBnV29GbkJKUWViS2p2LUg4NDY5dEV4cWdWNWNmWVdJQ1Q0eWFTTUJiN0hhVmJBUFJESzgtbzhYQUZpX2w4OERzVXdudllWTjc2R25BYV9HZEFvdTc1LVZ1c29Rbz0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDJ9.5FnygsaTu9ySRk1b2VYhYtjH1L9wQ9rtX0F1vLvf5x0"
}

OAuth2 - PKCE Flow

This flow is recommended for applications which do not have a backend server to complete the 2 step authentication.

  • Recommended for Single Page Applications (SPA)
  • Recommended for mobile applications
  • Diagram
  • Request Parameters for Step 1

    You need to navigate the user to the FYERS login url with the correct get parameters

    Request Attributes
    Attribute Data Type Description
    client_id string This is the app_id which you have received after creating the app.
    Eg: “qwerty-102”
    redirect_uri string This is where the user will be redirected after successful login.
    Eg:
    https://trade.fyers.in/api-login/redirect-uri/index.html
    This should be the same as what was provided at the time of app creation
    response_type string This value must always be “code”
    code_challenge string This is a SHA256 hash of the code_verifier which you have created at your end
    state (Optional) string You send a random value. The same value will be returned after successful login to the redirect uri.
    Eg: “abcdefg”
    Response Attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string This is the message to identify the specific error responses
    auth_code string String value which will be used to generate the access_token
    state string This value is returned as is from the first request
  • Request Parameters for Step 2

    Request Attributes
    Attribute Data Type Description
    grant_type string This value must always be “authorization_code”
    code_verifier string This is the original string which was used to create the code_challenge in the first step
    code string This is the auth_code which is received from the first step
    Response Attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string This is the message to identify the specific error responses
    access_token string This value will be used for all the subsequent requests.

.

Example Request 

https://api.fyers.in/api/v2/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&code_challenge=sample_code_challenge&state=sample_state

.

Curl Request Method:-
curl -H "Content-Type: application/json" -X POST -d 
'{
    "grant_type":"authorization_code",
    "code_verifier":"original_string",
    "code":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE2MDE5OTM1NTMsImV4cCI6MTYwMTk5Mzg1MywibmJmIjoxNjAxOTkzNTUzLCJhdWQiOlsieDoyIiwieDoxIiwieDowIl0sInN1YiI6ImF1dGhfY29kZSIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJub25jZSI6InNhbXBsZV9ub25jZSIsImFwcF9pZCI6IkhTTFJCU0xFSEUiLCJ1dWlkIjoiNWNlNGM5MmNiMGJmNGVkZDljNGFmM2Q2NDM5MGE0YjgiLCJpcEFkZHIiOiIxMDMuNTcuODIuODEiLCJzY29wZSI6Im9wZW5pZCJ9.9mG2VdJjxE7gegmyDwjGw5dxLY8BH1O-v0yEnIwb5eg" 
 }' https://api.fyers.in/api/v2/validate-authcode

.

Sample success response:

{
   "s": "ok",
   "code": 200,
   "message": "",
   "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE2MDE5OTM1NzMsImV4cCI6MTYwMjAzMDY1MywibmJmIjoxNjAxOTkzNTczLCJhdWQiOlsieDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCZmZIdGxQVDZZai1MZkNXdTlXdk5Ec1owUFQxYTJkb2tReEtBVVBhRFZ6b19TMExJOWhEc252d0x0d21tUTlJaWRtNHVtQnV3YW05WTBWamJ6REY2YndqMzNuLVZhUWUtU0t2S2VENUZVRzNQQ1ZmWT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDJ9.A89C71vlzXIXeb_tYfs0AB943yR9GHq1zKc08ePmDqo"
}

Best Practices.

These are the recommended best practises that you should follow while using the APIs

  • Never share your app_secret with anyone
  • Never share your access_token with anyone
  • Do not provide trading permissions unless you want to use the app to place orders
  • Provide a redirect_uri which is in your control rather than a public endpoint such as google.com
  • You should send a random value in the state parameter and verify whether the same value has been returned to you
  • For SPA or mobile apps, you should use PKCE flow
  • Do not store the app_secret in the front end. It should be securely kept without exposing it to third parties.

User

Profile

This allows you to fetch basic details of the client.

Response Attributes
Attribute Data Type Description
name string Name of the client
display_name string Display name, if any, provided by the client
fy_id string The client id of the fyers user
image string URL link to the user’s profile picture, if any.
email_id string Email address of the client
pan string PAN of the client
password_last_changed string Last password changed date
password_expiry_days int Number of days until the current password expires

Example request

Curl Request Method
curl -H "Authorization:app_id:access_token" https://api.fyers.in/api/v2/profile

Sample success response

{
  "s": "ok",
  "code": 200,
  "message": "",
  "data": {
            "name": "XASHXX G H",
            "image": "https://fyers-user-details.s3.amazonaws.com/image/FK6107548224?X-Amz-Algorithm=AWS4-HMAC",
            "display_name":"Y2K",
            "email_id":"xashxx.ghang@gmail.com",
            "PAN": "EXXXXXXXXE",
            "fy_id": "FX0011",
            "pwd_change_date": "19-08-2020 14:58:41",
            "pwd_to_expire": 42
          }
}

Funds

Shows the balance available for the user for capital as well as the commodity market.

Response Attributes
Attribute Data Type Description
id int Unique identity for particular fund
title string Each title represents a heading of the ledger
equityAmount float The amount in the capital ledger for the above-mentioned title
commodityAmount float The amount in the commodity ledger for the above-mentioned title

Example request

Curl Request Method
curl -H "Authorization:app_id:access_token"  https://api.fyers.in/api/v2/funds

Sample success response

{
  "s": "ok",
  "code": 200,
  "message": "",
  "fund_limit":
              [{
                "id":9,
                "title":"Limit at start of the day",
                "equityAmount":-132253.4,
                "commodityAmount": -37393.81
              },
              {
                "id":8,
                "title":"Adhoc Limit",
                "equityAmount": "0.0",
                "commodityAmount": "0.0"
              },
              {
                "id":7,
                "title":"Receivables",
                "equityAmount": "0.0",
                "commodityAmount": "0.0"
              },
              {
                "id":6,
                "title":"Fund Transfer",
                "equityAmount": "0.0",
                "commodityAmount": "100000.0"
              },
              {
                "id":5,
                "title":"Collaterals",
                "equityAmount": "0.0",
                "commodityAmount": "0.0"
              },
              {
                "id":4,
                "title":"Realized Profit and Loss",
                "equityAmount": "0.0",
                "commodityAmount": "0.0"
              },
              {
                "id":2,
                "title":"Utilized Amount",
                "equityAmount": "0.0",
                "commodityAmount": "0.0"
              },
              {
                "id":3,
                "title":"Clear Balance",
                "equityAmount": "0.0",
                "commodityAmount": "0.0"
              },
              {
                "id":3,
                "title":"Clear Balance",
                "equityAmount": "0.0",
                "commodityAmount": 62606.19
              },
              {
                "id":1,
                "title":"Total Balance",
                "equityAmount": -132253.4,
                "commodityAmount": 62606.19
              },
              {
                "id":10,
                "title":"Available Balance",
                "equityAmount": -132253.4,
                "commodityAmount": 62606.19
              },
              {
                "id":11,
                "title":"Available Balance",
                "equityAmount": "A",
                "commodityAmount": "M"
              },
              {
                "id":12,
                "title":"Available Balance",
                "equityAmount": "0.0",
                "commodityAmount": "0.0"
              }]
}

Holdings

Fetches the equity and mutual fund holdings which the user has in this demat account. This will include T1 and demat holdings.

Request Attributes - For each holding
Attribute Data Type Description
symbol string Eg: NSE:RCOM-EQ
holdingType string Identify the type of holding
View Details
quantity int The quantity of the symbol which the user has at the beginning of the day
remainingQuantity int This reflects the quantity - the quantity sold during the day
costPrice float The original buy price of the holding
marketVal float The Market value of the current holding
ltp float LTP is the price from which the next sale of the stocks happens
fytoken string Fytoken is a unique identifier for every symbol.
View Details
exchange int The exchange in which order is placed.
View Details
Response Attributes - Overall holdings
Attribute Data Type Description
count_total int Total number of holdings present
total_investment float Invested amount for the current holdings
total_current_value float The present value of the holdings
total_pl float Total profit and loss made
pnl_perc float Percentage value of the total pnl

Example request

Curl Request Method
curl -H "Authorization:app_id:access_token"  https://api.fyers.in/api/v2/holdings

Sample success response

{
  "s": "ok",
  "code": 200,
  "message": "",
  "holdings":
              [{
                "holdingType":"HLD",
                "quantity":1,
                "costPrice":1.55,
                "marketVal": 3.75,
                "remainingQuantity":1,
                "pl":2.2,
                "ltp":3.75,
                "id":1,
                "fyToken":101000000011460,
                "exchange":10,
                "symbol":"NSE:JPASSOCIAT-EQ"
              },
              {
                "holdingType":"HLD",
                "quantity":1,
                "costPrice":192.6,
                "marketVal": 149.70,
                "remainingQuantity":1,
                "pl":-42.9,
                "ltp":149.7,
                "id":2,
                "fyToken":10100000003812,
                "exchange":10,
                "symbol":"NSE:ZEEL-EQ"
              }],
     "overall":
              {
                "count_total":2,
                "total_investment":194.15,
                "total_current_value":153.45,
                "total_pl": -40.7,
                "pnl_perc":-10.48,
              }    
}

Transaction Info

Orders

Fetches all the orders placed by the user across all platforms and exchanges in the current trading day.

Response attributes - For each order
Attribute Data Type Description
id string The unique order id assigned for each order
exchOrdId string The order id provided by the exchange
symbol string The symbol for which order is placed
qty int The original order qty
remainingQuantity int The remaining qty
filledQty int The filled qty after partial trades
status int
  • 1 => Canceled
  • 2 => Traded / Filled
  • 3 => (Not used currently)
  • 4 => Transit
  • 5 => Rejected
  • 6 => Pending
  • 7 => Expired
  • View Details
    slNo int This is used to sort the orders based on the time
    message string The error messages are shown here
    segment int
    • 10 => E (Equity)
    • 11 => D (F&O)
    • 12 => C (Currency)
    • 20 => M (Commodity)
    • View Details
    limitPrice float The limit price for the order
    stopPrice float The limit price for the order
    productType string The product type
    type int
    • 1 => Limit Order
    • 2 => Market Order
    • 3 => Stop Order (SL-M)
    • 4 => Stoplimit Order (SL-L)
    side int
    disclosedQty int Disclosed quantity
    orderValidity string
    • DAY
    • IOC
    orderDateTime string The order time as per DD-MMM-YYYY hh:mm:ss in IST
    parentId string The parent order id will be provided only for applicable orders..
    Eg: BO Leg 2 & 3 and CO Leg 2
    tradedPrice float The average traded price for the order
    source string Source from where the order was placed.
    View Details
    fytoken string Fytoken is a unique identifier for every symbol.
    View Details
    offlineOrder string
    • False => When market is open
    • True => When placing AMO order
    pan string PAN of the client
    clientId string The client id of the fyers user
    exchange int The exchange in which order is placed
    View Details
    instrument int Exchange instrument type
    View Details

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token"  https://api.fyers.in/api/v2/orders

    Sample success response

    {
      "s": "ok",
      "code": 200,
      "message": "",
      "orderBook":
                  [{
                    "orderDateTime":"07-Aug-2020 13:43:08",
                    "id":"1200807100672",
                    "exchOrdId":"1300000010289593",
                    "side": 1,
                    "segment":10,
                    "instrument":0,
                    "productType":"CNC",
                    "status":2,
                    "qty":20,
                    "remainingQuantity":0,
                    "filledQty":20,
                    "limitPrice":0.0,
                    "stopPrice":0.0,
                    "type":2,
                    "discloseQty":0,
                    "dqQtyRem":0,
                    "orderValidity":"DAY",
                    "source":"W",
                    "slNo":1,
                    "fyToken":"101000000013188",
                    "offlineOrder":"False",
                    "message":"TRADE CONFIRMED",
                    "orderNumStatus":"1200807100672:2",
                    "tradedPrice":2.65,
                    "exchange":10,
                    "pan":"AXXXXXXXN",
                    "clientId":"FXXXXX",
                    "symbol":"NSE:RCOM-BE"
                  },
                  {
                    "orderDateTime":"07-Aug-2020 13:09:23",
                    "id":"120080789053",
                    "exchOrdId":"1300000009419529",
                    "side": 1,
                    "segment":10,
                    "instrument":0,
                    "productType":"INTRADAY",
                    "status":2,
                    "qty":1,
                    "remainingQuantity":0,
                    "filledQty":1,
                    "limitPrice":191.0,
                    "stopPrice":0.0,
                    "type":1,
                    "discloseQty":0,
                    "dqQtyRem":0,
                    "orderValidity":"DAY",
                    "source":"ITS",
                    "slNo":2,
                    "fyToken":"10100000003045",
                    "offlineOrder":"False",
                    "message":"TRADE CONFIRMED",
                    "orderNumStatus":"120080789053:2",
                    "tradedPrice":191.0,
                    "exchange":10,
                    "pan":"AXXXXXXXXN",
                    "clientId":"FXXXXX2",
                    "symbol":"NSE:SBIN-EQ",
                    "ch":0.65,
                    "chp":0.35,
                    "lp":185.25,
                    "ex_sym":"SBIN",
                    "description":"STATE BANK OF INDIA"
                  }]             
    }

    Order Filter / Order Status

    You can query for a particular order id by passing the id in the get parameters

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token"  https://api.fyers.in/api/v2/orders?id=sample_order_id

    Sample success response

    Positions

    Fetches the current open and closed positions for the current trading day. Note that previous trading day’s closed positions will not be shown here.

    Response attributes - For each position
    Attribute Data Type Description
    symbol string Eg: NSE:SBIN-EQ
    id string The unique value for each position
    buyAvg float Average buy price
    buyQty int Total buy qty
    sellAvg float Average sell price
    sellQty int Total sell qty
    netAvg float netAvg
    netQty int Net qty
    side int The side shows whether the position is long / short
    View Details
    qty int Absolute value of net qty
    productType string The product type of the position
    View Details
    realized_profit float The realized p&l of the position
    unrealized_profit float The unrealized p&l of the open position
    pl float The total p&l of the position
    crossCurrency string Y => It is cross currency position
    N => It is not a cross currency position
    rbiRefRate float Incase of cross currency position, the rbi reference rate will be required to calculate the p&l
    qtyMulti_com float Incase of commodity positions, this multiplier is required for p&l calculation
    segment int The segment in which the position is taken.
    View Details
    exchange int The exchange in which the position is taken.
    View Details
    slNo int This is used for sorting of positions
    ltp float LTP is the price from which the next sale of the stocks happens
    fytoken string Fytoken is a unique identifier for every symbol.
    View Details
    Response attributes - Overall Positions
    Attribute Data Type Description
    count_total int Total number of positions present
    count_open int Total number of positions opened
    pl_total float Total profit and losses
    pl_realized float Profit and losses when the owned product is sold
    pl_unrealized float Profit and loses when the product is owned , but is not sold

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token" https://api.fyers.in/api/v2/positions

    Sample success response

    {
      "s": "ok",
      "code": 200,
      "message": "",
      "netPositions":
                  [{
                    "netQty":1,
                    "qty":1,
                    "avgPrice":72256.0,
                    "netAvg": 71856.0,
                    "side":1,
                    "productType":"MARGIN",
                    "realized_profit":400.0,
                    "unrealized_profit":461.0,
                    "pl":861.0,
                    "ltp":72717.0,
                    "buyQty":2,
                    "buyAvg":72256.0,
                    "buyVal":144512.0,
                    "sellQty":1,
                    "sellAvg":72656.0,
                    "sellVal":72656.0,
                    "slNo":0,
                    "fyToken":"1120200831217406",
                    "dummy":"",
                    "crossCurrency":"N",
                    "rbiRefRate":1.0,
                    "qtyMulti_com":1.0,
                    "segment":20,
                    "symbol":"MCX:SILVERMIC20AUGFUT",
                    "id":"MCX:SILVERMIC20AUGFUT-MARGIN"
                  }],
       "overall":
                  {
                    "count_total":1,
                    "count_open":1,
                    "pl_total":861.0,
                    "pl_realized":400.0,
                    "pl_unrealized":461.0
                  }            
    }              

    Trades

    Fetches all the trades for the current day across all platforms and exchanges in the current trading day.

    Response attributes - For each trade
    Attribute Data Type Description
    symbol string Eg: NSE:SBIN-EQ
    id string The unique id to sort the trades
    orderDateTime string The time when the trade occured in “DD-MM-YYYY hh:mm:ss” format in IST
    orderNumber string The order id for which the trade occurred
    tradeNumber string The trade number generated by the exchange
    tradePrice float The traded price
    tradeValue float The total traded value
    tradedQty int The total traded qty
    side int
    productType string The product in which the order was placed
    View Details
    exchangeOrderNo string The order number provided by the exchange
    segment int The segment in which order is placed
    View Details
    exchange int The exchange in which order is placed
    View Details
    fyToken string Fytoken is a unique identifier for every symbol.

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token"  https://api.fyers.in/api/v2/tradebook

    Sample success response

    {
      "s": "ok",
      "code": 200,
      "message": "",
      "tradeBook":
                  [{
                    "clientId":"FXXXXX",
                    "orderDateTime":"07-Aug-2020 13:51:12",
                    "orderNumber":"120080789075",
                    "exchangeOrderNo": "1200000009204725",
                    "exchange":10,
                    "side":1,
                    "segment":10,
                    "orderType":2,
                    "fyToken":"101000000010666",
                    "productType":"CNC",
                    "tradedQty":10,
                    "tradePrice":32.7,
                    "tradeValue":327.0,
                    "tradeNumber":"52605023",
                    "id":"52605023",
                    "row":1,
                    "symbol":"NSE:PNB-EQ"
                  },
                  {
                    "clientId":"FXXXXX",
                    "orderDateTime":"07-Aug-2020 13:48:12",
                    "orderNumber":"120080789139",
                    "exchangeOrderNo": "1000000012031528",
                    "exchange":10,
                    "side":1,
                    "segment":10,
                    "orderType":2,
                    "fyToken":"101000000010454",
                    "productType":"CNC",
                    "tradedQty":19,
                    "tradePrice":14.1,
                    "tradeValue":267.9,
                    "tradeNumber":"3281523",
                    "id":"3281523",
                    "row":3,
                    "symbol":"NSE:CENTRUM-EQ"
                  },
                  {
                    "clientId":"FXXXXX1",
                    "orderDateTime":"07-Aug-2020 13:47:22",
                    "orderNumber":"120080797993",
                    "exchangeOrderNo": "1100000008047027",
                    "exchange":10,
                    "side":1,
                    "segment":10,
                    "orderType":2,
                    "fyToken":"101000000018783",
                    "productType":"CNC",
                    "tradedQty":4,
                    "tradePrice":115.5,
                    "tradeValue":462.0,
                    "tradeNumber":"27945307",
                    "id":"27945307",
                    "row":4,
                    "symbol":"NSE:IDFNIFTYET-EQ"
                  }]
    }

    Order Placement Guide

    The order placement process requires you to carefully input several parameters at the time of making the request. There are several validations which are required to be done before sending the request.

    Order Types

    • Limit Order
      • type = 1
      • stopPrice should be 0.
      • limitPrice is a mandatory input
    • Market Order
      • type = 2
      • limitPrice should be 0.
      • stopPriceshould be 0.
    • Stop Order / SL-M
      • type = 3
      • limitPrice should be 0.
      • stopPrice is a mandatory input
      • The stopPrice should not be higher than ltp for sell order and lower than ltp for buy order
    • Stop Limit Order/ SL-L
      • type = 4
      • limitPrice is a mandatory input
      • stopPrice field is a mandatory input
      • The stopPrice should not be higher than ltp for sell order and lower than ltp for buy order
        (The stopPrice should be lesser than ltp for sell order and stopPrice should be higher than ltp for buy order)
      • The stopPrice should be lesser than limit price for buy order and trigger price should be greater than limit price for sell order
        (The stopPrice should be greater than limit price for sell order and stopPrice should be lesser than limitPrice for buy order)

    Product Types

    • Intraday
      • Used to place orders which will be bought and sold the same day
      • Order type can be anything (Market, Limit, Stop and Stop Limit)
    • CNC
      • Used to place orders only in stocks which will be carried forward
      • Order type can be anything (Market, Limit, Stop and Stop Limit)
    • Margin
      • Used to place orders in derivative contracts which will be carried forward
      • Order type can be anything (Market, Limit, Stop and Stop Limit)
    • Cover Order (CO)
      • stopLoss is a mandatory input
      • stopLoss price is given in price denominated.
        • Eg: SBIN LTP = 300. Stop Loss given should be according to the price.
        • For the above example, for buy CO, stop loss can be 298
      • The order type can be either market or limit
        • If market order, then the stop loss price should not be higher than the ltp in buy and lower than the ltp for sell
        • If limit order, then the stop loss price should not be higher than the limit price in buy and lower than the limit for sell
      • Validity should be “DAY”.
      • Disclosed quantity should be 0.
    • Bracket Order (BO)
      • stopLoss is a mandatory input
      • takeProfit is a mandatory input
      • The stopLoss and takeProfit is denominated in rupees above and below the trade price.
      • Eg: SBIN LTP = 300. So the user can give a target of Rs. 10 and stop loss or Rs.5.
      • Order type can be either market, limit, stop or stop limit
      • Validity should be “DAY”.
      • Disclosed quantity should be 0

    Price Validations

    For all transaction requests (Order placement / modification), the price input should be in accordance with the exchange provided tick size for the particular symbol.

    • Tick size is applicable for all price inputs (Limit / stop / stopLoss / target)
    • Each symbol will have its own tick size
    • All price inputs have to be in multiples of the tick size
    • The tick size is available in the symbol master

    Quantity Validations

    For all transaction requests (Order placement / modification), the quantity input should be in accordance with the exchange provided minimum lot size.

    Segment Minimum Quantity Details
    Equities The quantity will be in multiples of 1
    Equity Derivatives The quantity will be in multiples of the lot size specified by the exchange
    Currency Derivatives The quantity will be in multiples of 1
    Commodity Derivatives The quantity will be in multiples of 1

    Order Placement

    Single Order

    This allows the user to place an order to any exchange via Fyers

    Request attributes
    Attribute Data Type Description
    symbol* string Eg: NSE:SBIN-EQ
    qty* int The quantity should be in multiples of lot size for derivatives.
    type* int
    1. 1 => Limit Order
    2. 2 => Market Order
    3. 3 => Stop Order (SL-M)
    4. 4 => Stoplimit Order (SL-L)
    5. View Details
    side* int
    1. 1 => Buy
    2. -1 => Sell
    3. View Details
    productType* string
    1. CNC => For equity only
    2. INTRADAY => Applicable for all segments.
    3. MARGIN => Applicable only for derivatives
    4. CO => Cover Order
    5. BO => Bracket Order
    6. View Details
    limitPrice* float Default => 0
    Provide valid price for Limit and Stoplimit orders
    stopPrice* float Default => 0
    Provide valid price for Stop and Stoplimit orders
    disclosedQty* int Default => 0
    Allowed only for Equity
    validity* string IOC => Immediate or Cancel
    DAY => Valid till the end of the day
    offlineOrder* string False => When market is open
    True => When placing AMO order
    stopLoss* float Default => 0
    Provide valid price for CO and BO orders
    takeProfit* float Default => 0
    Provide valid price for BO orders
    Response attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string Message to clarify the request status.
    Eg: Order submitted successfully.
    Your Order Ref. No.119062829763
    id string The order number of the placed order.
    Eg: 119031547242

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token" -H "Content-Type: application/json" -X  
    POST -d
    '{
      "symbol":"MCX:SILVERMIC20NOVFUT",
      "qty":1,
      "type":2,
      "side":1,
      "productType":"INTRADAY",
      "limitPrice":0,
      "stopPrice":0,
      "validity":"DAY",
      "disclosedQty":0,
      "offlineOrder":"False",
      "stopLoss":0,
      "takeProfit":0
      }' https://api.fyers.in/api/v2/orders

    Sample success response

    {
      "s": "ok",
      "code": 1101,
      "message": "Order submitted successfully. Your Order Ref. No.808058117761",
      "id":"808058117761"
    }

    Multi Orders

    You can place upto 10 orders simultaneously via the API.
    While Placing Multi orders you need to pass an ARRAY containing the orders request attributes

    Sample Request :

    [{ "symbol":"MCX:SILVERM20NOVFUT",
      "qty":1,
      "type":1,  
      "side":1, 
      "productType":"INTRADAY",   
      "limitPrice":61050,
      "stopPrice":0 ,
      "disclosedQty":0, 
      "validity":"DAY", 
      "offlineOrder":"False", 
      "stopLoss":0,  
      "takeProfit":0
    },
    {
      "symbol":"MCX:SILVERM20NOVFUT",
      "qty":1,
      "type":2,  
      "side":1, 
      "productType":"INTRADAY",   
      "limitPrice":61050,
      "stopPrice":0 ,
      "disclosedQty":0, 
      "validity":"DAY", 
      "offlineOrder":"False", 
      "stopLoss":0,  
      "takeProfit":0
    }]
    

    Example request

    Curl Request Method
    curl -H "Authorization:appId:access_token" -H "Content-Type: application/json" -X POST -d 
    '[{
      "symbol":"NSE:ITC-EQ",
      "qty":1,
      "type":1,
      "side":1,
      "productType":"INTRADAY",
      "limitPrice":165,
      "stopPrice":0,
      "disclosedQty":0,
      "validity":"DAY",
      "offlineOrder":"TRUE",
      "stopLoss":0,
      "takeProfit":0
      },
      {
        "symbol":"NSE:ITC-EQ",
        "qty":1,
        "type":1,
        "side":1,
        "productType":"INTRADAY",
        "limitPrice":165.10,
        "stopPrice":0,
        "disclosedQty":0,
        "validity":"DAY",
        "offlineOrder":"TRUE",
        "stopLoss":0,
        "takeProfit":0
      },
      {
        "symbol":"NSE:ITC-EQ",
        "qty":1,
        "type":1,
        "side":1,
        "productType":"INTRADAY",
        "limitPrice":165.10,
        "stopPrice":0,
        "disclosedQty":0,
        "validity":"DAY",
        "offlineOrder":"TRUE",
        "stopLoss":0,
        "takeProfit":0
      }]' https://api.fyers.in/api/v2/orders-multi

    Sample success response

      {
        "s": "ok",
        "code": 200,
        "message": "",
        "data": [{"statusCode": 200,
                  "body": {
                            "s": "ok",
                            "code": 200,
                            "message": "Order submitted successfully. 
                                        Your Order Ref. No. 120080778988",
                            "id": "120080778988"
                          },
                  "statusDescription": "HTTP OK"
                 },
                 {
                  "statusCode": 200,
                  "body": 
                          {
                            "s": "ok",
                            "code": 200,
                            "message": "Order submitted successfully. 
                                        Your Order Ref. No.120080777359",
                            "id": "120080777359"
                          },
                  "statusDescription": "HTTP OK"
                 },
                 {
                  "statusCode": 200,
                  "body": 
                          {
                            "s": "ok",
                            "code": 200,
                            "message": "Order submitted successfully. 
                                        Your Order Ref. No.120080777379",
                            "id": "120080777379"
                          }, "statusDescription": "HTTP OK"
                  }]
      }

    Other Transactions

    Modify Orders

    This allows the user to modify a pending order. User can provide parameters which needs to be modified. In case a particular parameter has not been provided, the original value will be considered.

    Request attributes
    Attribute Data Type Description
    id* string Mandatory.
    Eg: 119031547242
    limitPrice float Optional. Only incase of Limit/ Stoplimit orders
    stopLoss float Optional. Only incase of Stop/ Stoplimit orders
    qty int Optional. Incase you want to modify the quantity
    type int Optional. Incase you want to change the order type of the pending order
    Response attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string Message to clarify the request status.
    Eg: Successfully modified order
    id string The order number of the modified order
    Eg: 119031547242

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token" -H "Content-Type: application/json" -X PUT -d '{
              "id":809229222111,
              "qty":1,
              "type":2,
              "side":1,
              "limitPrice":61200
            }' https://api.fyers.in/api/v2/orders

    Sample success response

      {
        "s": "ok",
        "code": 1101,
        "message": "Successfully modified order', 'id': '808058117761"
      }

    Modify Multi Orders

    You can modify upto 10 orders simultaneously via the API.
    While Modifying Multi orders you need to pass an ARRAY containing the orders request attributes

    Sample Request :

     [{
        "id":orderId,
        "type":1,
        "limitPrice": 61049,
        "qty":1
      },
      {
        "id":orderId,
        "type":1,
        "limitPrice": 61049,
        "qty":1 
      }]
     

    Example request

    Sample success response

    Cancel Orders

    Cancel pending orders

    Request attributes
    Attribute Data Type Description
    id* string Mandatory.
    Eg: 119031547242
    Response attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string Message to clarify the request status.
    Eg: Successfully canceled order
    id string The order number of the canceled order.
    Eg: 119031547242

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token" -H "Content-Type: application/json" -X DELETE -d '{"id":"52009227353"}' https://api.fyers.in/api/v2/orders 

    Sample success response

      {
        "s": "ok",
        "code": 1103,
        "message": "Successfully cancelled order",
        "id": "808058117761"
      }

    Cancel Multi Orders

    You can cancel upto 10 orders simultaneously via the API.
    While cancelling Multi orders you need to pass an ARRAY containing the orders request attributes

    Sample Request :

     [{ 
       "id":orderId
      },
      {
        "id":orderId
     }]
    

    Sample success response

    Exit Positions

    This allows the user to either exit all open positions or any specific open position.

    Request attributes
    Attribute Data Type Description
    Id string In case id is not passed, then all the open positions will be closed
    Response attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string Message to clarify the request status.
    Eg:All positions are closed

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token" -H "Content-Type: application/json" -X DELETE -d '{}' https://api.fyers.in/api/v2/positions 

    Sample success response

      {
        "s": "ok",
        "code": 200,
        "message": "The position is closed."
      }

    Exit Position - By Id

    Request attributes
    Attribute Data Type Description
    id string Optional
    Eg: NSE:SBIN-EQ-BO
    This will only exit the open positions for a particular position id

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token" -H "Content-Type: application/json" -X DELETE -d '{"id":"NSE:SBIN-EQ-BO"}' https://api.fyers.in/api/v2/positions

    Sample success response

    Convert Positions

    This allows the user to convert an open position from one product type to another.

    Request attributes
    Attribute Data Type Description
    symbol* string Mandatory.
    Eg: 119031547242
    positionSide* int 1 => Open long positions
    -1 => Open short positions
    View Details
    convertQty* int Quantity to be converted. Has to be in multiples of lot size for derivatives
    convertFrom* string Existing productType
    (CNC positions cannot be converted)
    View Details
    convertTo* string The new product type
    View Details

    Notes

    1. CNC, CO and BO positions cannot be converted.
    2. You cannot convert positions to CO and BO
    Response attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    message string Message to clarify the request status.
    Eg: You cannot convert CNC position to INTRADAY / MARGIN.

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token" -H "Content-Type: application/json" -X PUT -d  
    
    {
      "symbol":"MCX:SILVERMIC20NOVFUT",
      "positionSide":1,
      "convertQty":1,
      "convertFrom":"INTRADAY",
      "convertTo":"CNC"
    }' https://api.fyers.in/api/v2/positions

    Sample success response

      {
        "s": "ok",
        "code": 200,
        "message": "Position Converted Successfully!!",
        "positionDetails": 1101
      }

    Broker Config

    Market Status

    Fetches the current market status of all the exchanges and their segments.

    Response attributes - For each exchange market segment
    Attribute Data Type Description
    exchange int The exchange in which the position is taken.
    View Details
    segment int The segment in which the position is taken.
    View Details
    market_type string NL => Normal Market
    MS => Morning Session
    ES => Evening Session
    status string CLOSE
    OPEN

    Example request

    Curl Request Method
    curl -H "Authorization:app_id:access_token" https://api.fyers.in/api/v2/market-status

    Sample success response

          {
            "s": "ok",
            "code": 200,
            "message": "",
            "marketStatus": [{
                                "exchange": 12,
                                "segment": 12,
                                "market_type": "OL",
                                "status": "OPEN"
                            },
                            {
                                "exchange": 12,
                                "segment": 12,
                                "market_type": "NL",
                                "status": "OPEN"
                            }]
          }

    Symbol Master

    You can get all the latest symbols of all the exchanges from the symbol master files

    • NSE – Currency Derivatives:
      http://public.fyers.in/sym_details/NSE_CD.csv
    • NSE – Equity Derivatives:
      http://public.fyers.in/sym_details/NSE_FO.csv
    • NSE – Capital Market:
      http://public.fyers.in/sym_details/NSE_CM.csv
    • MCX - Commodity:
      http://public.fyers.in/sym_details/MCX_COM.csv
    File Headers
    Attribute Data Type Description
    Fytoken string Unique token for each symbol
    View Details
    Symbol Details string Name of the symbol
    Exchange Instrument type int Exchange instrument type
    View Details
    Minimum lot size int Minimum qty multiplier
    Tick size float Minimum price multiplier
    ISIN string Unique ISIN provided by exchange for each symbol
    Trading Session string Trading session provided in IST
    Last update date date Date of last update
    Expiry date string Date of expiry for a symbol.Applicable only for derivative contracts
    Symbol ticker string Unique string to identify the symbol
    Exchange int Exchange mapping
    View Details
    Segment int Segment of the symbol
    View Details
    Scrip code int Token of the Exchange

    EDIS

    Electronic Delivery Instruction Slip or eDIS is a facility which allows you to sell shares when you have not submitted your Power of Attorney (POA). Please note: You can only sell the stocks you are holding in your linked Demat account. You may submit your POA to ensure a seamless trading experience.

    TPIN GENERATION

    TPIN is an authorization code generated by CDSL/NSDL respectively, using which the customer validates/authorises the transaction.

    Example request

    curl --location --request GET 'https://api.fyers.in/api/v2/tpin' 
    --header 'Authorization: app_id:access_token'

    Sample success response

    {"s": "ok", "code": 200, "message": "Successfully sent request for BO Tpin generation", "data": ""}

    DETAILS

    This Api Will provide the necessary information regarding the holdings you have on your and also the Status of the holdings. If the “sell” for the particular holdings is a success or not.

    Example request

    curl --location --request GET 'https://api.fyers.in/api/v2/details' \
    --header 'Authorization: app_id:access_token'

    Sample success response

     {"s": "ok", "code": 200, "message": "", "data": [{"clientId": "DXXXX4", "isin": "INE313D01013", "qty": 1.0, "qtyUtlize": 0.0, "entryDate": "07/06/2021 13:58:56", "startDate": "07/06/2021", "endDate": "07/06/2021", "noOfDays": 1, "source": "W", "status": "SUCCESS", "reason": "eDIS Transaction done successfully", "internalTxnId": "915485", "dpTxnId": "0706202171316317", "errCode": "NA", "errorCount": "0", "transactionId": "915484108176"}]

    INDEX

    This Api will provide you with the CDSL page to login where you can submit your Holdings information and accordingly you can provide the same to exchange to Sell your holdings.

    Example request

    curl --location --request POST 'https://api.fyers.in/api/dev/index' --header 'Authorization: app_id:accessToken' --header 'Content-Type: application/json' 
    --data-raw '{"recordLst": [{"isin_code": "INE313D01013", "qty": 1}]}'

    Sample success response

    {"s": "ok", "code": 200, "message": "", "data": "<table width=\"100%\"><tr><td><table align=\"center\"><tr><td><table  align=\"center\"><tr><th><img src=\"https://clib.fyers.in/fy_images/320x132.png\" alt=\"Fyers\" width=\"220\" /></th></tr><tr style=\"color:#7c7e7f;\"><th class=\"sansserif\">&nbsp; &nbsp; &nbsp; Free Investment Zone</th></tr></table></td></tr></table><table align=\"center\" bgcolor=\"#ffffff\"  style=\"Margin: 0 auto;max-width: 600px;min-width: 320px; border-style:solid;border-left-width:10px;padding:5px; border-color:#ffffff;\"><tr style=\"color:#3e4751;\"><th><img src=\"https://mockedis.cdslindia.com/images/CDSL-Logo.png\"></th> </tr><tr><th><hr  style=\" border:1px solid\" width=\"12%\"><br></th></tr><br><tr align=\"left\" style=\"color:#7c7e7f;\"><td class=\"sansserif\" id=\"tpinDescp\">As per new regulations, clients are required to authorise sell transactions by providing specific instrument details along with quantites at the CDSL portal prior to executing any sell transactions from their demat account.<br><br> The autorisation will be valid till the end of the day irrespective of whether you have completed the sell transaction or not. <br><br></td></tr><tr align=\"left\" style=\"color:#7c7e7f;\"><td class=\"sansserif\"><br></td></tr><tr align=\"left\" style=\"color:#7c7e7f;\"><td class=\"sansserif\" style=\"text-align:center\"><br><br>       <form name= \"frmDIS\" method = \"post\" action= \"https://eDIS.cdslindia.com/eDIS/VerifyDIS\" >        <input type= \"hidden\" name= \"DPId\" value= \"89400\" />        <input type= \"hidden\" name= \"ReqId\" value= \"917177108176\" />        <input type= \"hidden\" name= \"Version\" value= \"1.1\" />        <input type= \"hidden\" name= \"TransDtls\" value= \"LD9WAIJCL2jgSj1hY2DABqfayzA6iInmBvh9ub+Ftqy0P+V/Qy4kRf9dsBHElVwcDdAhTx5a6+9g3y/TcVh1zEdMbslVXAcMi913u+YwHNp5IWUS6XAOCAx9UY01XZ+OVAgAez/9m+7cP6TjOeOBCqw57MWZ1y5N6OsPyzh+ecLUD2e6G5hJMc/ZKRw1dl5FvzJGpfmr1MGpM5jwtpzpbksmAIiAUMyx+zqfT5dX27ZLp0P4MRCl/QNyLnMCNwbhoPx7TEp6fN23UD8T3Y1742Kb1mVz3b4Aw6Kt+maXsjM12jP2bHZuM+rYKkjQWBK+AejT3Uk9vAZmFbd+Y1xeqKJFXAoKRA+cQXiCp8gjpm6RaZ04p8V7MMTWrIhpKAXNCCpCb+suxO74mjfW18AfZMKxX0UK/JjVomEoHz0GaIAKq4z3KAfwwcpqhtcNZv8u68DyeMmCFwojJ0Y+SBLjwUlJV3SWqpYhBnXxni5YsmvOK5NQLfWxd+KjuWK4gXgONgxWIcPMWsjY++JkYwtAlAhI43khxe0Y0SjntmZTZ4A=\" />        <input type= \"submit\" value=\"Submit\">         </form></td></tr><tr><td style=\"text-align: center;\" class=\"like-anchor\"><div id=\"forgetTpinDiv\"><a href=\"#\" id=\"forgetTpin\" onclick=\"tpin()\">Forgot CDSL TPIN</a></div></td></tr></tbody></table></td></tr></tbody></table>"} 

    INQUIRY

    This Api is used to get the information/status of the provided transaction Id for the respective holdings you have on your end.

    Example request

    curl --location --request POST 'https://api.fyers.in/api/v2/inquiry' 
    --header 'Authorization: app_id:access_Token' --header 'Content-Type: application/json' --data-raw '{"transactionId": "915484108176"}'

    Sample success response

    {"s": "ok", "code": 200, "message": "", "data": {"FAILED_CNT": 0, "SUCEESS_CNT": 1}}

    Symbol Master

    You can get all the latest symbols of all the exchanges from the symbol master files

    • NSE – Currency Derivatives:
      http://public.fyers.in/sym_details/NSE_CD.csv
    • NSE – Equity Derivatives:
      http://public.fyers.in/sym_details/NSE_FO.csv
    • NSE – Capital Market:
      http://public.fyers.in/sym_details/NSE_CM.csv
    • MCX - Commodity:
      http://public.fyers.in/sym_details/MCX_COM.csv
    File Headers
    Attribute Data Type Description
    Fytoken string Unique token for each symbol
    View Details
    Symbol Details string Name of the symbol
    Exchange Instrument type int Exchange instrument type
    View Details
    Minimum lot size int Minimum qty multiplier
    Tick size float Minimum price multiplier
    ISIN string Unique ISIN provided by exchange for each symbol
    Trading Session string Trading session provided in IST
    Last update date date Date of last update
    Expiry date string Date of expiry for a symbol.Applicable only for derivative contracts
    Symbol ticker string Unique string to identify the symbol
    Exchange int Exchange mapping
    View Details
    Segment int Segment of the symbol
    View Details
    Scrip code int Token of the Exchange

    Data Api

    History

    The historical API provides archived data (up to date) for the symbols. across various exchanges within the given range. A historical record is presented in the form of a candle and the data is available in different resolutions like - minute, 10 minutes, 60 minutes...240 minutes and daily.

    Request attributes
    Attribute Data Type Description
    symbol* string Mandatory.
    Eg: NSE:SBIN-EQ
    resolution* string The candle resolution. Possible values are: Day : “D” or “1D”
    1 minute : “1”
    2 minute : “2"
    3 minute : "3"
    5 minute : "5"
    10 minute : "10"
    15 minute : "15"
    20 minute : "20"
    30 minute : "30"
    60 minute : "60"
    120 minute : "120"
    240 minute : "240"
    setDateFormat* int date_format is a boolean flag. 0 to enter the epoch value. Eg:670073472. 1 to enter the date format as yyyy-mm-dd.
    setRangeFrom* string Indicating the start date of records. Accepts epoch value if date_format flag is set to 0. Eg: range_from: 670073472
    Accepts yyyy-mm-dd format if date_format flag is set to 1. Eg: 2021-01-01
    setRangeTo* string Indicating the end date of records. Accepts epoch value if date_format flag is set to 0. Eg: range_to: 1622028732
    Accepts yyyy-mm-dd format if date_format flag is set to 1. Eg:2021-03-01
    setRangeTo* string Indicating the end date of records. Accepts epoch value if date_format flag is set to 0. Eg: range_to: 1622028732
    Accepts yyyy-mm-dd format if date_format flag is set to 1. Eg:2021-03-01
    Response attributes
    Attribute Data Type Description
    s string ok / error
    Candels array Candles data containing array of:
    1.Current epoch time
    2.Price during market opens
    3.Highest price for the day
    4.Lowest price for the day

    Example request

    curl --location --request GET 'https://api.fyers.in/data-rest/v2/history/?symbol=NSE:SBIN-EQ&resolution=30&date_format=1&range_from=2021-01-01&range_to=2021-01-02&cont_flag=' \
    --header 'Authorization:app_id:access_token’

    Sample success response

    Sample success response:-
    {
        "s": "ok",
        "candles": [
            [
                1621814400,
                417.0,
                419.2,
                405.3,
                412.05,
                142964052
            ],
            [
                1621900800,
                415.1,
                415.5,
                408.5,
                412.35,
                56048127
            ],
            [
                1621987200,
                413.8,
                418.75,
                410.8,
                413.55,
                52357719
            ],
            [
                1622073600,
                413.7,
                429.1,
                412.0,
                425.2,
                73392997
            ]
        ]
    }

    Quotes

    The Quotes API retrieves the full market quotes for one or more symbols provided by the user.

    Request attributes
    Attribute Data Type Description
    Symbol* string Maximum symbol limit is 50. Eg: NSE:SBIN-EQ.
    Response attributes
    Attribute Data Type Description
    s string ok / error
    ch float Change value
    chp float Percentage of change between the current value and the previous day's market close
    ip float Last traded price
    spread float Difference between lowest asking and highest bidding price
    ask float Asking price for the symbol
    bid float Bidding price for the symbol
    open_price float Price at market opening time
    high_price float Highest price for the day
    low_price float Lowest price for the day
    volume int Volume traded
    short_name string Short name for the symbol Eg: “SBIN-EQ”
    exchange string Name of the exchange. Eg: “NSE” or “BSE”
    description string Description of the symbol
    original_name string Original name of the symbol name provided by the use
    symbol string Symbol name provided by the user
    tt int Today’s time
    cmd dict Current time, open, high, low price and volume with HH:MM timestamp

    Example request

    curl --location --request GET 'https://api.fyers.in/data-rest/v2/quotes/?symbols=NSE:SBIN-EQ' \
    --header 'Authorization: app_id:access_token’

    Sample success response

    Sample success response:-
    
    {
        "s": "ok",
        "d": [
            {
                "n": "NSE:SBIN-EQ",
                "s": "ok",
                "v": {
                    "ch": 1.7,
                    "chp": 0.4,
                    "lp": 426.9,
                    "spread": 0.05,
                    "ask": 426.9,
                    "bid": 426.85,
                    "open_price": 430.5,
                    "high_price": 433.65,
                    "low_price": 423.6,
                    "prev_close_price": 425.2,
                    "volume": 38977242,
                    "short_name": "SBIN-EQ",
                    "exchange": "NSE",
                    "description": "NSE:SBIN-EQ",
                    "original_name": "NSE:SBIN-EQ",
                    "symbol": "NSE:SBIN-EQ",
                    "fyToken": "10100000003045",
                    "tt": 1622160000,
                    "cmd": {
                        "t": 1622184720,
                        "o": 426.85,
                        "h": 426.9,
                        "l": 426.85,
                        "c": 426.9,
                        "v": 3985,
                        "tf": "12:22"
    }
           }
    }
           ]
    }

    Market Depth

    The Market Depth API returns the complete market data of the symbol provided. It will include the quantity, OHLC values, and Open Interest fields, and bid/ask prices.

    Request attributes
    Attribute Data Type Description
    symbol* string Mandatory.
    Eg: NSE:SBIN-EQ'
    ohlcv_flag* int Set the ohlcv_flag to 1 to get open, high, low, closing and volume quantity'
    Response attributes
    Attribute Data Type Description
    s string ok / error
    code int This is the code to identify specific responses
    totalbuyqty int Total buying quantity
    totalsellqty int Total selling quantity
    bids array Bidding price along with volume and total number of orders
    ask array Offer price with volume and total number of orders
    o float Price at market opening time
    h float Highest price for the day
    i float Lowest price for the day
    c float Price at the of market closing
    chp float Percentage of change between the current value and the previous day's market close
    ch flot Change value
    itq int Last traded quantity
    itt int Last traded time
    ltp float Last traded price
    v int Volume traded
    atp float Average traded price
    lower_ckt float Lower circuit price`
    upper_ckt float upper circuit price
    expiry string Expiry date
    oiflag bool Boolean flag for OI data, true or false
    pdoi int
    oipercent float Change in open Interest percentage

    Example request

    curl --location --request GET 'https://api.fyers.in/data-rest/v2/depth/?symbol=NSE:SBIN-EQ&ohlcv_flag=1' \
    --header 'Authorization:app_id:access_token’

    Sample success response

    Sample success response:-
    
    {
        "s": "ok",
        "d": {
            "NSE:SBIN-EQ": {
                "totalbuyqty": 2396063,
                "totalsellqty": 4990001,
                "bids": [
                    {
                        "price": 427.25,
                        "volume": 4738,
                        "ord": 5
                    },
                    {
                        "price": 427.2,
                        "volume": 2631,
                        "ord": 9
                    },
                    {
                        "price": 427.15,
                        "volume": 6366,
                        "ord": 19
                    },
                    {
                        "price": 427.1,
                        "volume": 6344,
                        "ord": 18
                    },
                    {
                        "price": 427.05,
                        "volume": 8136,
                        "ord": 16
                    }
                ],
                "ask": [
                    {
                        "price": 427.4,
                        "volume": 2193,
                        "ord": 4
                    },
                    {
                        "price": 427.45,
                        "volume": 5406,
                        "ord": 19
                    },
                    {
                        "price": 427.5,
                        "volume": 15311,
                        "ord": 57
                    },
                    {
                        "price": 427.55,
                        "volume": 11170,
                        "ord": 17
                    },
                    {
                        "price": 427.6,
                        "volume": 7272,
                        "ord": 25
                    }
                ],
                "o": 430.5,
                "h": 433.65,
                "l": 423.6,
                "c": 425.2,
                "chp": 0.48,
                "ch": 2.05,
                "ltq": 20,
                "ltt": 1622184920,
                "ltp": 427.25,
                "v": 39163870,
                "atp": 428.07,
                "lower_ckt": 382.7,
                "upper_ckt": 467.7,
                "expiry": "",
                "oi": 0,
                "oiflag": false,
                "pdoi": 0,
                "oipercent": 0.0
            }
        },
        "message": ""

    WEBSOCKET

    Orders

               Returns individual order updates.
    

    Example request

    Sample success response

    Symbol

     
               Returns Symbol data for the specific symbol being mentioned.
    

    Example request

    Sample success response

    Truedata V2

    Introduction

    Fyers is offering market data APIs in collaboration with Truedata. The data APIs provide both real-time data as well as historical data.

    Truedata API Documentation

    You can download the entire Truedata API document here. This document will provide all the different functions which are available, sample requests and responses along with the Python sample code. You can also visit the official Python package on PyPi here

    Prerequisites

    Prerequisites to use Python Truedata Websocket library

    1. Python 3.7 or above
    2. pip install truedata_ws

    How to subscribe to Truedata from FYERS ?

    You can subscribe to the different Truedata subscription plans from here You can view your subscription status from here

    Appendix

    Fytoken

    Indicator Format Description
    Exchange 2 Digits Exchange of the symbol
    Segment 2 Digits Segment of the symbol
    Expiry 6 Digits Format: YYMMDD
    Eg: 200827
    Exchange Token From 2 upto 6 Digits The token assigned for the symbol by the exchange
    Eg: 22

    Exchanges

    Possible Values Description
    10 NSE (National Stock Exchange)
    11 MCX (Multi Commodity Exchange)
    12 BSE (Bombay Stock Exchange)

    Segments

    Possible Values Description
    10 Capital Market
    11 Equity Derivatives
    12 Currency Derivatives
    20 Commodity Derivatives

    Instrument Types

    Possible Values Description
    . CM segment
    0 EQ (EQUITY)
    1 PREFSHARES
    2 DEBENTURES
    3 WARRANTS
    4 MISC
    10 INDEX
    . FO segment
    11 FUTIDX
    12 FUTIVX
    13 FUTSTK
    14 OPTIDX
    15 OPTSTK
    . CD segment
    16 FUTCUR
    17 FUTIRT
    18 FUTIRC
    19 OPTCUR
    20 UNDCUR
    21 UNDIRC
    22 UNDIRT
    23 UNDIRD
    24 INDEX_CD
    25 FUTIRD
    . COM segment
    11 FUTIDX
    30 FUTCOM
    31 OPTFUT

    Symbology Format

    Segment Format Examples
    Equity {Ex}:{Ex_Symbol}-{Series} NSE:SBIN-EQ, NSE:ACC-EQ,
    NSE:MODIRUBBER-BE
    BSE:SBIN-A, BSE:ACC-A,
    BSE:MODIRUBBER-T
    Equity Futures {Ex}:{Ex_UnderlyingSymbol}{YY}{MMM}FUT NSE:NIFTY20OCTFUT,
    NSE:BANKNIFTY20NOVFUT
    Equity Options (Monthly Expiry) {Ex}:{Ex_UnderlyingSymbol}{YY}{MMM}{Strike}{Opt_Type} NSE:NIFTY20OCT11000CE,
    NSE:BANKNIFTY20NOV25000PE
    Equity Options (Monthly Expiry) {Ex}:{Ex_UnderlyingSymbol}{YY}{MMM}{Strike}{Opt_Type} NSE:NIFTY20OCT11000CE,
    NSE:BANKNIFTY20NOV25000PE
    Equity Options (Weekly Expiry) {Ex}:{Ex_UnderlyingSymbol}{YY}{M}{dd}{Strike}{Opt_Type} NSE:NIFTY20O0811000CE,
    NSE:BANKNIFTY20N0525000PE,
    NSE:NIFTY20D1025000CE
    Currency Futures {Ex}:{Ex_CurrencyPair}{YY}{MMM}FUT NSE:USDINR20OCTFUT,
    NSE:GBPINR20NOVFUT
    Currency Options (Monthly Expiry) Ex}:{Ex_CurrencyPair}{YY}{MMM}{Strike}{Opt_Type} NSE:USDINR20OCT75CE,
    NSE:GBPINR20NOV80.5PE
    Currency Options (Weekly Expiry) {Ex}:{Ex_CurrencyPair}{YY}{M}{dd}{Strike}{Opt_Type} NSE:USDINR20O0875CE,
    NSE:GBPINR20N0580.5PE
    NSE:USDINR20D1075CE
    Commodity Futures {Ex}:{Ex_Commodity}{YY}{MMM}FUT MCX:CRUDEOIL20OCTFUT,
    MCX:GOLD20DECFUT
    Commodity Options (Monthly Expiry) {Ex}:{Ex_Commodity}{YY}{MMM}{Strike}{Opt_Type} MCX:CRUDEOIL20OCT4000CE,
    MCX:GOLD20DEC40000PE

    Symbology Possible Values

    Variable Explanation Possible Values
    {Ex} This is the exchange on which the symbol is trading NSE, BSE, MCX
    {YY} This is the last 2 digits of the year 2019 will be 19
    2020 will be 2020
    2021 will be 21
    2022 will be 22
    {MMM} For monthly expiries such as futures and options,
    this value is the 3 characters of the month. The month
    will always be denoted in uppercase.
    JAN
    FEB
    MAR
    APR
    MAY
    JUN
    JUL
    AUG
    SEP
    OCT
    NOV
    DEC
    {M} For weekly expiries, this value represents the month
    of expiry but with only 1 character. This is a mix
    of numbers as well as characters.
    Jan => 1
    Feb => 2
    Mar => 3
    Apr => 4
    May => 5
    Jun => 6
    Jul => 7
    Aug => 8
    Sep => 9
    Oct => O (Letter)
    Nov => N
    Dec => D
    {dd} This is used in weekly expiries. This represents
    the date of the month on which the contract is
    going to expire. This value will always be 2 characters.
    01
    06
    10
    25
    30
    {Opt_Type} This represents whether the contract is call or put Call Option => CE,
    Put Option => PE
    {Strike} This is the strike price of the option contract 11000
    75.5
    80.75

    Product Types

    Possible Values Description
    CNC For equity only
    INTRADAY Applicable for all segments
    MARGIN Applicable only for derivatives
    CO Cover Order
    BO Bracket Order

    Order Types

    Possible Values Description
    1 Limit order
    2 Market order
    3 Stop order (SL-M)
    4 Stoplimit order (SL-L)

    Order Status

    Possible Values Description
    1 Cancelled
    2 Traded / Filled
    3 For future use
    4 Transit
    5 Rejected
    6 Pending

    Order Sides

    Possible Values Description
    1 Buy
    -1 Sell

    Position Sides

    Possible Values Description
    1 Long
    -1 Short
    0 Closed position

    Holding Types

    Possible Values Description
    T1 The shares are purchased but not yet delivered to the demat account.
    HLD The shares are purchased and are available in the demat account.

    Order Sources

    Possible Values Description
    M Mobile
    W Web
    R Fyers One
    A Admin
    ITS API

    Error codes and messages

    Please click on the following link to get an access to the API error code and message with their respective description

    Sample Code

    Postman Collection

    We have created an extensive Postman collection which will make it easier for implementation. Kindly import the postman_collection & postman_environment_variables

    • Download and import the postman collection from here
    • Download and import the postman environment variables from here
    • We have provided dummy data in the environment variables. Kindly update the correct values after you import it.

    Change Log

    Date Changes
    API Version 2
    • App Related
      • Introduced common apps for third party app developers
      • Different authentication methods such as OAuth2, PKCE and OIDC
      • Permission templates at the time of app creation
    • Authentication
      • Authentication flow has been changed to improve security
      • Authorization header value has been changed
    • Order placement
      • Multi order placement
      • Multi order modification
      • Multi order cancellation
    • Other
      • Market status API
    Show examples in:
    Fyers-logo
    API Docs V2