Pagination

The following section covers our upcoming approach on pagination. Please read carefully as this will impact your implementation from 31st July 2023

As we expand upon our Official Data Coverage across sports at IMG, we want our REST APIs to be as efficient and functional as they can be and as a result, we will be supporting pagination within our Seasons, Fixtures and Squads REST API. When you have a paginated API, it means that the results are split into separate pages, and users need to make multiple requests to get all the results. Each request retrieves a portion of the total results, and includes information about which page of results is being returned.

To consume this type of API and iterate over all the results, you can use a loop to make requests for each page of results. You start by making a request for the first page of results, and extract the data from that page. Then, you check to see if there are more pages of results to fetch. If there are, you make another request for the next page of results and repeat the process until you have retrieved all the results.

Once you have retrieved all the results, you can use them however you like, such as displaying them on a webpage or performing some sort of analysis on them.

From a technical point of view, here is a step by step guide

  1. Make an initial request to the API to get the first page of results using paged=true in the header (the default page return will be 20). For best results, please be sensible when using the page size parameter

  2. Extract the results from the response, and check if there are more pages to fetch. This can be done by checking the pageable metadata in the response, which includes the total number of pages and the current page number.

  3. If there are more pages to fetch, make subsequent requests to the API by incrementing the page number in the query parameters. For example, to fetch the next page, set page=1. Worth noting that page index starts at 0.

  4. Concatenate the results from all the pages into a single list.

Important Info and benefits:

  • If you run requests the same as before you will get the same behaviour (meaning getting the collection directly, not restricted to some page size). Downside here is that you have a lot of results, it can take time, and if you have a huge volume of results, if can either not work at all, or be truncated

  • If you run your requests with the header paged=true; you get a subset of your results, restricted to the number of entries of a page (default: 20, but you can choose in the request). Benefit here is that it is faster and reliable.

  • The endgame for IMGA is to get rid of the current method and return paginated results. Once the switch is done – the header value will be ignored, we’ll just be returning pages.

  • From 31st July 2023, (given there are only 2 matches on that day finishing at ~03:00), we are aiming to get all users migrated over to using paged=true and the current way will no longer be supported.

  • At present, pagination is not supported within the /actions or /statistics (not applicable), https REST API calls but we will work towards adding that to /actions and communicate in due course.

** Please be aware, the API will only return paginated results from the date specified below. We advise to add “paged=false” as soon as possible so that when we swop the default response over to paged, you won’t be caught off guard. Note this is only relevant for Soccer/Basketball/Volleyball (FIVB) & Snooker.

Last updated