Skip to main content

This is an important tutorial for people wanting to use stockseyes API for getting live stock quotes.

In this tutorial, we will be doing the following steps to help you understand the required APIs.

  • Case 1: We already know tradingSymbol and exchange
    • We will directly get the current quote for the instrument.
  • Case2: We don't know much about the instrument we want to look for
    • Search for Instruments we are interested in.
    • Get the current quote for instruments of our interest.

CASE 1

Get Current Quotes

Let's get the current quote (current market status) of Reliance. You can add any number of tradingSymbol and exchanges in instruments array in the request. If you want to know trading symbol and exchange, you can search here: Search Instruments

curl --location 'https://api.stockseyes.com/v1/public/quotes' \
--header 'Content-Type: application/json' \
--header 'Authorization: your-api-key' \
--data '{
"instruments": [
{
"trading_symbol": "RELIANCE",
"exchange": "NSE"
}
]
}'

Example Response:

{
"quotes": {
"738561": {
"instrumentToken": 738561,
"tradingSymbol": "RELIANCE",
"exchange": "NSE",
"volumeTradedToday": 0.0,
"lastTradedQuantity": 0.0,
"change": 0.0,
"oi": 0.0,
"sellQuantity": 0.0,
"lastPrice": 1204.7,
"buyQuantity": 0.0,
"ohlc": {
"open": 1241.1,
"high": 1245.45,
"low": 1193.15,
"close": 1248.7
},
"timestamp": "1970-01-21T09:53:21.58+05:30",
"averagePrice": 0.0,
"oiDayHigh": 0.0,
"oiDayLow": 0.0,
"depth": {
"buy": [
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
}
],
"sell": [
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
}
]
},
"lowerCircuitLimit": 1084.25,
"upperCircuitLimit": 1325.15
}
}
}

CASE 2

Search Instruments

Let's search instruments. For more details on search instruments. Visit later Search Instrument

To get all instrument list, visit: Get All Instruments

  • Let's search for Reliance of exchange NSE
curl --location 'https://api.stockseyes.com/v1/public/instruments/search' \
--header 'authorization: yourToken' \
--header 'Content-Type: application/json' \
--data '{
"filterRequest": {
"tradingsymbol": ["RELIANCE"],
"exchange": ["NSE"]
},
"searchPatterns": {},
"paginationDetails": {
"offset": 0,
"limit": 5
}
}'

Expected Response

Take a note of the instrument token here. We will fetch quote for reliance later

{
"totalCount": 1, // Total count of matching results according to our filters
"instruments": [
{
"instrument_token": 738561,
"exchange_token": "2885",
"tradingsymbol": "RELIANCE",
"name": "RELIANCE INDUSTRIES",
"last_price": "0",
"expiry": "",
"strike": "0",
"tick_size": "0.05",
"lot_size": "1",
"instrument_type": "EQ",
"segment": "NSE",
"exchange": "NSE"
}
]
}
  • Now let's search by pattern "REL". It will find all the stocks that contains "REL" word. Experiment with it, ypu can increase the limit parameter to get more results. Limit defines how many top matching results you want.
curl --location 'https://api.stockseyes.com/v1/public/instruments/search' \
--header 'authorization: your-api-key' \
--header 'Content-Type: application/json' \
--data '{
"filterRequest": {},
"searchPatterns": {
"tradingsymbol": "REL"
},
"paginationDetails": {
"offset": 0,
"limit": 5
}
}'

Expected Response

Here total count represents the number of matching results of which we request only 5 above in request.

{
"totalCount": 3748, // Total count of matching results according to our filters
"instruments": [
{
"instrument_token": 128083204,
"exchange_token": "500325",
"tradingsymbol": "RELIANCE",
"name": "RELIANCE INDUSTRIES",
"last_price": "0",
"expiry": "",
"strike": "0",
"tick_size": "0.05",
"lot_size": "1",
"instrument_type": "EQ",
"segment": "BSE",
"exchange": "BSE"
},
{
"instrument_token": 128099844,
"exchange_token": "500390",
"tradingsymbol": "RELINFRA",
"name": "RELIANCE INFRASTRUCTURE",
"last_price": "0",
"expiry": "",
"strike": "0",
"tick_size": "0.05",
"lot_size": "1",
"instrument_type": "EQ",
"segment": "BSE",
"exchange": "BSE"
},
{
"instrument_token": 128809476,
"exchange_token": "503162",
"tradingsymbol": "RELCHEMQ",
"name": "RELIANCE CHEMOTEX INDUSTRIES L",
"last_price": "0",
"expiry": "",
"strike": "0",
"tick_size": "0.05",
"lot_size": "1",
"instrument_type": "EQ",
"segment": "BSE",
"exchange": "BSE"
},
{
"instrument_token": 129111300,
"exchange_token": "504341",
"tradingsymbol": "RELTD",
"name": "RAVINDRA ENERGY",
"last_price": "0",
"expiry": "",
"strike": "0",
"tick_size": "0.05",
"lot_size": "1",
"instrument_type": "EQ",
"segment": "BSE",
"exchange": "BSE"
},
{
"instrument_token": 130998276,
"exchange_token": "511712",
"tradingsymbol": "RELICTEC",
"name": "RELIC TECHNOLOGIES",
"last_price": "0",
"expiry": "",
"strike": "0",
"tick_size": "0.01",
"lot_size": "1",
"instrument_type": "EQ",
"segment": "BSE",
"exchange": "BSE"
}
]
}

Get Current Quote

Let's get the current quote (current market status) of Reliance. I assume you have noted the instrument_token for Reliance as was pointed above in search instrument. You can give any number of comma separated instrumentIds in the request.

curl --location 'https://api.stockseyes.com/v1/public/quotes?instrumentIds=738561' \
--header 'accept: application/json' \
--header 'authorization: yourToken'

Expected Response:

{
"quotes": {
"738561": {
"volumeTradedToday": 0.0,
"lastTradedQuantity": 20.0,
"change": 0.0,
"oi": 0.0,
"sellQuantity": 0.0,
"lastPrice": 1205.3, // this is the current price of the stock
"buyQuantity": 0.0,
"ohlc": {
"open": 1224.0,
"high": 1239.5,
"low": 1201.5,
"close": 1205.3
},
"instrumentToken": 738561,
"timestamp": "1970-01-21T07:25:39.046+05:30",
"averagePrice": 0.0,
"oiDayHigh": 0.0,
"oiDayLow": 0.0,
"depth": {
"buy": [
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
}
],
"sell": [
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
},
{
"quantity": 0,
"price": 0.0,
"orders": null
}
]
},
"lowerCircuitLimit": 1084.8,
"upperCircuitLimit": 1325.8
}
}
}