Sections API call only returns up to 10 sections

Jump to solution
Davidemolin
Community Explorer

Hi,

I seem to have an issue with interfacing with the Canvas API from my tool (I'm a tool provider).

In Canvas we have a course with 20+ sections. When a launch of my tool is pefrormed from the instructor, we interface with Canvas (via its Oauth API) and check how many sections are present in the course, using the API url:

/api/v1/courses/:course_id/sections?include=total_students

What we see is baffling: we only receive up to 10 courses as a result. Is there some kind of limit we're hitting here with the Canvas API, or is the amount of sections that can be returned customizable somewhere so we can get all of them? 

This is particularly critical for us so any feedback would be greatly appreciated.

Best
Davide

0 Likes
2 Solutions
mzimmerman
Community Coach
Community Coach

Hi @Davidemolin 

There is a "pagination" setting in the API that defaults to returning 10 results.  See https://canvas.instructure.com/doc/api/file.pagination.html 

View solution in original post

JennyDruckrey
Community Explorer

I think you're probably running into pagination.  By default, the API will only return the top 10 results.  You can change the call to return up to 100 results (&per_page=100) or use a loop to get the next page of results.  I hope this helps.

Pagination - Canvas LMS REST API Documentation (instructure.com)

 

View solution in original post