| Title: | 'Canvas' LMS API Integration |
|---|---|
| Description: | Allow R users to interact with the 'Canvas' Learning Management System (LMS) API (see <https://canvas.instructure.com/doc/api/all_resources.html> for details). It provides a set of functions to access and manipulate course data, assignments, grades, users, and other resources available through the 'Canvas' API. |
| Authors: | Hajo Bons [aut, cre], Tomer Iwan [aut], Niels Smits [ctb] (ORCID: <https://orcid.org/0000-0003-3669-9266>), VU Analytics [cph] |
| Maintainer: | Hajo Bons <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.7 |
| Built: | 2026-05-20 09:34:14 UTC |
| Source: | https://github.com/vusaverse/vvcanvas |
Appends access_token to URL if not present
append_access_token(url, access_token)append_access_token(url, access_token)
url |
The URL to which the access_token should be appended. |
access_token |
The Canvas API access token (string). |
The URL with the access_token appended if it was not already present.
Get the Canvas API key from the environment variable
canvas_api_key()canvas_api_key()
The Canvas API key stored in the CANVAS_API_KEY environment variable.
This function handles authentication with the Canvas LMS API.
It uses the provided API key and base URL, or falls back to the CANVAS_API_KEY and CANVAS_BASE_URL environment variables if none are provided.
canvas_authenticate(api_key = canvas_api_key(), base_url = canvas_base_url())canvas_authenticate(api_key = canvas_api_key(), base_url = canvas_base_url())
api_key |
The API key for authenticating with the Canvas LMS API. Defaults to the |
base_url |
The base URL of the Canvas instance. Defaults to the |
A list containing the authenticated 'api_key' and 'base_url'.
The function verifies authentication by making a test request to the /api/v1/users/self endpoint of the Canvas instance.
If the response status code is not 200, it throws an error message indicating that authentication failed.
## Not run: # Authenticate with the Canvas LMS API api_key <- "your_api_key" base_url <- "https://canvas.example.com" canvas <- canvas_authenticate(api_key, base_url) ## End(Not run)## Not run: # Authenticate with the Canvas LMS API api_key <- "your_api_key" base_url <- "https://canvas.example.com" canvas <- canvas_authenticate(api_key, base_url) ## End(Not run)
Get the Canvas base URL from the environment variable
canvas_base_url()canvas_base_url()
The Canvas base URL stored in the CANVAS_BASE_URL environment variable.
Creates a new assignment group in a specific course using the Canvas LMS API.
create_assignment_group(canvas, course_id, group_name, group_position = NULL)create_assignment_group(canvas, course_id, group_name, group_position = NULL)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the assignment group. |
group_name |
The name of the assignment group. |
group_position |
The position of the assignment group in the course (optional). |
A confirmation message that the assignment group has been created.
Canvas allows for an e-mail like communication with students, called 'conversations', which can be handled from the API.
create_conversation( canvas, recipients = NULL, subject = " ", body = " ", force_new = TRUE, group_conversation = FALSE, attachments = NULL, attachment_ids = NULL, media_comment_id = NULL, media_comment_type = NULL, mode = "sync", scope = NULL, filter = NULL, filter_mode = NULL, context_code = NULL )create_conversation( canvas, recipients = NULL, subject = " ", body = " ", force_new = TRUE, group_conversation = FALSE, attachments = NULL, attachment_ids = NULL, media_comment_id = NULL, media_comment_type = NULL, mode = "sync", scope = NULL, filter = NULL, filter_mode = NULL, context_code = NULL )
canvas |
An object containing the Canvas API key and base URL, |
recipients |
An array of recipient ids. |
subject |
The subject of the conversation. Maximum length is 255 characters. |
body |
The message to be sent. Unfortunately, Canvas only allows for plain text. |
force_new |
logical. Forces a new message to be created, even if there is an existing private conversation. |
group_conversation |
logical. Defaults to |
attachments |
An array of paths to local files that should be uploaded. |
attachment_ids |
An array of attachments ids. These must be files that have been previously uploaded to the sender's 'conversation attachments' folder. |
media_comment_id |
Media comment id of an audio or video file to be associated with this message. |
media_comment_type |
Type of the associated media file, values allowed are |
mode |
Determines whether the messages will be created/sent synchronously or
asynchronously. Defaults to |
scope |
Used when generating 'visible' in the API response, values allowed are |
filter |
Used when generating 'visible' in the API response. |
filter_mode |
Used when generating 'visible' in the API response, values allowed are |
context_code |
The course or group that is the context for this conversation. Same format as courses or groups in the recipients argument. |
Note that the user should have rights to access the folder.
A confirmation message indicating that the message has been successfully send.
get_single_conversation() and get_conversations().
This function retrieves data from various endpoints for a specific course in the Canvas LMS API and stores the data as JSON files in a specified storage location.
create_course_datalake(canvas, course_id, storage_location)create_course_datalake(canvas, course_id, storage_location)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to create the data lake. |
storage_location |
The path to the storage location where the data files will be saved. |
NULL.
This function retrieves data from various endpoints. Access to certain endpoints may require specific roles.
Creates a new course section in a specific course using the Canvas LMS API.
create_course_section( canvas, course_id, section_name, section_start_date = NULL, section_end_date = NULL )create_course_section( canvas, course_id, section_name, section_start_date = NULL, section_end_date = NULL )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the section. |
section_name |
The name of the section. |
section_start_date |
(Optional) The start date of the section. |
section_end_date |
(Optional) The end date of the section. |
A confirmation message that the section has been created.
Creates a new folder in a specific course using the Canvas LMS API.
create_folder(canvas, course_id, folder_name, parent_folder_id = NULL)create_folder(canvas, course_id, folder_name, parent_folder_id = NULL)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the folder. |
folder_name |
The name of the folder. |
parent_folder_id |
(Optional) The ID of the parent folder in which to create the folder. |
A confirmation message that the folder has been created.
Creates a new group category in a specific course using the Canvas LMS API.
create_group_category( canvas, course_id, category_name, allow_self_signup = FALSE )create_group_category( canvas, course_id, category_name, allow_self_signup = FALSE )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the group category. |
category_name |
The name of the group category. |
allow_self_signup |
(Optional) Whether to allow self-signup for groups in the category. Defaults to FALSE. |
A confirmation message that the group category has been created.
Creates a new module in a specific course using the Canvas LMS API.
create_module(canvas, course_id, module_name, position = NULL)create_module(canvas, course_id, module_name, position = NULL)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the module. |
module_name |
The title of the module. |
position |
(Optional) The position of this module in the course |
A confirmation message that the module has been created.
Creates a new item in a specific module in a specifc course using the Canvas LMS API.
create_module_item( canvas, course_id, module_id, item_title, item_type = "Page", position = NULL, page_url = NULL, page_id = NULL )create_module_item( canvas, course_id, module_id, item_title, item_type = "Page", position = NULL, page_url = NULL, page_id = NULL )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the module item. |
module_id |
The ID of the module in which to create the item. |
item_title |
The title of the new item within the module. |
item_type |
The type of item. Defaults to "Page". |
position |
(Optional) The position of the item within the module. Defaults to 1. |
page_url |
(Optional) The url of the page. |
page_id |
(Optional) The id of the page. |
A confirmation message that the page has been created.
Creates a new page in a specific course using the Canvas LMS API.
create_page(canvas, course_id, page_title, page_body, published = FALSE)create_page(canvas, course_id, page_title, page_body, published = FALSE)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the page. |
page_title |
The title of the page. |
page_body |
The body/content of the page. |
published |
(Optional) Whether the page should be published. Defaults to FALSE. |
A confirmation message that the page has been created.
Deletes an existing course section using the Canvas LMS API.
delete_course_section(canvas, section_id)delete_course_section(canvas, section_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
section_id |
The ID of the section to delete. |
A confirmation message that the section has been deleted.
Deletes a page in a specific course using the Canvas LMS API.
delete_page(canvas, course_id, page_id)delete_page(canvas, course_id, page_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to delete the page. |
page_id |
The ID of the page. |
A confirmation message that the page has been deleted.
This function downloads a file from a specified URL and saves it locally.
download_course_file(canvas, file_url, download_path)download_course_file(canvas, file_url, download_path)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
file_url |
The URL of the file to download. |
download_path |
The path where the file should be downloaded. |
The path of the downloaded file.
## Not run: # Download a file from a given URL canvas <- canvas_authenticate(api_key, base_url) file_url <- "https://example.com/file.pdf" download_path <- "path/to/save/file.pdf" file_path <- download_course_file(canvas, file_url, download_path) ## End(Not run)## Not run: # Download a file from a given URL canvas <- canvas_authenticate(api_key, base_url) file_url <- "https://example.com/file.pdf" download_path <- "path/to/save/file.pdf" file_path <- download_course_file(canvas, file_url, download_path) ## End(Not run)
Modifies an existing course section using the Canvas LMS API.
edit_section( canvas, section_id, section_name = NULL, sis_section_id = NULL, integration_id = NULL, section_start_date = NULL, section_end_date = NULL, restrict_enrollments_to_section_dates = NULL, override_sis_stickiness = NULL )edit_section( canvas, section_id, section_name = NULL, sis_section_id = NULL, integration_id = NULL, section_start_date = NULL, section_end_date = NULL, restrict_enrollments_to_section_dates = NULL, override_sis_stickiness = NULL )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
section_id |
The ID of the section to edit. |
section_name |
The new name of the section (optional). |
sis_section_id |
The new SIS ID of the section (optional). |
integration_id |
The new integration ID of the section (optional). |
section_start_date |
The new start date of the section (optional). |
section_end_date |
The new end date of the section (optional). |
restrict_enrollments_to_section_dates |
Whether to restrict user enrollments to the start and end dates of the section (optional). |
override_sis_stickiness |
Whether to override SIS stickiness (optional). |
A confirmation message that the section has been edited.
Extracts the 'next' URL from a Link header
extract_next_url(link_header)extract_next_url(link_header)
link_header |
The Link header string from an httr response. |
The URL (character) for the next page, or NULL if not present.
Retrieves a paginated list of accounts that the current user can view or manage.
get_accounts(canvas, include = NULL, per_page = 100)get_accounts(canvas, include = NULL, per_page = 100)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
include |
A vector of additional information to include. Default is NULL. |
per_page |
Number of accounts to retrieve per page. Default is 100. |
A list of accounts retrieved from the Canvas LMS API.
This function retrieves a paginated list of all courses visible in the public index using the Canvas LMS API. NOTE This function might take a while to finish.
get_all_courses(canvas, per_page = 100)get_all_courses(canvas, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
per_page |
(Optional) The number of courses to retrieve per page of results (default is 100). |
A data frame of courses visible in the public index.
Retrieves the course-level assignment data for a specific course from the Canvas LMS API.
get_assignment_data(canvas, course_id, per_page = 100)get_assignment_data(canvas, course_id, per_page = 100)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the assignment data. |
per_page |
Number of assignment data to retrieve per page. Default is 100. |
A list of assignment data retrieved from the Canvas LMS API.
Retrieves detailed information about a specific assignment from the Canvas LMS API.
get_assignment_details(canvas, course_id, assignment_id)get_assignment_details(canvas, course_id, assignment_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which the assignment resides. |
assignment_id |
The ID of the assignment for which to retrieve the details. |
A dataframe containing the detailed information about the assignment.
This function retrieves the assignment groups within a specific course in the Canvas LMS API.
get_assignment_groups(canvas, course_id, per_page = 100)get_assignment_groups(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the assignment groups. |
per_page |
The number of entries to show per page. |
A list of assignment groups within the specified course.
This function retrieves the submissions to a specific assignment in a specific course in the Canvas LMS API.
get_assignment_submissions(canvas, course_id, assignment_id, per_page = 100)get_assignment_submissions(canvas, course_id, assignment_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch submissions. |
assignment_id |
The ID of the assignment for which to fetch the submissions. |
per_page |
(Optional) The number of submissions to retrieve per page of results (default is 100). |
A data frame containing the submission data.
Fetches a list of assignments within a specific course from the Canvas LMS API.
get_assignments(canvas, course_id)get_assignments(canvas, course_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the assignments. |
A list of assignments retrieved from the Canvas LMS API.
Retrieve the paginated list of calendar events or assignments for the current user.
get_calendar_events( canvas, type = "event", start_date = NULL, end_date = NULL, undated = FALSE, all_events = FALSE, context_codes = NULL, excludes = NULL, includes = NULL, important_dates = FALSE, blackout_date = FALSE )get_calendar_events( canvas, type = "event", start_date = NULL, end_date = NULL, undated = FALSE, all_events = FALSE, context_codes = NULL, excludes = NULL, includes = NULL, important_dates = FALSE, blackout_date = FALSE )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
type |
The type of events to retrieve. Default is "event". Allowed values: event, assignment. |
start_date |
Only return events since the start_date (inclusive). Defaults to today. |
end_date |
Only return events before the end_date (inclusive). Defaults to start_date. |
undated |
Defaults to false (dated events only). If true, only return undated events and ignore start_date and end_date. |
all_events |
Defaults to false (uses start_date, end_date, and undated criteria). If true, all events are returned, ignoring start_date, end_date, and undated criteria. |
context_codes |
List of context codes of courses, groups, users, or accounts whose events you want to see. If not specified, defaults to the current user (i.e personal calendar, no course/group events). |
excludes |
Array of attributes to exclude. Possible values are “description”, “child_events” and “assignment”. |
includes |
Array of optional attributes to include. Possible values are “web_conference” and if calendar_series flag is on, “series_natural_language”. |
important_dates |
Defaults to false. If true, only events with important dates set to true will be returned. |
blackout_date |
Defaults to false. If true, only events with blackout date set to true will be returned. |
A data frame of calendar events retrieved from the Canvas LMS API.
This function retrieves all details concerning conversations of the user.
get_conversations(canvas)get_conversations(canvas)
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
Returns a data frame containing the details of conversations for the current user, most recent ones first.
get_single_conversation() and create_conversation().
This function retrieves a list of announcements for a specific course in the Canvas LMS API.
get_course_announcements(canvas, course_id, per_page = 100)get_course_announcements(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to retrieve announcements. |
per_page |
(Optional) The number of announcements to retrieve per page of results (default is 100). |
A data frame of course announcements.
Retrieves detailed information about a specific course from the Canvas LMS API.
get_course_details(canvas, course_id)get_course_details(canvas, course_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the details. |
A dataframe containing the detailed information about the course.
This function retrieves the enrollments of students and other roles in a specific course in the Canvas LMS API.
get_course_enrollments(canvas, course_id, per_page = 100)get_course_enrollments(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the enrollments. |
per_page |
(Optional) The number of enrollments to retrieve per page of results (default is 100). |
A data frame of course enrollments for the specified course.
This function retrieves a list of files within a specific course in the Canvas LMS API.
get_course_files(canvas, course_id, per_page = 100)get_course_files(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the files. |
per_page |
(Optional) The number of files to retrieve per page of results (default is 100). |
A data frame of files within the specified course.
This function retrieves a list of folders for a specific course in the Canvas LMS API.
get_course_folders(canvas, course_id, per_page = 100)get_course_folders(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to retrieve folders. |
per_page |
Number of courses to retrieve per page. Default is 100. |
Returns a list of all folders and sub folders for the given course. Note that for some reported sub folders its main folder may be outside of the course.
A data frame of course folders.
get_course_root_folder() and get_user_folders()
This function generates a gradebook for the assignments in a specific course in the Canvas LMS API.
get_course_gradebook(canvas, course_id)get_course_gradebook(canvas, course_id)
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
course_id |
The ID of the course for which to generate the gradebook. |
The gradebook shown in Canvas is not accessible through the API. Here it is reconstructed using
the (visible) assignments and students in the course. It may be useful for performing more
advanced grade calculations (like allowing for conditional extra credit) before adjusting
assignment grades (see, update_course_grades and
update_section_grades).
A data frame containing the gradebook with student in rows (identifiable through
canvas_user_id) and assignments in columns (identifiable through assigment names).
get_assignments(), and get_assignment_submissions().
This function retrieves the list of groups in a specific course in the Canvas LMS API.
get_course_groups(canvas, course_id, per_page = 100)get_course_groups(canvas, course_id, per_page = 100)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to fetch the groups. |
per_page |
(Optional) The number of groups to retrieve per page of results (default is 100). |
A data frame of groups in the specified course.
This function retrieves the media objects associated with a specific course in the Canvas LMS API.
get_course_media_objects(canvas, course_id, per_page = 100)get_course_media_objects(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the media objects. |
per_page |
The number of entries to show per page. |
A data frame containing the media objects in the specified course.
This function retrieves the pages within a specific course in the Canvas LMS API.
get_course_pages(canvas, course_id, per_page = 100)get_course_pages(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the pages. |
per_page |
(Optional) The number of pages to retrieve per page of results (default is 50). |
A list of pages within the specified course.
Fetches the participation data for a specific course from the Canvas LMS API.
get_course_participation(canvas, course_id)get_course_participation(canvas, course_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the participation data. |
The participation data for the specified course retrieved from the Canvas LMS API.
This function retrieves a list of quizzes for a specific course in the Canvas LMS API.
get_course_quizzes(canvas, course_id, per_page = 100)get_course_quizzes(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to retrieve quizzes. |
per_page |
(Optional) The number of quizzes to retrieve per page of results (default is 100). |
A data frame of course quizzes.
This function retrieves the root folder associated with a course.
get_course_root_folder(canvas, course_id)get_course_root_folder(canvas, course_id)
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
course_id |
The ID of the course for which to fetch associated folders. |
Returns a data frame containing the details on the root folder associated with the specified course.
get_course_folders() and get_user_folders()
This function retrieves a list of sections for a specific course in the Canvas LMS API.
get_course_sections(canvas, course_id, per_page = 100)get_course_sections(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to retrieve sections. |
per_page |
(Optional) The number of sections to retrieve per page of results (default is 100). |
A data frame of course sections.
This function retrieves the list of students enrolled in a specific course in the Canvas LMS API.
get_course_students(canvas, course_id, per_page = 100)get_course_students(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the students. |
per_page |
(Optional) The number of students to retrieve per page of results (default is 100). |
A data frame of students enrolled in the specified course.
This function retrieves the users enrolled in a specific course in the Canvas LMS API.
get_course_users( canvas, course_id, per_page = 100, include = c("enrollments", "locked", "avatar_url", "test_student", "bio", "custom_links", "current_grading_period_scores", "uuid") )get_course_users( canvas, course_id, per_page = 100, include = c("enrollments", "locked", "avatar_url", "test_student", "bio", "custom_links", "current_grading_period_scores", "uuid") )
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the users. |
per_page |
The number of entries to show per page. |
include |
Optional parameters to include in the response. Possible values: "enrollments", "locked", "avatar_url", "test_student", "bio", "custom_links", "current_grading_period_scores", "uuid". |
A data frame containing the users in the specified course.
Retrieves a list of courses from the Canvas LMS API.
get_courses(canvas, per_page = 100)get_courses(canvas, per_page = 100)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
per_page |
Number of courses to retrieve per page. Default is 100. |
A list of courses retrieved from the Canvas LMS API.
Retrieves the department-level grade data for a specific account and term from the Canvas LMS API.
get_department_grade_data( canvas, account_id, type = "current", term_id = NULL, per_page = 100 )get_department_grade_data( canvas, account_id, type = "current", term_id = NULL, per_page = 100 )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
account_id |
The ID of the account for which to retrieve the grade data. |
type |
The type of courses to include in the data. Can be 'current', 'completed', or 'term'. |
term_id |
The ID of the term for which to retrieve the grade data. Only used when type is 'terms/<term_id>'. |
per_page |
Number of grade data to retrieve per page. Default is 100. |
A data frame of grade data retrieved from the Canvas LMS API.
Retrieves the department-level participation data for a specific account and term from the Canvas LMS API.
get_department_participation_data( canvas, account_id, type = "current", term_id = NULL, per_page = 100 )get_department_participation_data( canvas, account_id, type = "current", term_id = NULL, per_page = 100 )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
account_id |
The ID of the account for which to retrieve the participation data. |
type |
The type of courses to include in the data. Can be 'current', 'completed', or 'term'. |
term_id |
The ID of the term for which to retrieve the participation data. Only used when type is 'terms/<term_id>'. |
per_page |
Number of participation data to retrieve per page. Default is 100. |
A data frame of participation data retrieved from the Canvas LMS API.
Retrieves department-level statistics for a specific account and term from the Canvas LMS API.
get_department_statistics(canvas, account_id, type = "current", term_id = NULL)get_department_statistics(canvas, account_id, type = "current", term_id = NULL)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
account_id |
The ID of the account for which to retrieve the statistics. |
type |
The type of courses to include in the data. Can be 'current', 'completed', or 'term'. |
term_id |
The ID of the term for which to retrieve the statistics. Only used when type is 'terms/<term_id>'. |
A list of department-level statistics retrieved from the Canvas LMS API.
Retrieves department-level statistics for a specific account and term from the Canvas LMS API.
get_department_statistics_by_subaccount( canvas, account_id, type = "current", term_id = NULL )get_department_statistics_by_subaccount( canvas, account_id, type = "current", term_id = NULL )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
account_id |
The ID of the account for which to retrieve the statistics. |
type |
The type of courses to include in the data. Can be 'current', 'completed', or 'term'. |
term_id |
The ID of the term for which to retrieve the statistics. Only used when type is 'terms/<term_id>'. |
A list of department-level statistics retrieved from the Canvas LMS API.
This function retrieves the discussion topics within a specific course in the Canvas LMS API.
get_discussions(canvas, course_id, per_page = 100)get_discussions(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the discussion topics. |
per_page |
The number of entries to show |
A list of discussion topics within the specified course.
Retrieves the data of favorite courses for the authenticated user using the Canvas LMS API.
get_favorite_courses(canvas, exclude_blueprint_courses = NULL)get_favorite_courses(canvas, exclude_blueprint_courses = NULL)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
exclude_blueprint_courses |
When set, only return courses that are not configured as blueprint courses (optional). |
The dataframe of favorite courses.
This function lists all files available in a specific folder.
get_folder_files(canvas, folder_id)get_folder_files(canvas, folder_id)
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
folder_id |
The ID of the folder for which to fetch associated files. |
Returns a data frame containing the details on the files stored in the specified folder.
This function retrieves the group categories for a specific context (e.g., course) in the Canvas LMS API.
get_group_categories(canvas, course_id)get_group_categories(canvas, course_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the group categories. |
A data frame of group categories in the specified context.
This function retrieves information about a specific group in the Canvas LMS API.
get_group_info(canvas, group_id)get_group_info(canvas, group_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
group_id |
The ID of the group for which to retrieve the information. |
A list containing the information about the specified group.
This function retrieves the memberships for a specific group in the Canvas LMS API.
get_group_memberships(canvas, group_id)get_group_memberships(canvas, group_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
group_id |
The ID of the group for which to retrieve the memberships. |
A data frame of memberships in the specified group.
This function retrieves the users in a specific group in the Canvas LMS API.
get_group_users(canvas, group_id)get_group_users(canvas, group_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
group_id |
The ID of the group for which to retrieve the users. |
A data frame of users in the specified group.
This function retrieves the items within a specific module of a course in the Canvas LMS API.
get_module_items(canvas, course_id, module_id)get_module_items(canvas, course_id, module_id)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course containing the module. |
module_id |
The ID of the module for which to fetch the items. |
A list of items within the specified module.
This function retrieves the modules within a specific course in the Canvas LMS API.
get_modules(canvas, course_id, per_page = 100)get_modules(canvas, course_id, per_page = 100)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course for which to fetch the modules. |
per_page |
The number of entries to show |
A list of modules within the specified course.
This function retrieves the content body of a specified page within a course in the Canvas LMS API.
get_page_content(canvas, course_id, page_id, return_as_plain_text = TRUE)get_page_content(canvas, course_id, page_id, return_as_plain_text = TRUE)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course to which the page belongs. |
page_id |
The ID of the page for which to fetch the content body. |
return_as_plain_text |
A logical value indicating whether to return the content as plain text (default is TRUE). |
The content body of the specified page, either as plain text or raw HTML.
This function retrieves the submissions to a specific quiz in a specific course in the Canvas LMS API.
get_quiz_submissions(canvas, course_id, quiz_id)get_quiz_submissions(canvas, course_id, quiz_id)
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
course_id |
The ID of the course for which to fetch submissions. |
quiz_id |
The ID of the quiz for which to fetch the submissions. |
A data frame containing the submission data.
This function retrieves a paginated list of the roles available to a specific account in the Canvas LMS system.
get_roles(canvas, account_id, per_page = 100)get_roles(canvas, account_id, per_page = 100)
canvas |
A list containing the base URL and API key for the Canvas LMS instance. |
account_id |
The ID of the account for which you want to retrieve the roles. |
per_page |
The number of roles to retrieve per page (default is 100). |
A data frame containing the roles available to the specified account.
Retrieves information about a specific course section using the Canvas LMS API.
get_section_information(canvas, course_id, section_id)get_section_information(canvas, course_id, section_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course. |
section_id |
The ID of the section. |
The information about the section.
This function retrieves a list of students enrolled in a specific section of a course in Canvas LMS.
get_section_students(canvas, section_id, per_page = 100)get_section_students(canvas, section_id, per_page = 100)
canvas |
A list containing the Canvas API key and base URL, typically obtained through a |
section_id |
The ID of the section for which to retrieve students. |
per_page |
(Optional) The number of student records to retrieve per page of results. Defaults to 100. |
A data frame containing details of students enrolled in the specified section.
## Not run: canvas <- list(base_url = "https://your_canvas_instance.instructure.com", api_key = "your_api_key") section_id <- "67890" students <- get_section_students(canvas, section_id) print(students) ## End(Not run)## Not run: canvas <- list(base_url = "https://your_canvas_instance.instructure.com", api_key = "your_api_key") section_id <- "67890" students <- get_section_students(canvas, section_id) print(students) ## End(Not run)
This function retrieves all details concerning a specific conversation.
get_single_conversation(canvas, conversation_id)get_single_conversation(canvas, conversation_id)
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
conversation_id |
The id of the specific conversation. |
Returns information for a specific conversation for the current user. Response includes all fields that are present in the list/index action as well as messages and extended participant information.
get_conversations() and create_conversation().
Retrieves the student summaries for a specific course from the Canvas LMS API.
get_student_summaries(canvas, course_id, per_page = 100)get_student_summaries(canvas, course_id, per_page = 100)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the student summaries. |
per_page |
Number of student summaries to retrieve per page. Default is 100. |
A list of student summaries retrieved from the Canvas LMS API.
Retrieves user-in-a-course-level assignment data for a specific course and student from the Canvas LMS API.
get_user_course_assignment_data(canvas, course_id, student_id)get_user_course_assignment_data(canvas, course_id, student_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the assignment data. |
student_id |
The ID of the student for which to retrieve the assignment data. |
A list of user-in-a-course-level assignment data retrieved from the Canvas LMS API.
Retrieves user-in-a-course-level messaging data for a specific course and student from the Canvas LMS API.
get_user_course_messaging_data(canvas, course_id, student_id)get_user_course_messaging_data(canvas, course_id, student_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the messaging data. |
student_id |
The ID of the student for which to retrieve the messaging data. |
A list of user-in-a-course-level messaging data retrieved from the Canvas LMS API.
Retrieves user-in-a-course-level participation data for a specific course and student from the Canvas LMS API.
get_user_course_participation_data(canvas, course_id, student_id)get_user_course_participation_data(canvas, course_id, student_id)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course for which to retrieve the participation data. |
student_id |
The ID of the student for which to retrieve the participation data. |
A list of user-in-a-course-level participation data retrieved from the Canvas LMS API.
This function retrieves all folders associated with the user accessing the API.
get_user_folders(canvas)get_user_folders(canvas)
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
Returns a list of all folders 'owned by' the current user. Note that since self replaces
user_id, the id of the user accessing the API does not need to be specified. The
highest level folder name is my folder.
Returns a data frame containing the details on the folders available to the user accessing the API.
get_course_root_folder() and get_course_folders()
Retrieves users from a specific account in the Canvas LMS API with optional filtering and pagination.
get_users( canvas, account_id = "self", per_page = 100, search_term = NULL, enrollment_type = NULL, sort = NULL, order = NULL, include_deleted_users = NULL, uuids = NULL, include = NULL )get_users( canvas, account_id = "self", per_page = 100, search_term = NULL, enrollment_type = NULL, sort = NULL, order = NULL, include_deleted_users = NULL, uuids = NULL, include = NULL )
canvas |
An object containing the Canvas API key and base URL, obtained through the |
account_id |
The ID of the account. Defaults to "self" for the current user's account. |
per_page |
The number of entries to show per page. Default is 100. |
search_term |
Optional. The partial name or full ID of the users to match and return in the results list. Must be at least 3 characters. |
enrollment_type |
Optional. When set, only return users enrolled with the specified course-level base role. Possible values: 'student', 'teacher', 'ta', 'observer', or 'designer'. |
sort |
Optional. The column to sort results by. Possible values: 'username', 'email', 'sis_id', 'integration_id', 'last_login', 'id'. |
order |
Optional. The order to sort the given column by. Possible values: 'asc', 'desc'. |
include_deleted_users |
Optional. When set to TRUE, returns users who have deleted pseudonyms for the context. |
uuids |
Optional. A vector of UUIDs. When set, only return users with the specified UUIDs. UUIDs after the first 100 are ignored. |
include |
Optional. A vector of additional information to include. Possible values include: "email", "enrollments", "avatar_url", "bio", "last_login", "time_zone", "locale", "uuid". |
A data frame containing the users matching the specified criteria.
## Not run: # Authenticate with Canvas canvas <- canvas_authenticate() # Get all users from the default account users <- get_users(canvas) # Get users with a search term users <- get_users(canvas, search_term = "John") # Get users with email addresses included users <- get_users(canvas, include = c("email", "enrollments")) ## End(Not run)## Not run: # Authenticate with Canvas canvas <- canvas_authenticate() # Get all users from the default account users <- get_users(canvas) # Get users with a search term users <- get_users(canvas, search_term = "John") # Get users with email addresses included users <- get_users(canvas, include = c("email", "enrollments")) ## End(Not run)
This function retrieves a paginated list of all enrollment terms for a specified account in Canvas LMS.
list_all_enrollment_terms(canvas, account_id, per_page = 100)list_all_enrollment_terms(canvas, account_id, per_page = 100)
canvas |
A list containing Canvas API configuration:
|
account_id |
The ID of the account for which to retrieve enrollment terms |
per_page |
The number of terms to retrieve per page (default is 100) |
A dataframe containing all enrollment terms details
Follows 'next' links in the Link header to retrieve all pages. Returns a list of all responses.
paginate(initial_response, access_token, showProgress = TRUE)paginate(initial_response, access_token, showProgress = TRUE)
initial_response |
The initial httr response object from the first GET request. |
access_token |
The Canvas API access token (string). |
showProgress |
Logical; whether to print progress as pages are fetched. Default is TRUE. |
A list of httr response objects, one for each page.
Creates a new discussion topic in a specific course using the Canvas LMS API.
post_new_discussion( canvas, course_id, discussion_title, discussion_message, discussion_is_announcement = FALSE )post_new_discussion( canvas, course_id, discussion_title, discussion_message, discussion_is_announcement = FALSE )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the discussion. |
discussion_title |
The title of the discussion topic. |
discussion_message |
The initial message content of the discussion topic. |
discussion_is_announcement |
(Optional) Whether the discussion should be an announcement. Defaults to FALSE. |
A confirmation message that the discussion has been created.
This function queries the progress of asynchronous API operations.
query_progress(canvas, progress_url, attempts = 10)query_progress(canvas, progress_url, attempts = 10)
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
progress_url |
The url where a progress update can be retrieved. |
attempts |
The number of times it is allowed to check progress. |
It performs 10 attempts with a pause of 6 seconds between them.
a message indicating completion and status information about the asynchronous job.
This function updates the assignment grades of a specific assignment in a specific course in the Canvas LMS API.
update_course_grades( canvas, course_id, assignment_id, student_ids, posted_grades )update_course_grades( canvas, course_id, assignment_id, student_ids, posted_grades )
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
course_id |
The ID of the course for which to generate the gradebook. |
assignment_id |
The ID of the assignment for which the grades are updated. |
student_ids |
The IDs of the students for whom the grades are updated. |
posted_grades |
The values of the (updated) grades. |
It updates the grading on multiple students' assignment submissions in an asynchronous job. The user must have permission to manage grades in the course. The API documentation describes the following types of scores:
A floating point or integral value, such as "13.5". The grade will be interpreted directly as the score of the assignment. Values above assignment.points_possible are allowed, for awarding extra credit.
A floating point value appended with a percent sign, such as "40%". The grade will be interpreted as a percentage score on the assignment, where 100% == assignment.points_possible. Values above 100% are allowed, for awarding extra credit.
A letter grade, following the assignment's defined letter grading scheme. For example, "A-". The resulting score will be the high end of the defined range for the letter grade. For instance, if "B" is defined as 86% to 84%, a letter grade of "B" will be worth 86%. The letter grade will be rejected if the assignment does not have a defined letter grading scheme. For more fine-grained control of scores, pass in points or percentage rather than the letter grade.
A string value of "pass" or "complete" will give a score of 100%. "fail" or "incomplete" will give a score of 0.
A confirmation message indicating that the grades have been updated.
Updates an existing page in a specific course using the Canvas LMS API.
update_page(canvas, course_id, page_id, page_params)update_page(canvas, course_id, page_id, page_params)
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course in which to create the page. |
page_id |
The ID of the page. |
page_params |
A named list of page parameters to update. This list can include:
|
A confirmation message that the page has been updated.
This function modifies an existing quiz in a specific course in the Canvas LMS API.
update_quiz(canvas, course_id, quiz_id, quiz_params)update_quiz(canvas, course_id, quiz_id, quiz_params)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course containing the quiz to be modified. |
quiz_id |
The ID of the quiz to be modified. |
quiz_params |
A named list of quiz parameters to update. This list can include:
|
A list representing the updated quiz object.
This function updates the assignment grades of a specific assignment in a specific section in the Canvas LMS API.
update_section_grades( canvas, section_id, assignment_id, student_ids, posted_grades )update_section_grades( canvas, section_id, assignment_id, student_ids, posted_grades )
canvas |
An object containing the Canvas API key and base URL, obtained through the
|
section_id |
The ID of the section for which to generate the gradebook. |
assignment_id |
The ID of the assignment for which the grades are updated. |
student_ids |
The IDs of the students for whom the grades are updated. |
posted_grades |
The values of the (updated) grades. |
It updates the grading on multiple students' assignment submissions in an asynchronous job. The user must have permission to manage grades in the section. The API documentation describes the following types of scores:
A floating point or integral value, such as "13.5". The grade will be interpreted directly as the score of the assignment. Values above assignment.points_possible are allowed, for awarding extra credit.
A floating point value appended with a percent sign, such as "40%". The grade will be interpreted as a percentage score on the assignment, where 100% == assignment.points_possible. Values above 100% are allowed, for awarding extra credit.
A letter grade, following the assignment's defined letter grading scheme. For example, "A-". The resulting score will be the high end of the defined range for the letter grade. For instance, if "B" is defined as 86% to 84%, a letter grade of "B" will be worth 86%. The letter grade will be rejected if the assignment does not have a defined letter grading scheme. For more fine-grained control of scores, pass in points or percentage rather than the letter grade.
A string value of "pass" or "complete" will give a score of 100%. "fail" or "incomplete" will give a score of 0.
A confirmation message indicating that the grades have been updated.
This function uploads a file to the files folder of a specific course.
upload_file(canvas, course_id, file_name)upload_file(canvas, course_id, file_name)
canvas |
An object containing the Canvas API key and base URL, obtained through the |
course_id |
The ID of the course where the file will be uploaded. |
file_name |
The file to be uploaded. |
A confirmation message indicating that the file has been uploaded.
This function uploads a specific file to a specific folder.
upload_folder_file(canvas, folder_id, file_name, generate_message = TRUE)upload_folder_file(canvas, folder_id, file_name, generate_message = TRUE)
canvas |
An object containing the Canvas API key and base URL,
obtained through the |
folder_id |
The ID of the folder to which the file is uploaded. |
file_name |
The path to the local file that should be uploaded. |
generate_message |
A logical expressing whether a message should
be shown after a succesful upload; defaults to |
Note that the user should have rights to access the folder.
If generate_message is TRUE, a confirmation message indicating
that the file has been successfully uploaded.
get_course_root_folder() and get_user_folders()
This function uploads a QTI file to a specified course in Canvas LMS and initiates a content migration. It handles the process of creating the migration, uploading the file, and checking the migration status. Additionally, it allows for obtaining the ID of the resulting quiz within Canvas so that quiz settings are easily updated. In that case, because processing the QTI file (i.e. turning it into a quiz) takes some time, the execution of further commands need to be suspended. If the processing of the uploaded file has not yet resulted in a new quiz ID the user is asked if further waiting is required.
upload_qti_file_with_migration( canvas, course_id, qti_name, wait = FALSE, settings = list() )upload_qti_file_with_migration( canvas, course_id, qti_name, wait = FALSE, settings = list() )
canvas |
A list containing the 'api_key' and 'base_url' for authentication. |
course_id |
The ID of the course where the QTI file will be uploaded. |
qti_name |
The name of the QTI file (without the '.zip' extension) being uploaded. |
wait |
logical or integer. Defaults to |
settings |
A list of additional settings for the content migration. This can include options like question bank name or overwrite settings. |
A quiz ID (equal to NULL if wait = FALSE or if no new quiz ID was found) and a confirmation message indicating that the content migration has been completed.