Retrieve all courses via API

Jump to solution
jjbaxter
Community Novice

My canvas account for my institution is admin and I have generated an access_token.

The API documentation for api/v1/courses states that it "Returns the paginated list of active courses for the current user" and indeed it returns the one course I enrolled in as a test.

But how do I use the API to see ALL the course's my institution offers, can it be done?

Eventually I want to:

 1- locate and verify a course is open and obtain its price
 2- Check that a user does not already exist and create them if they do not
 3- enrol student in course

Julien

 

Labels (1)
0 Likes
1 Solution
James
Community Champion

 @jjbaxter ,

You are using the wrong API call if you want to get a list of all of the courses. The API that you gave is scoped to the user, so you get a list of all of the courses that user is enrolled in, not all of the courses in the account.

The API call that you want to use is to List active courses in an account.

Depending on what information you need, you may also be able to use the GraphQL interface to the account with a coursesConnection. It allows you to specify what information you need and by limiting what information you ask for you can get more at a time (fewer pagination links). You can play around with the GraphQL by adding /graphiql to the end of your Canvas instance URL.

View solution in original post