# Financials Historical Data

> Use the following API endpoints to obtain historical data for financials.

Source: https://docs.tradingeconomics.com/financials/historical/

The historical endpoint contains a time series with an indicator identifier, category, fiscal calendar, the reference date, the report date, and the observed value. It allows one to check the evolution of key indicators over time.

## By symbol and category

**PYTHON**
*Using Requests:*
```python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/financials/historical/aapl:us:assets?c={your_api_key}'
data = requests.get(url).json()
print(data)
```
*Or using our package:*
```python
import tradingeconomics as te
te.login('your_api_key')
te.getFinancialsHistorical(symbol = 'aapl:us', category = 'assets')
```

**JS**
*Using Requests:*
```js
const axios = require('axios');
(async () => {
    const your_api_key = 'your_api_key'
    const response = await axios.get(`https://api.tradingeconomics.com/financials/historical/aapl:us:assets?c=${your_api_key}`)
    console.log(response.data)
})()
```
*Or using our package:*
```javascript
const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getFinancialsHistorical(symbol = 'aapl:us', category = 'assets' ).then(function(data){
  console.log(data)     
});
```

**C#**
*Using Requests:*
```c#
using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/financials/historical/aapl:us:assets?c=your_api_key"))
    {
        request.Headers.TryAddWithoutValidation("Upgrade-Insecure-Requests", "1");
        var response = await httpClient.SendAsync(request);
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync(); 
            Console.WriteLine(content);
        }
    }
}
```

*With multi symbols:*

**PYTHON**
*Using Requests:*
```python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/financials/historical/aapl:us:assets,msft:us:assets?c={your_api_key}'
data = requests.get(url).json()
print(data)
```
*Or using our package:*
```python
te.getFinancialsHistorical(symbol = ['aapl:us' , 'msft:us'], category = 'assets')
```

**JS**
*Using Requests:*
```js
const axios = require('axios');
(async () => {
    const your_api_key = 'your_api_key'
    const response = await axios.get(`https://api.tradingeconomics.com/financials/historical/aapl:us:assets,msft:us:assets?c=${your_api_key}`)
    console.log(response.data)
})()
```
*Or using our package:*
```javascript
data = te.getFinancialsHistorical(symbol = ['aapl:us', 'msft:us'],
 category = 'assets' ).then(function(data){
  console.log(data)     
});
```

**C#**
*Using Requests:*
```c#
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/financials/historical/aapl:us:assets,msft:us:assets?c=your_api_key");
```

The response data format can be configured by appending the **&f=** parameter to the URL request.

**JSON**
```text
https://api.tradingeconomics.com/financials/historical/{symbol:category}?c={your_api_key}&f=json
```
```json
[
  {
    "symbol": "aapl:us",
    "category": "assets",
    "date": "2009-12-31T00:00:00",
    "value": 53926.0,
    "reportDate": "2009-12-26T00:00:00",
    "reference": "FY2010Q1  "
  },
  {
    "symbol": "aapl:us",
    "category": "assets",
    "date": "2010-03-31T00:00:00",
    "value": 57057.0,
    "reportDate": "2010-03-27T00:00:00",
    "reference": "FY2010Q2  "
  },
  {
    "symbol": "aapl:us",
    "category": "assets",
    "date": "2010-06-30T00:00:00",
    "value": 64725.0,
    "reportDate": "2010-06-26T00:00:00",
    "reference": "FY2010Q3  "
  }
]
```

**CSV**
```text
https://api.tradingeconomics.com/financials/historical/{symbol:category}?c={your_api_key}&f=csv
```
```bash
aapl:us,assets,12/31/2009 12:00:00 AM,53926.0000,12/26/2009 12:00:00 AM,FY2010Q1  
aapl:us,assets,3/31/2010 12:00:00 AM,57057.0000,3/27/2010 12:00:00 AM,FY2010Q2  
aapl:us,assets,6/30/2010 12:00:00 AM,64725.0000,6/26/2010 12:00:00 AM,FY2010Q3  
```

**HTML**
```text
https://api.tradingeconomics.com/financials/historical/{symbol:category}?c={your_api_key}
```

| symbol | category | date | value | reportDate | reference |
|-------|-------|-------|-------|-------|-------|
| aapl:us | assets | 12/31/2009 12:00:00 AM | 53926.0000 | 12/26/2009 12:00:00 AM | FY2010Q1 |
| aapl:us | assets | 3/31/2010 12:00:00 AM | 57057.0000 | 3/27/2010 12:00:00 AM | FY2010Q2 |
| aapl:us | assets | 6/30/2010 12:00:00 AM | 64725.0000 | 6/26/2010 12:00:00 AM | FY2010Q3 |

## By symbol, category and date

**PYTHON**
*Using Requests:*
```python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/financials/historical/aapl:us:assets?d1=2022-01-01&d2=2023-01-01&c={your_api_key}'
data = requests.get(url).json()
print(data)
```
*Or using our package:*
```python
te.getFinancialsHistorical(symbol = 'aapl:us', category = 'assets',
 initDate = '2022-01-01', endDate ='2023-01-01')
```
<!-- 
```python
te.getFinancialsHistorical(symbol = ['aapl:us', 'tsla:us'], category = ['assets', 'debt'],
 initDate = '2022-01-01', endDate ='2023-01-01')
```
-->

**JS**
*Using Requests:*
```js
const axios = require('axios');
(async () => {
    const your_api_key = 'your_api_key'
    const response = await axios.get(`https://api.tradingeconomics.com/financials/historical/aapl:us:assets?d1=2022-01-01&d2=2023-01-01&c=${your_api_key}`)
    console.log(response.data)
})()
```
*Or using our package:*
```javascript
data = te.getFinancialsHistorical(symbol = 'aapl:us', category = 'assets',
 start_date = '2022-01-01', end_date = '2023-01-01').then(function(data){
  console.log(data)     
});
```
<!-- 
```javascript
data = te.getFinancialsHistorical(symbol = ['aapl:us', 'msft:us'], category = ['assets', 'debt'],
 start_date = '2022-01-01', end_date = '2023-01-01').then(function(data){
  console.log(data)     
});
```
-->

**C#**
*Using Requests:*
```c#
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/financials/historical/aapl:us:assets?d1=2022-01-01&d2=2023-01-01&c=your_api_key");
```

**JSON**
```text
https://api.tradingeconomics.com/financials/historical/{symbol:category}?c={your_api_key}&d1=yyyy-mm-dd&d2=yyyy-mm-dd&f=json
```
```json
[
  {
    "symbol": "aapl:us",
    "category": "assets",
    "date": "2022-03-31T00:00:00",
    "value": 350662.0,
    "reportDate": "2022-03-26T00:00:00",
    "reference": "FY2022Q2  "
  },
  {
    "symbol": "aapl:us",
    "category": "assets",
    "date": "2022-06-30T00:00:00",
    "value": 336309.0,
    "reportDate": "2022-06-25T00:00:00",
    "reference": "FY2022Q3  "
  },
  {
    "symbol": "aapl:us",
    "category": "assets",
    "date": "2022-09-30T00:00:00",
    "value": 352755.0,
    "reportDate": "2022-09-24T00:00:00",
    "reference": "FY2022Q4  "
  }
]
```

**CSV**
```text
https://api.tradingeconomics.com/financials/historical/{symbol:category}?c={your_api_key}&d1=yyyy-mm-dd&d2=yyyy-mm-dd&f=csv
```
```bash
aapl:us,assets,3/31/2022 12:00:00 AM,350662.0000,3/26/2022 12:00:00 AM,FY2022Q2  
aapl:us,assets,6/30/2022 12:00:00 AM,336309.0000,6/25/2022 12:00:00 AM,FY2022Q3  
aapl:us,assets,9/30/2022 12:00:00 AM,352755.0000,9/24/2022 12:00:00 AM,FY2022Q4  
```

**HTML**
```text
https://api.tradingeconomics.com/financials/historical/{symbol:category}?c={your_api_key}&d1=yyyy-mm-dd&d2=yyyy-mm-dd
```

| symbol | category | date | value | reportDate | reference |
|-------|-------|-------|-------|-------|-------|
| aapl:us | assets | 3/31/2022 12:00:00 AM | 350662.0000 | 3/26/2022 12:00:00 AM | FY2022Q2 |
| aapl:us | assets | 6/30/2022 12:00:00 AM | 336309.0000 | 6/25/2022 12:00:00 AM | FY2022Q3 |
| aapl:us | assets | 9/30/2022 12:00:00 AM | 352755.0000 | 9/24/2022 12:00:00 AM | FY2022Q4 |

## Response fields

| Field     | Type   | Description                              | Example               |
| ----------| -------|------------------------------------------|-----------------------|
| Symbol    | string | Unique Trading Economics symbol identifying the company | "aapl:us"            |
| Category  | string | Financials category or indicator                        | "assets"             |
| Date      | string | Date of the financial record in UTC                     | "2009-12-31T00:00:00"|
| Value     | number | Reported value for the specified date                   | 53926.0000           |
| Report    | string | Official reporting date of the financial statement      | "2009-12-26T00:00:00"|
| Reference | string | Fiscal reference period identifier                      | "FY2010Q1"           |

