Skip to main content
All CollectionsAPI GuideHow to
How to get historical prices
How to get historical prices

Discover how to get the historical data across all instruments

Team avatar
Written by Team
Updated over 3 years ago

Through Twelve Data, you can also fetch the data of various intervals. Following time frames are supported: 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 8h, 1day, 1week, 1month.

At this stage it is important to find out:

  • Difference between intraday and daily intervals

  • What is the earliest available data date

  • Method to access historical prices

Intraday vs. Daily intervals

At Twelve Data all intervals can be divided into categories the intraday and the daily data. The main difference lies in the amount of historical data available.

Daily intervals include 1day, 1week, 1month and contain data for the complete history since the first trading date for most of the symbols.

Intraday intervals include 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 8h, 1day, 1week, 1month and contain data on average from a couple of months to a couple of years.

Earliest available date

To check the first available date you can use the /earliest_timestamp endpoint. You can a dedicated article about it here.

How to get the prices

Once, you know the first available date and you want to extract the according information, you can use two methods.

  1. Specify the number of records to be returned with the outputsize parameter. This is the simplest and the most efficient approach, however, the maximum value to be set is 5000.

  2. Filter data using start_date and end_date parameters. This gives great flexibility in manipulating the data but has some nuances such as the correct order of using the parameters, the "sliding window" approach, and a few others.

When requesting historical data the response time might increase, therefore try to get it once and update it later with the real-time data. We strongly recommend reading this comprehensive guide to master the technique of obtaining historical data.

Examples

First historical data for AAPL for EOD data

Minute by minute price for the entire day

Weekly prices for the last 9 months

Did this answer your question?