Skip to main content

Handling pagination

caution

This functionality might not be supported by every LMS. Use with caution.

Some of the LTI® Advantage services provide the LMSes and users with a standardized way of handling a large ammount of results through pagination. LTIAAS allows you to handle pagination easily through special fields in API requests and responses.

The pagination fields

If the results of a certain service API request are paginated, the response object will likely contain one or more of the following fields:

  • next - The URL of the next page of results;
  • prev - The URL of the previous page of results;
  • first - The URL of the first page of results;
  • last - The URL of the last page of results.
tip

Not every endpoint will return all of these fields. We detail expected fields in the guides for each specific service.

Utilizing pagination fields

After retrieving one of the pagination fields from the API response, you can then use that to perform another API call fetching that specific page of results.

Every endpoint that supports pagination will accept a url query parameter, which you can use to specify the page you want to fetch.

info

The value of the pagination fields need to be URL encoded to be safely sent as a query parameter.

// Building Ltik based API authentication header
const authorizationHeader = `LTIK-AUTH-V2 ${API_KEY}:${LTIK}`
const headers = { Authorization: authorizationHeader }
// Making /api/memberships GET request
const response = requests.get(`https://your.ltiaas.com/api/memberships`, { headers })
// Retrieving next pagination field
const nextPage = response['next']
// Making /api/memberships GET request for the next page
const url = encodeURIComponent(nextPage)
const nextPageResponse = requests.get(`https://your.ltiaas.com/api/memberships?url=${url}`, { headers })
// Retrieving next page members
const members = nextPageResponse['members']

Limiting results

Every endpoint that supports pagination will accept a limit query parameter, which you can use to specify the maximum number of results you want to fetch.

// Building Ltik based API authentication header
const authorizationHeader = `LTIK-AUTH-V2 ${API_KEY}:${LTIK}`
const headers = { Authorization: authorizationHeader }
// Making /api/memberships GET request
const limit = 10
const response = requests.get(`https://your.ltiaas.com/api/memberships?limit=${limit}`, { headers })
// Retrieving next page members
const members = response['members'] // Maximum of 10 results
info

Some LMSes will have a default number of maximum results per page, which you can override by specifying the limit query parameter.

All trademarks, logos, and service marks displayed on this website are the property of their respective owners. LTIAAS is a trademark of GatherAct, LLC, doing business as LTIAAS. Learning Tools Interoperability (LTI)® and LTI® are trademarks of 1EdTech Consortium, Inc. LTIAAS is not affiliated with, endorsed or sponsored by 1EdTech Consortium, Inc. or by any other owners of third-party trademarks used on this website. LTIAAS is not responsible for the content, quality, or accuracy of any websites linked to or from this website that are not owned by LTIAAS. If you have any questions or concerns about the use of any trademarks or content on this website, please contact us.