Get Trade History
The Trade History API provides users with access to their historical trade and transaction data, allowing them to retrieve details of orders executed through Upstox platform. This API enables various use cases, including reviewing past month's trade activity, maintaining records for compliance or analysis, and other potential use case.
NOTE
Currently this API will give you data only for last 3 financial years.
Header Parameters
Name | Required | Type | Description |
---|---|---|---|
Authorization | true | string | Requires the format Bearer access_token where access_token is obtained from the Token API. |
Accept | true | string | Defines the content format the client expects, which should be set to application/json . |
Query Parameters
Name | Required | Type | Description |
---|---|---|---|
segment | false | string | Segment for which data is requested can be from the following options, If not provide, will consider all the segment. EQ - Equity FO - Futures and Options COM - Commodity CD - Currency Derivatives MF - Mutual funds |
start_date | true | string | Date from which data needs to be fetched. it should be within the last 3 financial years. Date format: YYYY-mm-dd . |
end_date | true | string | Date till data needs to be fetched. it should be within the last 3 financial years. Date format: YYYY-mm-dd . |
page_number | true | integer | Page number, the pages are starting from 1. |
page_size | true | integer | Page size for pagination. |
Responses
- 200
- 4XX
Response Body
- EQ
- FO
- COM
- CD
- MF
{
"status": "success",
"data": [
{
"exchange": "NSE",
"segment": "EQ",
"option_type": "",
"quantity": 1,
"amount": 2252.35,
"trade_id": "75217259",
"trade_date": "2023-03-28",
"transaction_type": "BUY",
"scrip_name": "RELIANCE",
"strike_price": "0.0",
"expiry": "",
"price": 2252.35,
"isin": "INE002A01018",
"symbol": "RELIANCE",
"instrument_token": "NSE_EQ|INE002A01018"
}
],
"errors": null,
"meta_data": {
"page": {
"page_number": 1,
"page_size": 15,
"total_records": 15,
"total_pages": 1
}
}
}
{
"status": "success",
"data": [
{
"exchange": "NFO",
"segment": "FO",
"option_type": "CE",
"quantity": 25,
"amount": 15237.5,
"trade_id": "430927903",
"trade_date": "2023-03-31",
"transaction_type": "SELL",
"scrip_name": "BANKNIFTY",
"strike_price": "40000.0",
"expiry": "2023-04-06",
"price": 609.5,
"isin": "",
"symbol": "BANKNIFTY",
"instrument_token": ""
}
],
"errors": null,
"meta_data": {
"page": {
"page_number": 1,
"page_size": 15,
"total_records": 15,
"total_pages": 1
}
}
}
{
"status": "success",
"data": [
{
"exchange": "MCX",
"segment": "COM",
"option_type": "",
"quantity": 2,
"amount": 721000,
"trade_id": "110116226",
"trade_date": "2023-03-31",
"transaction_type": "BUY",
"scrip_name": "SILVERM",
"strike_price": "0.0",
"expiry": "2023-04-28",
"price": 72100,
"isin": "",
"symbol": "",
"instrument_token": ""
}
],
"errors": null,
"meta_data": {
"page": {
"page_number": 1,
"page_size": 15,
"total_records": 15,
"total_pages": 1
}
}
}
{
"status": "success",
"data": [
{
"exchange": "CDS",
"segment": "CD",
"option_type": "CE",
"quantity": 1,
"amount": 385,
"trade_id": "420354",
"trade_date": "2023-03-27",
"transaction_type": "SELL",
"scrip_name": "USDINR",
"strike_price": "82.0",
"expiry": "2023-03-28",
"price": 0.385,
"isin": "",
"symbol": "",
"instrument_token": ""
}
],
"errors": null,
"meta_data": {
"page": {
"page_number": 1,
"page_size": 15,
"total_records": 15,
"total_pages": 1
}
}
}
{
"status": "success",
"data": [
{
"exchange": "BMF",
"segment": "MF",
"option_type": "",
"quantity": 13,
"amount": 999.9852,
"trade_id": "",
"trade_date": "2023-02-09",
"transaction_type": "BUY",
"scrip_name": "AXIS SMALL CAP FUND - DIRECT P",
"strike_price": "0.0",
"expiry": "",
"price": 71.9,
"isin": "INF846K01K35",
"symbol": "",
"instrument_token": "BMF_MF|INF846K01K35"
}
],
"errors": null,
"meta_data": {
"page": {
"page_number": 1,
"page_size": 15,
"total_records": 15,
"total_pages": 1
}
}
}
Name | Type | Description |
---|---|---|
status | string | A string indicating the outcome of the request. Typically success for successful operations. |
data | object[] | Response data for historical trade reports |
data[].exchange | string | Exchange to which the order is associated. Valid exchanges can be found in the Exchange Appendix |
data[].segment | string | Segment to which the order is associated. Possible values: EQ , FO , CD , COM , MF . |
data[].option_type | string | Option type of the option contracts. Possible values: CE , PE . Option type is available only in case of FO and CD segment. |
data[].quantity | integer | Quantity with which the order was placed. |
data[].amount | float | Total amount at which order is bought/sold. |
data[].trade_id | string | Trade ID generated from exchange towards traded transaction |
data[].trade_date | string | The date on which the order was bought/sold |
data[].transaction_type | string | Indicates whether its a buy or sell order. Possible values: BUY , SELL . |
data[].scrip_name | string | Name of the scrip traded |
data[].strike_price | float | The strike price for the option. |
data[].expiry | string | Expiry date (for derivatives). Data format is YYYY-mm-dd . |
data[].price | float | Price at which the traded quantity is traded. |
data[].isin | string | This represents the standard ISIN for stocks listed on multiple exchanges. ISIN is available in case of EQ and MF segment. |
data[].symbol | string | Shows the trading symbol of the instrument. Symbol is available in case of EQ and FO segment. |
data[].instrument_token | string | Key of the instrument. For the regex pattern applicable to this field, see the Field Pattern Appendix. Instrument token is available in case of EQ and MF segment. |
metadata | object | Meta data for historical trade data |
metadata.page | object | Meta data for page. |
metadata.page.page_number | integer | Page number for pagination |
metadata.page.page_size | integer | Page size |
Error codes
Error code | Description |
---|---|
UDAPI1066 | The segment is invalid - The provided segment value isn't recognized or accepted. |
UDAPI1091 | The page_number is required - You need to specify the page number for the data you're trying to retrieve. |
UDAPI1092 | The page_size is required - The page size, indicating the number of results per page, must be provided. |
UDAPI1093 | The start_date and end_date exceed the financial year limit. - Ensure your date ranges lies within the last 3 financial years. |
UDAPI1094 | end_date must be greater than or equal to start_date and Date should be in valid format: yyyy-MM-dd - Ensure your date ranges and formats are correct. |
UDAPI1120 | The page_size should be greater than or equal to 1: page_size must be at least 1 |
UDAPI1121 | The page_size should be less than or equal to 5000: page_size must be no more than 5000 |
UDAPI1122 | The page_number should be greater than or equal to 1: page_number must be at least 1 |
Examples
A comprehensive set of examples is provided to illustrate various use cases and implementation scenarios for this API. To view detailed examples and access sample code, please refer to: API Examples.
Loading...