FTX supports pagination on most REST API endpoints. Pagination allows you to specify the time range of data to be returned, which also enables you to retrieve more results than are returned by default. For most endpoints, this means that including the start_time and end_time query params will relax the max results per page to 5,000 items.

start_time represents the minimum time for the filter, and end_time represents the maximum time, and they are both inclusive (start_time <= {results} <= end_time. Both start_time and end_time are represented as UNIX timestamps in seconds (eg. 1658160880), but you can also optionally include sub-seconds after the decimal (eg. 1658160880.123456).

You can find sample Python code which demonstrates pagination using the start_time and end_time parameters on our GitHub here.

Below is a brief example from our Python client of using the start_time and end_time parameters to loop through and collect a set larger than the per page limit. Imagine that you want to retrieve the set of trades for a particular market between start_time and end_time, but there are 20,000 results. To do so, you can fetch pages in a loop, and move the end_time closer to the start_time while merging results along the way until you run out of pages. You will know you have reached the last page of results, because the item count will be less than the page size at that point:

    def get_all_trades(self, market: str, start_time: float = None, end_time: float = None) -> List:
        ids = set()
        limit = 5000
        results = []
        while True:
            response = self._get(f'markets/{market}/trades', {
                'end_time': end_time,
                'start_time': start_time,
            deduped_trades = [r for r in response if r['id'] not in ids]
            ids |= {r['id'] for r in deduped_trades}
            print(f'Adding {len(response)} trades with end time {end_time}')
            if len(response) == 0:
            end_time = min(parse_datetime(t['time']) for t in response).timestamp()
            if len(response) < limit:
        return results