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.
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.