cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jjbaxter
Community Member

Retrieve all courses via API

Jump to solution

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)
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
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

2 Replies
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

jjbaxter
Community Member

Thanks James - just the nudge I needed.

Full course list retrieved successfully via API api/v1/accounts/1/courses.