7.2 Retrieve Job History
Pagination of results is useful for endpoints that return a collection of objects, especially when the collection has large amounts of results. To help users work with pages of results, we improved the response body to be the following structure:
items (array[Object]): Items in this results page
limit (integer): limits how many items are returned by this call. Could set it to 10 to only retrieve 10 jobs at a time.
offset (integer): Offset of this results page
totalCount (integer): Total amount of items available
It is possible to hit the max number of responses allowed by the REST API. Currently, there are only 1000 responses allowed in one request. If you are retrieving your entire job history it is likely that is will be over 1000 responses.
So, we can use the offset to gather 1000 responses at a time. The offset starts from the newest and subtracts from the offset number. Let's say you have a busy server with 10,000 jobs and you wanted to retrieve the full job history. For the first call, you would want to set the limit to 1000 and the offset to 0. This will retrieve the newest 1000 jobs. The next call would have to set the limit to 1000 and the offset to 1000. This would retrieve the next newest 1000 jobs.
The next exercise demonstrates how you could retrieve job history and create an HTML report with the information.