All Collections
API Guide
Getting historical data
Getting historical data

Explore how to adopt the &start_date, &end_date, and &outputsize parameters

Team avatar
Written by Team
Updated over a week ago

To search for a particular period in the instrument's history, start_date and end_date parameters should be the first tools to be used. However, there are some nuances to master this technique.


start_date

When using this parameter alone there would no effect unless the start_date > outputsize.

https://api.twelvedata.com/time_series?start_date=2020-05-06&outputsize=5&symbol=aapl&interval=1day&apikey=xxx

This request would return the most recent 5 records since the condition would be satisfied. However, if the start_date would be somewhere between the current day and the outputsize limit the truncation will take place.


end_date

This parameter sets the maximum possible datetime value for the time series.

https://api.twelvedata.com/time_series?end_date=2020-05-06&outputsize=5&symbol=aapl&interval=1day&apikey=xxx

In this scenario, the output would be the last five records [2020-05-05, 2020-05-04, 2020-05-01, 2020-04-30, 2020-04-29] and the number of rows is purely controlled by the outputsize parameter,


start_date and end_date

When used together these parameters define the lower and the upper boundaries of the response.

https://api.twelvedata.com/time_series?&start_date=2020-01-06&end_date=2020-05-06&symbol=aapl&interval=1day&apikey=xxx

Would return all the values between the dates. Notice, that the outpusize parameter has not been used because otherwise, it would limit the output.


General recommendations

  • The maximum number of data points that can be retrieved with one request is 5000.

  • Before going into production, make sure that you fully understand how these parameters work in edge cases.

Did this answer your question?