Why use an API?
- When you need to make changes in bulk.
Examples of API Use:
- Create a user
- Give certain users admin rights
- Change the course status to private
- Turn on a feature flag for all the courses of a certain instructor
- Merge 2 users
“Hey Siri, what time does Walmart Pharmacy open today?”
There are 4 parts of an API call:
Example in Canvas:
“Hey Canvas, tell me what users are enrolled in BIO 101 100M SU19?”
- Get (tell me something)
- Post (create something new)
- Put (update something that already exists)
- Delete (remove from the UI)
What if you don’t know the course ID?
- Get the ID from a provisioning report - How do I view reports for an account?
- Get the ID from another API call
Canvas API Documentation: api.instructure.com
When using a GET API call, you’ve already authenticated in your browser.
When using POST, PUT, DELETE, you can’t use a browser so you need another way to authenticate using a TOKEN.
API Token Security Best Practices:
- Don’t share it
- Protect it
- Have it expire
It’s better to create a separate token in Production, Test, & Beta Canvas instances.
Account > Settings > Generate New Token
Admin > Settings > Reports > Provisioning Report > Courses (only use a specific Term) > Run Report
Can use the Provisioning Report from above to get the unique course ID to replicate the same action on all courses.
Use double curly brackets in Postman app on the new value for the Path Variable: