User

class canvasapi.user.User(requester, attributes)
Parameters:
  • requester (canvasapi.requester.Requester) – The requester to pass HTTP requests through.

  • attributes (dict) – The JSON object to build this object with.

add_observee(observee_id, **kwargs)

Registers a user as being observed by the given user.

Calls:

PUT /api/v1/users/:user_id/observees/:observee_id

Parameters:

observee_id (int) – The login id for the user to observe.

Return type:

canvasapi.user.User

add_observee_with_credentials(**kwargs)

Register the given user to observe another user, given the observee’s credentials.

Calls:

POST /api/v1/users/:user_id/observees

Return type:

canvasapi.user.User

create_communication_channel(**kwargs)

Create a communication channel for this user

Calls:

POST /api/v1/users/:user_id/communication_channels

Return type:

canvasapi.communication_channel.CommunicationChannel

create_content_migration(migration_type, **kwargs)

Create a content migration.

Calls:

POST /api/v1/users/:user_id/content_migrations

Parameters:

migration_type (str or canvasapi.content_migration.Migrator) – The migrator type to use in this migration

Return type:

canvasapi.content_migration.ContentMigration

create_folder(name, **kwargs)

Creates a folder in this user.

Calls:

POST /api/v1/users/:user_id/folders

Parameters:

name (str) – The name of the folder.

Return type:

canvasapi.folder.Folder

create_pairing_code(**kwargs)

Create a pairing code for this user.

Calls:

POST /api/v1/users/:user_id/observer_pairing_codes

Return type:

canvasapi.pairing_code.PairingCode

edit(**kwargs)

Modify this user’s information.

Calls:

PUT /api/v1/users/:id

Return type:

canvasapi.user.User

export_content(export_type, **kwargs)

Begin a content export job for a user.

Calls:

POST /api/v1/users/:user_id/content_exports

Parameters:

export_type (str) – The type of content to export.

Return type:

canvasapi.content_export.ContentExport

get_assignments(course, **kwargs)

Return the list of assignments for this user if the current user (the API key owner) has rights to view. See List assignments for valid arguments.

Calls:

GET /api/v1/users/:user_id/courses/:course_id/assignments

Parameters:

course (canvasapi.course.Course or int) – The object or ID of the course to retrieve.

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.assignment.Assignment

get_authentication_events(**kwargs)

List authentication events for a given user.

Calls:

GET /api/v1/audit/authentication/users/:user_id

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.authentication_event.AuthenticationEvent

get_avatars(**kwargs)

Retrieve the possible user avatar options that can be set with the user update endpoint.

Calls:

GET /api/v1/users/:user_id/avatars

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.avatar.Avatar

get_calendar_events_for_user(**kwargs)

List calendar events that the current user can view or manage.

Calls:

GET /api/v1/users/:user_id/calendar_events

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.calendar_event.CalendarEvent

get_closed_poll_sessions(**kwargs)

Returns a paginated list of all closed poll sessions available to the current user.

Calls:

GET /api/v1/poll_sessions/closed

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.poll_session.PollSession

get_color(asset_string, **kwargs)

Return the custom colors that have been saved by this user for a given context.

The asset_string parameter should be in the format ‘context_id’, for example ‘course_42’.

Calls:

GET /api/v1/users/:id/colors/:asset_string

Parameters:

asset_string (str) – The asset to retrieve the color from.

Return type:

dict

get_colors(**kwargs)

Return all custom colors that have been saved by this user.

Calls:

GET /api/v1/users/:id/colors

Return type:

dict

get_communication_channels(**kwargs)

List communication channels for the specified user, sorted by position.

Calls:

GET /api/v1/users/:user_id/communication_channels

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.communication_channel.CommunicationChannel

get_content_export(content_export, **kwargs)

Return information about a single content export.

Calls:

GET /api/v1/users/:user_id/content_exports/:id

Parameters:

content_export (int or canvasapi.content_export.ContentExport) – The object or ID of the content export to show.

Return type:

canvasapi.content_export.ContentExport

get_content_exports(**kwargs)

Return a paginated list of the past and pending content export jobs for a user.

Calls:

GET /api/v1/users/:user_id/content_exports

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.content_export.ContentExport

get_content_migration(content_migration, **kwargs)

Retrive a content migration by its ID

Calls:

GET /api/v1/users/:user_id/content_migrations/:id

Parameters:

content_migration (int, str or canvasapi.content_migration.ContentMigration) – The object or ID of the content migration to retrieve.

Return type:

canvasapi.content_migration.ContentMigration

get_content_migrations(**kwargs)

List content migrations that the current account can view or manage.

Calls:

GET /api/v1/users/:user_id/content_migrations/

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.content_migration.ContentMigration

get_courses(**kwargs)

Retrieve all courses this user is enrolled in.

Calls:

GET /api/v1/users/:user_id/courses

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.course.Course

get_enabled_features(**kwargs)

Lists all of the enabled features for a user.

Calls:

GET /api/v1/users/:user_id/features/enabled

Return type:

list of str

get_enrollments(**kwargs)

List all of the enrollments for this user.

Calls:

GET /api/v1/users/:user_id/enrollments

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.enrollment.Enrollment

get_eportfolios(**kwargs)

Returns a list of ePortfolios for a user.

Calls:

GET /api/v1/users/:user_id/eportfolios

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.eportfolio.EPortfolio

get_feature_flag(feature, **kwargs)

Returns the feature flag that applies to the given user.

Calls:

GET /api/v1/users/:user_id/features/flags/:feature

Parameters:

feature (canvasapi.feature.Feature or str) – The feature object or name of the feature to retrieve.

Return type:

canvasapi.feature.FeatureFlag

get_features(**kwargs)

Lists all of the features for this user.

Calls:

GET /api/v1/users/:user_id/features

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.feature.Feature

get_file(file, **kwargs)

Return the standard attachment json object for a file.

Calls:

GET /api/v1/users/:user_id/files/:id

Parameters:

file (canvasapi.file.File or int) – The object or ID of the file to retrieve.

Return type:

canvasapi.file.File

get_file_quota(**kwargs)

Returns the total and used storage quota for the user.

Calls:

GET /api/v1/users/:user_id/files/quota

Return type:

dict

get_files(**kwargs)

Returns the paginated list of files for the user.

Calls:

GET /api/v1/users/:user_id/files

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.file.File

get_folder(folder, **kwargs)

Returns the details for a user’s folder

Calls:

GET /api/v1/users/:user_id/folders/:id

Parameters:

folder (canvasapi.folder.Folder or int) – The object or ID of the folder to retrieve.

Return type:

canvasapi.folder.Folder

get_folders(**kwargs)

Returns the paginated list of all folders for the given user. This will be returned as a flat list containing all subfolders as well.

Calls:

GET /api/v1/users/:user_id/folders

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.folder.Folder

get_grade_change_events_for_grader(**kwargs)

Returns the grade change events for a grader.

Calls:

/api/v1/audit/grade_change/graders/:grader_id

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.grade_change_log.GradeChangeEvent

get_grade_change_events_for_student(**kwargs)

Returns the grade change events for the current student.

Calls:

/api/v1/audit/grade_change/students/:student_id

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.grade_change_log.GradeChangeEvent

get_licenses(**kwargs)

Returns a paginated list of the licenses that can be applied to the files under the user scope

Calls:

GET /api/v1/users/:user_id/content_licenses

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.license.License

get_migration_systems(**kwargs)

Return a list of migration systems.

Calls:

GET /api/v1/users/:user_id/content_migrations/migrators

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.content_migration.Migrator

get_missing_submissions(**kwargs)

Retrieve all past-due assignments for which the student does not have a submission.

Calls:

GET /api/v1/users/:user_id/missing_submissions

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.assignment.Assignment

get_observees(**kwargs)

List the users that the given user is observing

Calls:

GET /api/v1/users/:user_id/observees

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.user.User

get_observers(**kwargs)

List the users that are observing the given user.

Calls:

GET /api/v1/users/:user_id/observers

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.user.User

get_open_poll_sessions(**kwargs)

Returns a paginated list of all opened poll sessions available to the current user.

Calls:

GET /api/v1/poll_sessions/opened

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.poll_session.PollSession

get_page_views(**kwargs)

Retrieve this user’s page views.

Calls:

GET /api/v1/users/:user_id/page_views

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.course.PageView

get_profile(**kwargs)

Retrieve this user’s profile.

Calls:

GET /api/v1/users/:user_id/profile

Return type:

dict

get_user_logins(**kwargs)

Given a user ID, return that user’s logins for the given account.

Calls:

GET /api/v1/users/:user_id/logins

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.login.Login

merge_into(destination_user, **kwargs)

Merge this user into another user.

Calls:

PUT /api/v1/users/:id/merge_into/:destination_user_id

Parameters:

destination_user (canvasapi.user.User or int) – The object or ID of the user to merge into.

Return type:

canvasapi.user.User

moderate_all_eportfolios(**kwargs)

Update the spam_status for all active eportfolios of a user. Only available to admins who can moderate_user_content.

Parameters:

eportfolio (canvasapi.eportfolio.EPortfolio or int) – The object or ID of the ePortfolio to retrieve.

Calls:

PUT /api/v1/users/:user_id/eportfolios

Returns:

A list of all user ePortfolios.

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.eportfolio.EPortfolio

remove_observee(observee_id, **kwargs)

Unregisters a user as being observed by the given user.

Calls:

DELETE /api/v1/users/:user_id/observees/:observee_id

Parameters:

observee_id (int) – The login id for the user to observe.

Return type:

canvasapi.user.User

remove_usage_rights(**kwargs)

Changes the usage rights for specified files that are under the user scope

Calls:

DELETE /api/v1/users/:user_id/usage_rights

Return type:

dict

resolve_path(full_path=None, **kwargs)

Returns the paginated list of all of the folders in the given path starting at the user root folder. Returns root folder if called with no arguments.

Calls:

GET /api/v1/users/:user_id/folders/by_path/*full_path

Parameters:

full_path (string) – Full path to resolve, relative to user root.

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.folder.Folder

set_usage_rights(**kwargs)

Changes the usage rights for specified files that are under the user scope

Calls:

PUT /api/v1/users/:user_id/usage_rights

Return type:

canvasapi.usage_rights.UsageRights

show_observee(observee_id, **kwargs)

Gets information about an observed user.

Calls:

GET /api/v1/users/:user_id/observees/:observee_id

Parameters:

observee_id (int) – The login id for the user to observe.

Return type:

canvasapi.user.User

terminate_sessions(**kwargs)

Terminate all sessions for a user.

This includes all browser-based sessions and all access tokens, including manually generated ones.

Calls:

DELETE /api/v1/users/:id/sessions

Return type:

str

update_color(asset_string, hexcode, **kwargs)

Update a custom color for this user for a given context.

This allows colors for the calendar and elsewhere to be customized on a user basis.

The asset_string parameter should be in the format ‘context_id’, for example ‘course_42’. The hexcode parameter need not include the ‘#’.

Calls:

PUT /api/v1/users/:id/colors/:asset_string

Parameters:
  • asset_string (str) – The asset to modify the color for.

  • hexcode (str) – The hexcode of the color to use.

Return type:

dict

update_settings(**kwargs)

Update this user’s settings.

Calls:

PUT /api/v1/users/:id/settings

Return type:

dict

upload(file: PathLike | str | IOBase | FileIO, **kwargs)

Upload a file for a user.

NOTE: You must have authenticated with this user’s API key to upload on their behalf no matter what permissions the issuer of the request has.

Calls:

POST /api/v1/users/:user_id/files

Parameters:

file (file or str) – The file or path of the file to upload.

Returns:

True if the file uploaded successfully, False otherwise, and the JSON response from the API.

Return type:

tuple