Skip to content

Orders

Glossary

param value Description
variety reg Regular Order
amo After Market Order
co Cover Order
order_type MARKET Market Order
LIMIT Limit Order
SL Stoploss order
SL-M Stoploss-market order
product CNC Cash & Carry for equity
NRML Normal for futures and options
MIS Margin Intraday Squareoff
MFT mft
validity DAY Regular order
IOC Immediate or Cancel

Order APIs

The order APIs let you place orders of different varities, modify and cancel pending orders, retrieve the daily order and more.

method path description
POST https://api.mstock.trade/openapi/typea/orders/{variety} Place a new order
PUT https://api.mstock.trade/openapi/typea/orders/regular/{OrderID} Modify a pending order
DELETE https://api.mstock.trade/openapi/typea/orders/regular/{OrderID} Cancel a pending order
POST https://api.mstock.trade/openapi/typea/orders/cancelall Cancel all pending order
GET https://api.mstock.trade/openapi/typea/orders View all the existing orders.
GET https://api.mstock.trade/openapi/typea/trades This endpoint returns a list of all trades generated upon the execution of orders for that day.
GET https://api.mstock.trade/openapi/typea/tradebook This endpoint returns the trade book with all executed trades.
GET https://api.mstock.trade/openapi/typea/order/details View the status of individual order

Order Placement

This endpoint allows users to place a regular trading order in the specified market. Users must provide relevant order details such as the trading symbol, exchange, transaction type, and other order specifics.

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: 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/orders/{variety}' \
    --header 'X-Mirae-Version: 1' \
    --header 'Authorization: token api_key:access_token \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'tradingsymbol=INFY' \
    --data-urlencode 'exchange=NSE' \
    --data-urlencode 'transaction_type=BUY' \
    --data-urlencode 'order_type=LIMIT' \
    --data-urlencode 'quantity=10' \
    --data-urlencode 'product=MIS' \
    --data-urlencode 'validity=DAY' \
    --data-urlencode 'price=1250'
import axios from 'axios';

const response = await axios.post(
'https://api.mstock.trade/openapi/typea/orders/{variety}',
new URLSearchParams({
    'tradingsymbol': 'INFY',
    'exchange': 'NSE',
    'transaction_type': 'BUY',
    'order_type': 'LIMIT',
    'quantity': '10',
    'product': 'MIS',
    'validity': 'DAY',
    'price': '1250'
}),
{
    headers: {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token'
    }
}
);
import requests

headers = {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token',
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'tradingsymbol': 'INFY',
    'exchange': 'NSE',
    'transaction_type': 'BUY',
    'order_type': 'LIMIT',
    'quantity': '10',
    'product': 'MIS',
    'validity': 'DAY',
    'price': '1250',
}

response = requests.post('https://api.mstock.trade/openapi/typea/orders/{variety}', headers=headers, data=data)
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/orders/{variety}"))
    .POST(BodyPublishers.ofString("tradingsymbol=INFY&exchange=NSE&transaction_type=BUY&order_type=LIMIT&quantity=10&product=MIS&validity=DAY&price=1250"))
    .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
variety string Variety of the order ( regular amo co)
tradingsymbol string Refer Trading Symbol in Tables
transaction_type string The trading side of transaction : BUY SELL
order_type string Order Type :MARKET LIMIT SL SL-M
quantity string Number of shares for the order
product string Product type CNC NRML MIS MTF
validity string Validity of Order DAY IOC
price string Price at which order is placed

Response Structure -

The response of the request will be based on authentication outcome.

  • Success (HTTP Status 200): On successful order placement, the server returns a JSON object containing the order ID and status
{
    "status": "success",
    "data": {
        "order_id": "1131241001100"
    }
}
  • Failure (HTTP Status 401): If the order fails due to invalid parameters, authentication issues, or other errors, 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 200): If market is closed or not connected to NSE then api will return an error message with below json format.
{
    "status": "error",
    "message": "System is not connected to NSE Equity market",
    "error_type": "InputException",
    "data": null
}
  • Failure (HTTP Status 400): 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
}

Order Modification

This endpoint allows users to update/modify an existing order by specifying the order ID and providing the updated order details.

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 --request PUT 'https://api.mstock.trade/openapi/typea/orders/regular/1000000000016050' \
--header 'X-Mirae-Version: 1' \
--header 'Authorization: token api_key:access_token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'order_type=LIMIT' \  
--data-urlencode 'quantity=5' \
--data-urlencode 'price=2000' \
--data-urlencode 'validity=DAY' \
--data-urlencode 'disclosed_quantity=0' \
--data-urlencode 'trigger_price=0'
import axios from 'axios';

const response = await axios.post(
'https://api.mstock.trade/openapi/typea/session/token',
new URLSearchParams({
    'api_key': 'ay3KxxxxxxxxxxkB/MAKg@@',
    'request_token': '123',
    'checksum': 'L'
}),
{
    headers: {
    'X-Mirae-Version': '1'
    }
}
);
import requests

headers = {
    'X-Mirae-Version': '1',
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'api_key': 'ay3KxxxxxxxxxxkB/MAKg@@',
    'request_token': '123',
    'checksum': 'L',
}

response = requests.post('https://api.mstock.trade/openapi/typea/session/token', headers=headers, data=data)
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/orders/regular/1000000000016050"))
    .PUT(BodyPublishers.ofString("order_type=LIMIT&quantity=5&price=2000&validity=DAY&disclosed_quantity=0&trigger_price=0"))
    .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());

Path Parameter -

Field Description
order_id The unique identifier of the order to be updated or modified

Request Body - The body of the request must be URL-encoded and include the following parameters:

Field Type Description
variety string Variety of the order ( regular amo co)
tradingsymbol string Refer Trading Symbol in Tables
order_type string Order Type :LIMIT MARKET SL SL-M
quantity string Number of shares for the order
price string Price at which order is placed
validity string Validity of Order DAY IOC
exchange string Validity of Order NSE BSE
trigger_price string Price at which the order is triggered, in case of SL SL-M
disclosed_quantity string Number of shares visible (Keep more than 30% of quantity)
transaction_type string The trading side of transaction : BUY SELL
product string Product type CNC MIS MTF NRML
modqty_remng string Remaining quantity

Request Response -

The response of the request will be based on authentication outcome.

  • Success (HTTP Status 200): On successful order update, the server returns a JSON object containing the order ID and status.
{
    "status": "success",
    "data": {
        "order_id": "1131241001100"
    }
}
  • Failure (HTTP Status 401): If the order fails due to invalid parameters, authentication issues, or other errors, 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 200): If orderid does not exist then server will return below json reponse.

{
    "status": "error",
    "message": "Order Does not Exsist.Need to refresh orderbook / relogin in application ",
    "error_type": "InputException",
    "data": null
}
- Failure (HTTP Status 400): 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
}

Order Cancellation

This endpoint allows users to delete an existing order specified by the order ID. Deleting an order will cancel the specified order.

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.

curl --location --request DELETE 'https://api.mstock.trade/openapi/typea/orders/regular/1161241001100' \
    --header 'X-Mirae-Version: 1' \
    --header 'Authorization: token api_key:access_token'
import axios from 'axios';

const response = await axios.delete('https://api.mstock.trade/openapi/typea/orders/regular/1161241001100', {
headers: {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token'
}
});
import requests

headers = {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token',
}

response = requests.delete('https://api.mstock.trade/openapi/typea/orders/regular/1161241001100', headers=headers)
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
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/orders/regular/1161241001100"))
    .DELETE()
    .setHeader("X-Mirae-Version", "1")
    .setHeader("Authorization", "token api_key:access_token")
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

Path Parameter -

Field Description
order_id The unique identifier of the order to be cancel.

Response Structure -

The response of the request will be based on authentication outcome.

  • Success (HTTP Status 200): On successful order deletion, the server returns a JSON object containing the order ID and status.
{
    "status": "success",
    "data": {
        "order_id": "1161241001100"
    }
}
  • Failure (HTTP Status 200): If orderid does not exist then server will return below json reponse.
{
    "status": "error",
    "message": "Order Does not Exsist.Need to refresh orderbook / relogin in application ",
    "error_type": "InputException",
    "data": null
}
  • Failure (HTTP Status 400): 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
}

Cancel All

This endpoint allows users to cancel all the orders at once.

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.

curl --location --request POST 'https://api.mstock.trade/openapi/typea/orders/cancelall' \
--header 'X-Mirae-Version: 1' \
--header 'Authorization: token api_key:access_token' \
import axios from 'axios';

const response = await axios.post(
'https://api.mstock.trade/openapi/typea/orders/cancelall',
'',
{
    headers: {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token'
    }
}
);
import requests

headers = {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token',
}

response = requests.post('https://api.mstock.trade/openapi/typea/orders/cancelall', headers=headers)
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
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/orders/cancelall"))
    .POST(HttpRequest.BodyPublishers.noBody())
    .setHeader("X-Mirae-Version", "1")
    .setHeader("Authorization", "token api_key:access_token")
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

Response Structure -

The response of the request will be based on authentication outcome.

  • Success (HTTP Status 200): On successful order deletion, the server returns a JSON object containing the order ID and status.

{
    "status": "success",
    "data": {
        "order_id": "1161241001100"
    }
}
- Failure (HTTP Status 200): If orderid does not exist then server will return below json reponse.

{
    "status": "error",
    "message": "Order Does not Exsist.Need to refresh orderbook / relogin in application ",
    "error_type": "InputException",
    "data": null
}
  • Failure (HTTP Status 400): 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
}

Order Book

This endpoint allows users to retrieve a list of their trading orders. Users can view all their existing orders.

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.

curl --location 'https://api.mstock.trade/openapi/typea/orders' \
    --header 'X-Mirae-Version: 1' \
    --header 'Authorization: token api_key:access_token'
import axios from 'axios';

const response = await axios.get('https://api.mstock.trade/openapi/typea/orders', {
headers: {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token'
}
});
import requests

headers = {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token',
}

response = requests.get('https://api.mstock.trade/openapi/typea/orders', headers=headers)
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
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/orders"))
    .GET()
    .setHeader("X-Mirae-Version", "1")
    .setHeader("Authorization", "token api_key:access_token")
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

Request Body - This endpoint does not require a request body or additional parameters in the query string for the retrieval of orders.

Response Structure -

The response of the request will be based on authentication outcome.

  • Success (HTTP Status 200): On successful order deletion, the server returns a JSON object containing the order ID and status.
{
    "status": "success",
    "data": [
        {
            "placed_by": "XXXXX",
            "order_id": "1151240930103",
            "exchange_order_id": "0",
            "parent_order_id": null,
            "status": "Rejected",
            "status_message": "RMS:1151240930103:NSE,EQUITY,1594,INFY,INTRADAY,,EQ,XXXX,B,10,I,1250.00000,FUND LIMIT INSUFFICIENT,AVAILABLE FUND=0,ADDITIONAL REQUIRED FUND=3125,CALCULATED MARGIN FOR ORDER=3125",
            "status_message_raw": null,
            "order_timestamp": "30-09-2024 15:45:46",
            "exchange_update_timestamp": null,
            "exchange_timestamp": null,
            "variety": null,
            "modified": "false",
            "exchange": "NSE",
            "tradingsymbol": "INFY",
            "instrument_token": 1594,
            "order_type": "LIMIT",
            "transaction_type": "BUY",
            "validity": "DAY",
            "product": "INTRADAY",
            "quantity": 10,
            "disclosed_quantity": 0,
            "price": 1250,
            "trigger_price": 0,
            "average_price": 0,
            "filled_quantity": 0,
            "pending_quantity": 0,
            "cancelled_quantity": 0,
            "market_protection": 0,
            "meta": {
                "demat_consent": "physical"
            },
            "tag": [],
            "guid": ""
        },
        {
            "placed_by": "XXXXX",
            "order_id": "1161240930100",
            "exchange_order_id": "0",
            "parent_order_id": null,
            "status": "Rejected",
            "status_message": "RMS:1161240930100:NSE,EQUITY,22,ACC,INTRADAY,,EQ,XXXXX,B,10,I,2320.39990,FUND LIMIT INSUFFICIENT,AVAILABLE FUND=0,ADDITIONAL REQUIRED FUND=5801,CALCULATED MARGIN FOR ORDER=5801",
            "status_message_raw": null,
            "order_timestamp": "30-09-2024 10:54:37",
            "exchange_update_timestamp": null,
            "exchange_timestamp": null,
            "variety": null,
            "modified": "false",
            "exchange": "NSE",
            "tradingsymbol": "ACC",
            "instrument_token": 22,
            "order_type": "MARKET",
            "transaction_type": "BUY",
            "validity": "DAY",
            "product": "INTRADAY",
            "quantity": 10,
            "disclosed_quantity": 0,
            "price": 0,
            "trigger_price": 0,
            "average_price": 0,
            "filled_quantity": 0,
            "pending_quantity": 0,
            "cancelled_quantity": 0,
            "market_protection": 0,
            "meta": {
                "demat_consent": "physical"
            },
            "tag": [],
            "guid": ""
        }
    ]
}
  • Failure (HTTP Status 400): If authentication fails, the server will return an error message
{
    "status": "error",
    "message": "Please provide valid api version.",
    "error_type": "VersionException",
    "data": null
}

Trade Book

This endpoint returns the trade book with all executed trades.

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
curl --location 'https://api.mstock.trade/openapi/typea/tradebook' \
--header 'X-Mirae-Version: 1' \
--header 'Authorization: token api_key:access_token'
import axios from 'axios';

const response = await axios.get('https://api.mstock.trade/openapi/typea/tradebook', {
headers: {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token'
}
});
import requests

headers = {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token',
}

response = requests.get('https://api.mstock.trade/openapi/typea/tradebook', headers=headers)
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
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/tradebook"))
    .GET()
    .setHeader("X-Mirae-Version", "1")
    .setHeader("Authorization", "token api_key:access_token")
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

Request Body - This endpoint does not require a request body or additional parameters in the query string.

Response Structure -

The response of the request will be based on authentication outcome.

  • Success (HTTP Status 200): On successful request, the server returns a JSON object containing the trade book data.
{
  "status": "success",   
  "data": [
    {
      "ALGO_ID": "0",    
      "BUY_SELL": "Sell",
      "CLIENT_ID": "MA68XXXXX",
      "ENCASH_FLG": "N",
      "EXCHANGE": "NSE",
      "EXCH_ORDER_NUMBER": "1100000048872942",
      "EXPIRY_DATE": "0",
      "FULL_SYMBOL": "VODAFONE IDEA LIMITED",
      "GTC_FLG": "N",
      "INSTRUMENT_NAME": "EQUITY",
      "MKT_PROTECT_FLG": "N",
      "MKT_PROTECT_VAL": 0,
      "MKT_TYPE": "NL",
      "OPT_TYPE": "XX",
      "ORDER_DATE_TIME": "10-06-2025 13:08:42",
      "ORDER_NUMBER": "21612506101476",
      "ORDER_TYPE": "MARKET",
      "PAN_NO": "BYYPXXXXXX",
      "PARTICIPANT_TYPE": "B",
      "PRICE": 6.98,
      "PRODUCT": "CNC",
      "QUANTITY": 4,
      "R": 1,
      "REMARKS1": "NA",
      "REMARKS2": "NA",
      "SEC_ID": "14366",
      "SEGMENT": "E",
      "SETTLOR": "90144",
      "SOURCE_FLG": "WEB",
      "STRIKE_PRICE": 0,
      "SYMBOL": "IDEA",
      "TRADE_NUMBER": "206465040",
      "TRADE_VALUE": 27.92
    },
    {
      "ALGO_ID": "0",
      "BUY_SELL": "Buy",
      "CLIENT_ID": "MA68XXXXX",
      "ENCASH_FLG": "N",
      "EXCHANGE": "NSE",
      "EXCH_ORDER_NUMBER": "1100000045177810",
      "EXPIRY_DATE": "0",
      "FULL_SYMBOL": "VODAFONE IDEA LIMITED",
      "GTC_FLG": "N",
      "INSTRUMENT_NAME": "EQUITY",
      "MKT_PROTECT_FLG": "N",
      "MKT_PROTECT_VAL": 0,
      "MKT_TYPE": "NL",
      "OPT_TYPE": "XX",
      "ORDER_DATE_TIME": "10-06-2025 12:43:56",
      "ORDER_NUMBER": "21612506101398",
      "ORDER_TYPE": "MARKET",
      "PAN_NO": "BYYPXXXXXX",
      "PARTICIPANT_TYPE": "B",
      "PRICE": 6.99,
      "PRODUCT": "CNC",
      "QUANTITY": 1,
      "R": 2,
      "REMARKS1": "NA",
      "REMARKS2": "NA",
      "SEC_ID": "14366",
      "SEGMENT": "E",
      "SETTLOR": "90144",
      "SOURCE_FLG": "WEB",
      "STRIKE_PRICE": 0,
      "SYMBOL": "IDEA",
      "TRADE_NUMBER": "205988815",
      "TRADE_VALUE": 6.99
    }
  ]
}
  • Failure (HTTP Status 400): 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
}

Trade History

While an orders is sent as single entry but, it may get executed in arbitrary chunks at the exchange level. This endpoint returns a list of all trades generated upon the execution of orders for that day.

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 --request GET 'https://api.mstock.trade/openapi/typea/trades' \
    --header 'X-Mirae-Version: 1' \
    --header 'Authorization: token api_key:access_token' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'fromdate=2024-01-06' \
    --data-urlencode 'todate=2025-01-07'
import axios from 'axios';

const response = await axios.get('https://api.mstock.trade/openapi/typea/trades', {
headers: {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token'
},
data: new URLSearchParams({
    'fromdate': '2024-01-06',
    'todate': '2025-01-07'
})
});
import requests

headers = {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token',
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'fromdate': '2024-01-06',
    'todate': '2025-01-07',
}

response = requests.get('https://api.mstock.trade/openapi/typea/trades', headers=headers, data=data)
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/trades"))
    .method("GET", BodyPublishers.ofString("fromdate=2024-01-06&todate=2025-01-07"))
    .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
fromdate string 2024-01-06
todate string 2025-01-07

Request Response -

The response of the request will be based on authentication outcome.

  • Success (HTTP Status 200): On successful order update, the server returns a JSON object containing the order ID and status.
{
    "status": "success",
    "data": [
        {
            "trade_id": "68346395",
            "order_id": "1300000040250500",
            "exchange": "NSE",
            "tradingsymbol": "RASHTRIYA CHEMICALS & FER",
            "instrument_token": 0,
            "product": "CNC",
            "average_price": 145.45,
            "quantity": 1,
            "exchange_order_id": "1300000040250500",
            "transaction_type": "SELL",
            "fill_timestamp": "14:48:23",
            "order_timestamp": "2024-02-14 14:48:23",
            "exchange_timestamp": "2024-02-14 14:48:23"
        },
        {
            "trade_id": "68334426",
            "order_id": "1300000040194885",
            "exchange": "NSE",
            "tradingsymbol": "RASHTRIYA CHEMICALS & FER",
            "instrument_token": 0,
            "product": "CNC",
            "average_price": 145.6,
            "quantity": 1,
            "exchange_order_id": "1300000040194885",
            "transaction_type": "BUY",
            "fill_timestamp": "14:47:53",
            "order_timestamp": "2024-02-14 14:47:53",
            "exchange_timestamp": "2024-02-14 14:47:53"
        }
    ]
}
  • Failure (HTTP Status 400): 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
}

Individual Order Details

This endpoint allows users to retrieve the status of individual order using the order id.

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/order/details' \
    --header 'X-Mirae-Version: 1' \
    --header 'Authorization: token api_key:access_token'\
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'order_no=1157250130101' \
    --data-urlencode 'segment=E'
import axios from 'axios';

const response = await axios.get(
'https://api.mstock.trade/openapi/typea/order/details',
new URLSearchParams({
    'order_no': '1157250130101',
    'segment': 'E'
}),
{
    headers: {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token'
    }
}
);
import requests

headers = {
    'X-Mirae-Version': '1',
    'Authorization': 'token api_key:access_token',
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'order_no': '1157250130101',
    'segment': 'E',
}

response = requests.get('https://api.mstock.trade/openapi/typea/order/details', headers=headers, data=data)
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/order/details"))
    .GET(BodyPublishers.ofString("order_no=1157250130101&segment=E"))
    .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 - This endpoint does not require a request body or additional parameters in the query string for the retrieval of orders.

Field Type Description
order_id string The unique identifier of the order for which details need to be retrieved.
segment string E (Equity) / D (Derivative)

Response Structure -

The response of the request will be based on authentication outcome.

  • Success (HTTP Status 200): On successful order deletion, the server returns a JSON object containing the order ID and status.

{
    "status": "success",
    "data": [
        {
            "average_price": 1950,
            "cancelled_quantity": 10,
            "disclosed_quantity": 0,
            "exchange": "NSE",
            "exchange_order_id": "1000000000016050",
            "exchange_timestamp": null,
            "filled_quantity": 10,
            "instrument_token": 0,
            "order_id": "1121250123103",
            "order_timestamp": "23-01-2025 02:55:55 PM",
            "order_type": "LIMIT",
            "parent_order_id": null,
            "pending_quantity": 10,
            "price": 1950,
            "product": "CNC",
            "quantity": 10,
            "status": "Triggered",
            "status_message": "STOPLOSS TRIGGER",
            "tag": null,
            "tradingsymbol": "ACC",
            "transaction_type": "SELL",
            "trigger_price": 0,
            "validity": "DAY",
            "variety": null,
            "modified": 0
        },
        {
            "average_price": 1950,
            "cancelled_quantity": 10,
            "disclosed_quantity": 0,
            "exchange": "NSE",
            "exchange_order_id": "1000000000016050",
            "exchange_timestamp": null,
            "filled_quantity": 10,
            "instrument_token": 0,
            "order_id": "1121250123103",
            "order_timestamp": "23-01-2025 02:55:55 PM",
            "order_type": "SL",
            "parent_order_id": null,
            "pending_quantity": 10,
            "price": 1950,
            "product": "CNC",
            "quantity": 10,
            "status": "Pending",
            "status_message": "CONFIRMED",
            "tag": null,
            "tradingsymbol": "ACC",
            "transaction_type": "SELL",
            "trigger_price": 1945,
            "validity": "DAY",
            "variety": null,
            "modified": 0
        }
    ]
}
- Failure (HTTP Status 200): If authentication fails, the server will return an error message

{
    "status": "error",
    "message": "Please provide valid api version.",
    "error_type": "VersionException",
    "data": null
}
- Failure (HTTP Status 400): 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
}