Top Gainers and Losers
Top Gainers and Losers API
| method | path | description |
|---|---|---|
| POST | https://api.mstock.trade/openapi/typea/losergainer | This endpoint allows users to retrieve top gainers and losers |
Top Gainer/Losers API
This endpoint allows users to retrieve list of top gainers and losers.
Request Headers -
-
X-Mirae-Version : Specifies the version of the API being used. In this case, it is set to 1.
-
Authorization : A token-based authentication header. The format is token api_key:access_token.
-
Content-Type : Indicated the media type of the resource. For this request, it is set to application/x-www-form-urlencoded, which is used for submiting form data.
curl --location 'https://api.mstock.trade/openapi/typea/losergainer' \
--header 'X-Mirae-Version: 1' \
--header 'Authorization: token api_key:access_token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'Exchange=1' \
--data-urlencode 'SecurityIdCode=13' \
--data-urlencode 'segment=1' \
--data-urlencode 'TypeFlag=G'
import axios from 'axios';
const response = await axios.post(
'https://api.mstock.trade/openapi/typea/losergainer',
{
'Exchange': '1',
'SecurityIdCode': '13',
'segment': '1',
'TypeFlag': 'G'
},
{
headers: {
'X-Mirae-Version': '1',
'Authorization': 'token api_key:access_token',
'Content-Type': 'application/x-www-form-urlencoded'
}
}
);
import http.client
import json
conn = http.client.HTTPConnection('api.mstock.trade')
headers = {
'X-Mirae-Version': '1',
'Authorization': 'token api_key:access_token',
'Content-Type': 'application/x-www-form-urlencoded',
}
json_data = {
'Exchange': '1',
'SecurityIdCode': '13',
'segment': '1',
'TypeFlag': 'G'
}
conn.request(
'POST',
'openapi/typea/losergainer',
json.dumps(json_data),
headers
)
response = conn.getresponse()
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NORMAL)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.mstock.trade/openapi/typea/losergainer"))
.POST(BodyPublishers.ofString("{\n \"Exchange\": \"1\",\n \"SecurityIdCode\": \"13\",\n \"segment\": \"1\",\n \"TypeFlag\": \"G\"}"))
.setHeader("X-Mirae-Version", "1")
.setHeader("Authorization", "token api_key:access_token")
.setHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request Body - The body of the request must be URL-encoded and include the following parameters:
| Field | Type | Description |
|---|---|---|
| Exchange | int | Exchange ID ( 1 = NSE, 4 = BSE ) |
| SecurityIdCode | int | Security ID Code (refer table below) |
| segment | int | Segment ID ( 1 = NSE, 2 = BSE ) |
| TypeFlag | string | Flag Type ( G = Gainers, L = Losers ) |
SecurityIdCode Values -
| SecurityIdCode | NSE Index Name | BSE Index Name |
|---|---|---|
| 0 | ALL | ALL |
| 1 | NSE NIFTY MIDCAP 150 | BSE BSEDSI |
| 2 | NSE NIFTY SMALLCAP 250 | BSE BSEEVI |
| 3 | NSE NIFTY SMALLCAP 100 | BSE BSELVI |
| 4 | NSE NIFTY MIDSMALLCAP 400 | BSE BSEMOI |
| 5 | NSE NIFTY100 EQUAL WEIGHT | BSE SENSEX |
| 6 | NSE NIFTY100 LOW VOLATILITY 30 | BSE BSEPBI |
| 7 | NSE NIFTY ALPHA 50 | BSE ESG100 |
| 8 | NSE NIFTY 50 | BSE LCTMCI |
| 9 | NSE NIFTY AUTO | BSE LMI250 |
| 10 | NSE NIFTY PVT BANK | BSE MID150 |
| 11 | NSE NIFTY MID LIQ 15 | BSE MSL400 |
| 12 | NSE NIFTY 100 | BSE MIDCAP |
| 13 | NSE NIFTY 200 | BSE BSE100 |
| 14 | NSE NIFTY 500 | BSE BSE200 |
| 15 | NSE NIFTY MIDCAP 50 | BSE BSE500 |
| 16 | NSE INDIA VIX | BSE AUTO |
| 17 | NSE NIFTY SMALLCAP 50 | BSE BANKEX |
| 18 | NSE NIFTY BANK | BSE BSE CD |
| 19 | NSE FINNIFTY | BSE BSE CG |
| 20 | NIFTY FMCG | BSE BSEFMC |
| 21 | NSE NIFTY IT | BSE BSE HC |
| 22 | NSE NIFTY MEDIA | BSE BSE IT |
| 23 | NSE NIFTY METAL | BSE METAL |
| 24 | NSE NIFTY PHARMA | BSE OILGAS |
| 25 | NSE NIFTY PSU BANK | BSE POWER |
| 26 | NSE NIFTY REALTY | BSE BSEPSU |
| 27 | NSE NIFTY100 LIQ 15 | BSE REALTY |
| 28 | NSE NIFTY MIDCAP 100 | BSE TECK |
| 29 | NSE NIFTY NEXT 50 | BSE BSEQUI |
| 30 | NSE NIFTY COMMODITIES | BSE SMLCAP |
| 31 | NSE NIFTY CONSUMPTION | BSE SNSX50 |
| 32 | NSE NIFTY PSE | BSE ALLCAP |
| 33 | NSE NIFTY ENERGY | BSE INFRA |
| 34 | NSE NIFTY INFRA | BSE CPSE |
| 35 | NSE NIFTY MNC | BSE MFG |
| 36 | NSE NIFTY CPSE | BSE UTILS |
| 37 | NSE NIFTY SERV SECTOR | BSE TELCOM |
| 38 | NSE NIFTY DIV OPPS 50 | BSE SMLSEL |
| 39 | NSE NIFTY GROWSECT 15 | BSE BASMTR |
| 40 | NSE NIFTY50 VALUE 20 | BSE ENERGY |
| 41 | NSE NIFTY100 QUALTY30 | BSE FIN |
| 42 | NSE NIFTY MID SELECT | BSE LRGCAP |
| 43 | NSE NIFTY TATA GROUP 25 PERCENT CAP | BSE MIDSEL |
| 44 | NSE NIFTY500 MULTICAP INDIA MANUFACTURING 50:30:20 | BSE CDGS |
| 45 | NSE NIFTY500 MULTICAP MANUFACTURING 50:30:20 | BSE INDSTR |
| 46 | NSE NIFTY MIDSMALL HEALTHCARE | BSE BHRT22 |
| 47 | NSE NIFTY INDIA DEFENCE | BSE GREENX |
| 48 | NSE NIFTY INDIA TOURISM | BSE BSEIPO |
| 49 | NSE NIFTY CAPITAL MARKETS | BSE SMEIPO |
| 50 | NSE NIFTY500 MOMENTUM 50 | BSE CARBON |
| 51 | NSE NIFTY MIDSMALLCAP400 MOMENTUM QUALITY 100 | BSE DFRGRI |
| 52 | NSE NIFTY SMALLCAP250 MOMENTUM QUALITY 100 | BSE SML250 |
| 53 | NSE NIFTY TOP 10 EQUAL WEIGHT | BSE SNXT50 |
| 54 | NSE NIFTY BHARAT BOND INDEX - APRIL 2025 | COMMODITIES |
| 55 | NSE NIFTY BHARAT BOND INDEX - APRIL 2030 | DOLLEX200 |
| 56 | NSE NIFTY BHARAT BOND INDEX - APRIL 2031 | SERVICES |
| 57 | NSE NIFTY BHARAT BOND INDEX - APRIL 2032 | |
| 58 | NSE NIFTY BHARAT BOND INDEX - APRIL 2033 | |
| 59 | NSE NIFTY CONSUMER DURABLES | |
| 60 | NSE NIFTY FINANCIAL SERVICES | |
| 61 | NSE NIFTY OIL AND GAS | |
| 62 | NSE NIFTY HEALTHCARE INDEX | |
| 63 | NSE NIFTY LARGEMIDCAP 250 |
Response Structure -
The response of the request will be based on authentication outcome.
- Success (HTTP Status 200): On successful request execution, server will return the below json formated data.
{
"status": true,
"data": [
{
"exchange": "NSE",
"segment": "E",
"security_id": 5258,
"ltp": 733.15,
"Pclose": 0,
"Open": 0,
"TickSize": 0.05,
"Multiplier": 1,
"per_month_change": 0,
"month_change": 0,
"Price1": 0,
"volume": 6211517,
"per_change": 6.33,
"change": 43.64999999999998,
"Price": 0,
"symbol_name": "INDUSIND BANK LIMITED",
"isin": "INE095A01012",
"instrument": "EQUITY",
"series": "EQ",
"lot_size": 1,
"expiry_date": "01-01-0001 00:00:00",
"strike_price": "",
"option_type": "",
"display_name": "INDUSIND BANK LIMITED",
"symbol": "INDUSINDBK",
"exchange_inst_name": "EQ",
"Message": "0"
},
{
"exchange": "NSE",
"segment": "E",
"security_id": 3456,
"ltp": 622.85,
"Pclose": 0,
"Open": 0,
"TickSize": 0.05,
"Multiplier": 1,
"per_month_change": 0,
"month_change": 0,
"Price1": 0,
"volume": 10527655,
"per_change": 4.67,
"change": 27.800000000000068,
"Price": 0,
"symbol_name": "TATA MOTORS LIMITED",
"isin": "INE155A01022",
"instrument": "EQUITY",
"series": "EQ",
"lot_size": 1,
"expiry_date": "01-01-0001 00:00:00",
"strike_price": "",
"option_type": "",
"display_name": "TATA MOTORS LIMITED",
"symbol": "TATAMOTORS",
"exchange_inst_name": "EQ",
"Message": "0"
}
]
}
- Failure (HTTP Status 400): If the request fails due to invalid parameters the server will return an error message with below json format.
{
"status": "error",
"message": "Invalid request. Please try again.",
"error_type": "InputException",
"data": null
}
- Failure (HTTP Status 401): If the request fails due to authentication issues the server will return an error message with below json format.
{
"status": "error",
"message": "Invalid request. Please try again.",
"error_type": "TokenException",
"data": null
}
- Failure (HTTP Status 403): If the API Key is Invalid or expired.
{
"status": "error",
"message": "API is suspended/expired for use. Please check your API subscription and try again.",
"error_type": "APIKeyException",
"data": null
}