Skip to main content
All CollectionsAPI Guide
Getting historical data
Getting historical data

Learn how to use the `&start_date`, `&end_date`, and `&outputsize` parameters effectively.

Team avatar
Written by Team
Updated over 2 weeks ago

To search for a specific period in an instrument's history, start_date and end_date parameters are your primary tools. However, mastering this technique requires understanding a few key nuances.


start_date: Using this parameter alone has no effect unless start_date exceeds the range specified by outputsize.

Example:

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

This request will return the most recent 5 records, as the condition is met. However, if the start_date falls within the range between the current day and the outputsize limit, truncation will occur.


end_date: This parameter defines the maximum possible datetime value for the time series.

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

In this case, the output will include the last five records: [2020-05-05, 2020-05-04, 2020-05-01, 2020-04-30, 2020-04-29]. The number of rows is entirely determined by the outputsize parameter.


start_date and end_date: When used together, these parameters set the lower and upper boundaries for the response.

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

This request returns all values between the specified dates. Note that the outputsize parameter is omitted in this case; including it would restrict the output.


General Recommendations:

  • A maximum of 5,000 data points can be retrieved in a single request.

  • Before deploying to production, ensure a thorough understanding of how these parameters behave, particularly in edge cases.

Did this answer your question?