Canvas
- class canvasapi.Canvas(base_url, access_token)
The main class to be instantiated to provide access to Canvas’s API.
- Parameters:
base_url (str) – The base URL of the Canvas instance’s API.
access_token (str) – The API key to authenticate requests with.
- clear_course_nicknames(**kwargs)
Remove all stored course nicknames.
- Calls:
- Returns:
True if the nicknames were cleared, False otherwise.
- Return type:
bool
- conversations_batch_update(conversation_ids, event, **kwargs)
- Calls:
- Parameters:
conversation_ids (list of str) – List of conversations to update. Limited to 500 conversations.
event (str) – The action to take on each conversation.
- Return type:
- conversations_get_running_batches(**kwargs)
Returns any currently running conversation batches for the current user. Conversation batches are created when a bulk private message is sent asynchronously.
- Calls:
- Returns:
dict with list of batch objects - not currently a Class
- Return type:
dict
- conversations_mark_all_as_read(**kwargs)
Mark all conversations as read.
- Calls:
- Return type:
bool
- conversations_unread_count(**kwargs)
Get the number of unread conversations for the current user
- Calls:
- Returns:
simple object with unread_count, example: {‘unread_count’: ‘7’}
- Return type:
dict
- create_account(**kwargs)
Create a new root account.
- Calls:
- Return type:
- create_appointment_group(appointment_group, **kwargs)
Create a new Appointment Group.
- Calls:
- Parameters:
appointment_group (dict) – The attributes of the appointment group.
title (str) – The title of the appointment group.
- Return type:
- create_calendar_event(calendar_event, **kwargs)
Create a new Calendar Event.
- Calls:
- Parameters:
calendar_event (dict) – The attributes of the calendar event.
- Return type:
- create_conversation(recipients, body, **kwargs)
Create a new Conversation.
- Calls:
- Parameters:
recipients (list of str) – An array of recipient ids. These may be user ids or course/group ids prefixed with ‘course_’ or ‘group_’ respectively, e.g. recipients=[‘1’, ‘2’, ‘course_3’]
body (str) – The body of the message being added.
- Return type:
- create_group(**kwargs)
Create a group
- Calls:
- Return type:
- create_jwt(**kwargs)
Creates a unique JWT to use with other Canvas services.
- Calls:
- Return type:
list of
canvasapi.jwt.JWT
- create_planner_note(**kwargs)
Create a planner note for the current user
- Calls:
- Return type:
- create_planner_override(plannable_type, plannable_id, **kwargs)
Create a planner override for the current user
- Calls:
- Parameters:
plannable_type (str) – Type of the item that you are overriding in the planner
plannable_id (int or
canvasapi.planner.PlannerOverride) – ID of the item that you are overriding in the planner
- Return type:
- create_poll(polls, **kwargs)
Create a new poll for the current user.
- Calls:
- Parameters:
polls (list of dict) – List of polls to create. ‘question’ key is required.
- Return type:
- get_account(account, use_sis_id=False, **kwargs)
Retrieve information on an individual account.
- Calls:
- Parameters:
account (int, str or
canvasapi.account.Account) – The object or ID of the account to retrieve.use_sis_id (bool) – Whether or not account_id is an sis ID. Defaults to False.
- Return type:
- get_account_calendars(**kwargs)
Returns a paginated list of account calendars available to the user.
- get_accounts(**kwargs)
List accounts that the current user can view or manage.
Typically, students and teachers will get an empty list in response. Only account admins can view the accounts that they are in.
- Calls:
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.account.Account
- get_activity_stream_summary(**kwargs)
Return a summary of the current user’s global activity stream.
- Calls:
- Return type:
dict
- get_announcements(context_codes, **kwargs)
List announcements.
- Calls:
- Parameters:
context_codes (list) – Course ID(s) or <Course> objects to request announcements from.
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.discussion_topic.DiscussionTopic
- get_appointment_group(appointment_group, **kwargs)
Return single Appointment Group by id
- Calls:
- Parameters:
appointment_group (
canvasapi.appointment_group.AppointmentGroupor int) – The ID of the appointment group.- Return type:
- get_appointment_groups(**kwargs)
List appointment groups.
- get_brand_variables(**kwargs)
Get account brand variables
- Calls:
- Returns:
JSON with brand variables for the account.
- Return type:
dict
- get_calendar_event(calendar_event, **kwargs)
Return single Calendar Event by id
- Calls:
- Parameters:
calendar_event (
canvasapi.calendar_event.CalendarEventor int) – The object or ID of the calendar event.- Return type:
- get_calendar_events(**kwargs)
List calendar events.
- get_comm_messages(user, **kwargs)
Retrieve a paginated list of messages sent to a user.
- Calls:
- Parameters:
user (
canvasapi.user.Useror int) – The object or ID of the user.- Returns:
Paginated list containing messages sent to user
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.comm_message.CommMessage
- get_conversation(conversation, **kwargs)
Return single Conversation
- Calls:
- Parameters:
conversation (
canvasapi.conversation.Conversationor int) – The object or ID of the conversation.- Return type:
- get_conversations(**kwargs)
Return list of conversations for the current user, most resent ones first.
- Calls:
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.conversation.Conversation
- get_course(course, use_sis_id=False, **kwargs)
Retrieve a course by its ID.
- Calls:
- Parameters:
course (int, str or
canvasapi.course.Course) – The object or ID of the course to retrieve.use_sis_id (bool) – Whether or not course_id is an sis ID. Defaults to False.
- Return type:
- get_course_accounts(**kwargs)
List accounts that the current user can view through their admin course enrollments (Teacher, TA or designer enrollments).
Only returns id, name, workflow_state, root_account_id and parent_account_id.
- Calls:
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.account.Account
- get_course_nickname(course, **kwargs)
Return the nickname for the given course.
- Calls:
- Parameters:
course (
canvasapi.course.Courseor int) – The object or ID of the course.- Return type:
- get_course_nicknames(**kwargs)
Return all course nicknames set by the current account.
- get_courses(**kwargs)
Return a list of active courses for the current user.
- Calls:
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.course.Course
- get_current_user()
Return a details of the current user.
- Calls:
- Return type:
- get_eportfolio(eportfolio, **kwargs)
Get an eportfolio by ID.
- Parameters:
eportfolio – The object or ID of the eportfolio to retrieve.
- Calls:
GET /api/v1/eportfolios/:id https://canvas.instructure.com/doc/api/e_portfolios.html#method.eportfolios_api.show
- Return type:
- get_epub_exports(**kwargs)
Return a list of epub exports for the associated course.
- get_file(file, **kwargs)
Return the standard attachment json object for a file.
- Calls:
- Parameters:
file (
canvasapi.file.Fileor int) – The object or ID of the file to retrieve.- Return type:
- get_folder(folder, **kwargs)
Return the details for a folder
- Calls:
- Parameters:
folder (
canvasapi.folder.Folderor int) – The object or ID of the folder to retrieve.- Return type:
- get_group(group, use_sis_id=False, **kwargs)
Return the data for a single group. If the caller does not have permission to view the group a 401 will be returned.
- Calls:
- Parameters:
group (
canvasapi.group.Groupor int) – The object or ID of the group to get.use_sis_id (bool) – Whether or not group_id is an sis ID. Defaults to False.
- Return type:
- get_group_category(category, **kwargs)
Get a single group category.
- Calls:
- Parameters:
category (
canvasapi.group.GroupCategoryor int) – The object or ID of the category.- Return type:
- get_group_participants(appointment_group, **kwargs)
List student group participants in this appointment group.
- Calls:
- Parameters:
appointment_group (
canvasapi.appointment_group.AppointmentGroupor int) – The object or ID of the appointment group.- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.group.Group
- get_outcome(outcome, **kwargs)
Returns the details of the outcome with the given id.
- Calls:
- Parameters:
outcome (
canvasapi.outcome.Outcomeor int) – The outcome object or ID to return.- Returns:
An Outcome object.
- Return type:
- get_outcome_group(group, **kwargs)
Returns the details of the Outcome Group with the given id.
- Calls:
- Parameters:
group (
canvasapi.outcome.OutcomeGroupor int) – The outcome group object or ID to return.- Returns:
An outcome group object.
- Return type:
- get_planner_note(planner_note, **kwargs)
Retrieve a planner note for the current user
- Calls:
- Parameters:
planner_note (int or
canvasapi.planner.PlannerNote) – The ID of the planner note to retrieve.- Return type:
- get_planner_notes(**kwargs)
Retrieve the paginated list of planner notes
- Calls:
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.planner.PlannerNote
- get_planner_override(planner_override, **kwargs)
Retrieve a planner override for the current user
- Calls:
- Parameters:
planner_override (int or
canvasapi.planner.PlannerOverride) – The override or the ID of the planner override to retrieve.- Return type:
- get_planner_overrides(**kwargs)
Retrieve a planner override for the current user
- Calls:
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.planner.PlannerOverride
- get_poll(poll, **kwargs)
Get a single poll, based on the poll id.
- Calls:
- Parameters:
poll (int) – The ID of the poll or the poll to change.
- Return type:
- get_polls(**kwargs)
Returns a paginated list of polls for the current user
- Calls:
- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.poll.Poll
- get_progress(progress, **kwargs)
Get a specific progress.
- Calls:
- Parameters:
progress (int, str or
canvasapi.progress.Progress) – The object or ID of the progress to retrieve.- Return type:
- get_root_outcome_group(**kwargs)
Redirect to root outcome group for context
- Calls:
- Returns:
The OutcomeGroup of the context.
- Return type:
- get_section(section, use_sis_id=False, **kwargs)
Get details about a specific section.
- Calls:
- Parameters:
section (
canvasapi.section.Sectionor int) – The object or ID of the section to get.use_sis_id (bool) – Whether or not section_id is an sis ID. Defaults to False.
- Return type:
- get_todo_items(**kwargs)
Return the current user’s list of todo items, as seen on the user dashboard.
- Calls:
- Return type:
dict
- get_upcoming_events(**kwargs)
Return the current user’s upcoming events, i.e. the same things shown in the dashboard ‘Coming Up’ sidebar.
- Calls:
- Return type:
dict
- get_user(user, id_type=None, **kwargs)
Retrieve a user by their ID. id_type denotes which endpoint to try as there are several different IDs that can pull the same user record from Canvas.
Refer to API documentation’s User example to see the ID types a user can be retrieved with.
- Calls:
- Parameters:
user (
canvasapi.user.Useror int) – The user’s object or ID.id_type (str) – The ID type.
- Return type:
- get_user_participants(appointment_group, **kwargs)
List user participants in this appointment group.
- Calls:
- Parameters:
appointment_group (
canvasapi.appointment_group.AppointmentGroupor int) – The object or ID of the appointment group.- Return type:
canvasapi.paginated_list.PaginatedListofcanvasapi.user.User
- graphql(query, variables=None, **kwargs)
Makes a GraphQL formatted request to Canvas
- Calls:
- Parameters:
query (str) – The GraphQL query to execute as a String
variables (dict) – The variable values as required by the supplied query
- Return type:
dict
- refresh_jwt(jwt, **kwargs)
Refreshes a JWT for reuse with other canvas services. It generates a different JWT each time it’s called; expires after one hour.
- Calls:
- Parameters:
jwt (str or
canvasapi.jwt.JWT) – An existing JWT to refresh.- Return type:
- reserve_time_slot(calendar_event, participant_id=None, **kwargs)
Return single Calendar Event by id
- Calls:
- Parameters:
calendar_event (
canvasapi.calendar_event.CalendarEventor int) – The object or ID of the calendar event.participant_id (str) – The ID of the participant, if given.
- Return type:
- search_accounts(**kwargs)
Return a list of up to 5 matching account domains. Partial matches on name and domain are supported.
- Calls:
- Return type:
dict
- search_all_courses(**kwargs)
List all the courses visible in the public index. Returns a list of dicts, each containing a single course.
- Calls:
- Return type:
list
- search_recipients(**kwargs)
Find valid recipients (users, courses and groups) that the current user can send messages to. Returns a list of mixed data types.
- Calls:
- Return type:
list
- set_course_nickname(course, nickname, **kwargs)
Set a nickname for the given course. This will replace the course’s name in the output of subsequent API calls, as well as in selected places in the Canvas web user interface.
- Calls:
- Parameters:
course (
canvasapi.course.Courseor int) – The ID of the course.nickname (str) – The nickname for the course.
- Return type: