Skip to content

Portfolio

Portfolio APIs

method path description
GET https://api.mstock.trade/openapi/typea/portfolio/holdings View all holdings

Holdings

This endpoint offers the users to retrieve all the list of holdings that contain the user's portfolio of long term equity delivery stocks.

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/portfolio/holdings' \
    --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/portfolio/holdings', {
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/portfolio/holdings', 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/portfolio/holdings"))
    .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 retrieval, the server returns a JSON array of client positions.

{
    "status": "success",
    "data": [
        {
            "tradingsymbol": "BANK OF MAHARASHTRA",
            "exchange": null,
            "instrument_token": 11377,
            "isin": "INE457A01014",
            "product": null,
            "price": 30,
            "quantity": 10,
            "used_quantity": 1,
            "t1_quantity": 0,
            "realised_quantity": 0,
            "authorised_quantity": 0,
            "authorised_date": null,
            "opening_quantity": 0,
            "collateral_quantity": 0,
            "collateral_type": null,
            "discrepancy": 0,
            "average_price": 30,
            "last_price": 84.7,
            "close_price": 51.1,
            "pnl": 0,
            "day_change": 0,
            "day_change_percentage": 0
        },
        {
            "tradingsymbol": "PSP PROJECTS LIMITED",
            "exchange": null,
            "instrument_token": 20877,
            "isin": "INE488V01015",
            "product": null,
            "price": 513.35,
            "quantity": 100,
            "used_quantity": 0,
            "t1_quantity": 0,
            "realised_quantity": 0,
            "authorised_quantity": 0,
            "authorised_date": null,
            "opening_quantity": 0,
            "collateral_quantity": 100,
            "collateral_type": null,
            "discrepancy": 0,
            "average_price": 513.35,
            "last_price": 774.75,
            "close_price": 659.95,
            "pnl": 0,
            "day_change": 0,
            "day_change_percentage": 0
        }
    ]
}
- Failure (HTTP Status 401): If authentication fails, the server will return an error message

{
    "status": "error",
    "message": "Invalid request. Please try again.",
    "error_type": "TokenException",
    "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
}