The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Hi Roger,
All responses from Canvas are paginated. The default page size is 10 entries.
The API documentation on pagination isn't great: Pagination - Canvas LMS REST API Documentation
You can use the ?per_page parameter to set a larger page (e.g. api/v1/accounts/account_id/courses?per_page=100) but you can't just set this a huge number and be sure you'll get all your classes.
You need to find a way in your chosen language to make repeated requests until you've retrieved all the pages.
Here's a Python3 function I use (the editor has stripped indents)...
def get_courselist():
courses = []
pagesize = 10
queryterms="?per_page="+str(pagesize)+"&&exclude_blueprint_courses=true"
uri = 'https://awsacademy.instructure.com/api/v1/courses'+queryterms
r = requests.get(uri, headers=headers)
raw = r.json()
for course in raw:
courses.append(course)
while r.links['current']['url'] != r.links['last']['url']:
r = requests.get(r.links['next']['url'], headers=headers)
raw = r.json()
for course in raw:
courses.append(course)
return courses
I'm sure there are neater ways, I'm no programmer.
Another 'gotcha' I found - It only reports courses for the requesting user. This means if you created the API keys as bob@example.com then you'll only see courses with bob enrolled (in any role).
I've posted a question on this forum asking for a work around for that particular problem.
It sounds like you could benefit from this document: Canvas APIs: Getting started, the practical ins and outs, gotchas, tips, and tricks
Pagination and Masquerading are two things that often draw questions from new developers. They also have their own pages in the Basics section of the Canvas LMS API documentation.
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.