Skip to content
Subhajit Sahu edited this page Sep 22, 2022 · 2 revisions

A Javascript interface for FYERS API {http}.
📦 Node.js, 🌐 Web, 📜 Files, 📰 Docs.

[FYERS] is one of the cheapest online stock brokers in India, that offers trading in the equity (NSE, BSE), currency (NSE), and commodity segments (MCX). The objective of this package is to provide a cleaner interface to FYERS API. This http namespace provides the same interface as FYERS HTTP API.

Global functions associated with FYERS API, such as getPositions(), are stateless and accept Authorization as the first parameter. Note that this authorization can be obtained be performing login with loginStep1() and loginStep2().

This package is available in both Node.js and Web formats. The web format is exposed as extra_fyers_http standalone variable and can be loaded from jsDelivr CDN.

This is part of package extra-fyers.
Stability: Experimental.


const {http} = require('extra-fyers');

async function main() {
  var app_id       = '****';  // app_id recieved after creating app
  var access_token = '****';  // access_token recieved after login
  var auth = {app_id, access_token};

  // List equity and commodity fund limits.
  console.log(await http.getFunds(auth));

  // List holdings.
  console.log(await http.getHoldings(auth));

  // Place CNC market order for SBIN (equity) on NSE for 5 shares
  var id = await http.placeOrder(auth, {
    symbol: 'NSE:SBIN-EQ',
    productType: "CNC",
    qty: 5,
    side: 1, // BUY
    type: 2, // MARKET
    offlineOrder: "False"
  });

  // List postions for today (should list NSE:SBIN-EQ-CNC).
  console.log(await http.getPositions(auth));
}
main();


Index

Property Description
API_URL Root URL for API requests.
DATA_URL Root URL for Data API requests.
SYMBOLS_URL Root URL for Symbol master files.
loginStep1 Get request step 1 for authorization (browser only).
loginStep2 Get request step 2 for authorization (browser, server).
getProfile Get basic details of the client.
getFunds Get balance available for the user for capital as well as the commodity market.
getHoldings Get the equity and mutual fund holdings which the user has in this demat account.
getOrder Get details of an order placed in the current trading day.
getOrders Get details of all the orders placed in the current trading day.
getPositions Get details of all the positions in the current trading day.
getTrades Get details of all the trades in the current trading day.
placeOrder Place an order to any exchange via Fyers.
placeOrders Place multiple orders to any exchange via Fyers.
modifyOrder Modify an order placed on any exchange via Fyers.
modifyOrders Modify orders placed on any exchange via Fyers.
cancelOrder Cancel an order placed on any exchange via Fyers.
cancelOrders Cancel orders placed on any exchange via Fyers.
exitPosition Exit a position on the current trading day.
exitAllPositions Exit all positions on the current trading day.
convertPosition Convert a position on the current trading day.
getMarketStatus Get the current market status of all the exchanges and their segments.
getMarketHistory Get the current market history for a particular symbol.
getMarketQuotes Get the current market quotes for a set of symbols.
getMarketDepth Get the current market depth for a particular symbol.
getSymbolMaster Get all the latest symbols of all the exchanges from the symbol master files.
generateEdisTpin Generate e-DIS TPIN for validating/authorising transaction.
getEdisTransactions Get 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.
submitEdisHoldingsStep Redirect to CDSL page for login where you can submit your Holdings information and accordingly you can provide the same to exchange to Sell your holdings (browser only).
inquireEdisTransaction Inquire the information/status of the provided transaction Id for the respective holdings you have on your end.


References



Clone this wiki locally