{"id":13815065,"url":"https://github.com/ucfopen/canvasapi","last_synced_at":"2025-05-14T04:07:53.031Z","repository":{"id":38802273,"uuid":"73851042","full_name":"ucfopen/canvasapi","owner":"ucfopen","description":"Python API wrapper for Instructure's Canvas LMS. Easily manage courses, users, gradebooks, and more.","archived":false,"fork":false,"pushed_at":"2024-12-27T01:46:28.000Z","size":4895,"stargazers_count":590,"open_issues_count":76,"forks_count":181,"subscribers_count":24,"default_branch":"develop","last_synced_at":"2025-04-13T12:41:16.444Z","etag":null,"topics":["api","canvas","canvas-lms","education","hacktoberfest","instructure","python","wrapper"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/canvasapi","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ucfopen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-15T20:09:41.000Z","updated_at":"2025-04-10T17:05:47.000Z","dependencies_parsed_at":"2023-01-25T21:46:28.224Z","dependency_job_id":"d25bf0f8-146d-4acf-86d3-2cc078d1afda","html_url":"https://github.com/ucfopen/canvasapi","commit_stats":{"total_commits":1452,"total_committers":77,"mean_commits":"18.857142857142858","dds":0.6487603305785123,"last_synced_commit":"5e4f2600247116a46701ef26ce046a213b3df519"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucfopen%2Fcanvasapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucfopen%2Fcanvasapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucfopen%2Fcanvasapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucfopen%2Fcanvasapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ucfopen","download_url":"https://codeload.github.com/ucfopen/canvasapi/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254069446,"owners_count":22009556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","canvas","canvas-lms","education","hacktoberfest","instructure","python","wrapper"],"created_at":"2024-08-04T04:02:54.483Z","updated_at":"2025-05-14T04:07:48.011Z","avatar_url":"https://github.com/ucfopen.png","language":"Python","readme":"[![CanvasAPI on PyPI](https://img.shields.io/pypi/v/canvasapi.svg)](https://pypi.python.org/pypi/canvasapi)\n[![License](https://img.shields.io/pypi/l/canvasapi.svg)](https://pypi.python.org/pypi/canvasapi)\n[![Python Versions](https://img.shields.io/pypi/pyversions/canvasapi.svg)](https://pypi.python.org/pypi/canvasapi)\n[![Documentation Status](https://readthedocs.org/projects/canvasapi/badge/?version=stable)](http://canvasapi.readthedocs.io/en/stable/?badge=stable)\n[![Build Status](https://github.com/ucfopen/canvasapi/actions/workflows/run-tests.yml/badge.svg?branch=develop)](https://github.com/ucfopen/canvasapi/actions)\n[![codecov](https://codecov.io/gh/ucfopen/canvasapi/branch/develop/graph/badge.svg?token=CFNpp8f56M)](https://codecov.io/gh/ucfopen/canvasapi)\n[![Join UCF Open Slack Discussions](https://badgen.net/badge/icon/ucfopen?icon=slack\u0026label=slack\u0026color=pink)](https://dl.ucf.edu/join-ucfopen)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# CanvasAPI\n\nCanvasAPI is a Python library for accessing Instructure’s [Canvas LMS API](https://canvas.instructure.com/doc/api/index.html). The library enables developers to programmatically manage Canvas courses, users, gradebooks, and more.\n\n## Table of Contents\n\n- [CanvasAPI](#canvasapi)\n  - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n  - [Documentation](#documentation)\n  - [Contributing](#contributing)\n  - [Quickstart](#quickstart)\n    - [Working with Canvas Objects](#working-with-canvas-objects)\n      - [Course objects](#course-objects)\n      - [User objects](#user-objects)\n      - [Paginated Lists](#paginated-lists)\n      - [Keyword arguments](#keyword-arguments)\n  - [CanvasAPI Projects](#canvasapi-projects)\n  - [Contact Us](#contact-us)\n\n## Installation\n\nYou can install CanvasAPI with pip:\n\n`pip install canvasapi`\n\n## Documentation\n\nFull documentation is available at [Read the Docs](http://canvasapi.readthedocs.io/).\n\n## Contributing\n\nWant to help us improve CanvasAPI? Check out our [Contributing Guide](.github/CONTRIBUTING.md) to learn about running CanvasAPI as a developer, picking issues to work on, submitting bug reports, contributing patches, and more.\n\n## Quickstart\n\nGetting started with CanvasAPI is easy.\n\nLike most API clients, CanvasAPI exposes a single class that provides access to the rest of the API: `Canvas`.\n\nThe first thing to do is instantiate a new `Canvas` object by providing your Canvas instance’s root API URL and a valid API key:\n\n```python\n# Import the Canvas class\nfrom canvasapi import Canvas\n\n# Canvas API URL\nAPI_URL = \"https://example.com\"\n# Canvas API key\nAPI_KEY = \"p@$$w0rd\"\n\n# Initialize a new Canvas object\ncanvas = Canvas(API_URL, API_KEY)\n```\n\nYou can now use `canvas` to begin making API calls.\n\n### Working with Canvas Objects\n\nCanvasAPI converts the JSON responses from the Canvas API into Python objects. These objects provide further access to the Canvas API. You can find a full breakdown of the methods these classes provide in our [class documentation](http://canvasapi.readthedocs.io/en/stable/class-reference.html). Below, you’ll find a few examples of common CanvasAPI use cases.\n\n#### Course objects\n\nCourses can be retrieved from the API:\n\n```python\n# Grab course 123456\n\u003e\u003e\u003e course = canvas.get_course(123456)\n\n# Access the course's name\n\u003e\u003e\u003e course.name\n'Test Course'\n\n# Update the course's name\n\u003e\u003e\u003e course.update(course={'name': 'New Course Name'})\n```\n\nSee our documentation on [keyword arguments](#keyword-arguments) for more information about how `course.update()` handles the `name` argument.\n\n#### User objects\n\nIndividual users can be pulled from the API as well:\n\n```python\n# Grab user 123\n\u003e\u003e\u003e user = canvas.get_user(123)\n\n# Access the user's name\n\u003e\u003e\u003e user.name\n'Test User'\n\n# Retrieve a list of courses the user is enrolled in\n\u003e\u003e\u003e courses = user.get_courses()\n\n# Grab a different user by their SIS ID\n\u003e\u003e\u003e login_id_user = canvas.get_user('some_user', 'sis_login_id')\n```\n\n#### Paginated Lists\n\nSome calls, like the `user.get_courses()` call above, will request multiple objects from Canvas’s API. CanvasAPI collects these objects in a `PaginatedList` object. `PaginatedList` generally acts like a regular Python list. You can grab an element by index, iterate over it, and take a slice of it.\n\n**Warning**: `PaginatedList` lazily loads its elements. Unfortunately, there’s no way to determine the exact number of records Canvas will return without traversing the list fully. This means that `PaginatedList` isn’t aware of its own length and negative indexing is not currently supported.\n\nLet’s look at how we can use the `PaginatedList` returned by our `get_courses()` call:\n\n```python\n# Retrieve a list of courses the user is enrolled in\n\u003e\u003e\u003e courses = user.get_courses()\n\n\u003e\u003e\u003e print(courses)\n\u003cPaginatedList of type Course\u003e\n\n# Access the first element in our list.\n#\n# You'll notice the first call takes a moment, but the next N-1\n# elements (where N = the per_page argument supplied; the default is 10)\n# will be instantly accessible.\n\u003e\u003e\u003e print(courses[0])\nTST101 Test Course (1234567)\n\n# Iterate over our course list\n\u003e\u003e\u003e for course in courses:\n         print(course)\n\nTST101 Test Course 1 (1234567)\nTST102 Test Course 2 (1234568)\nTST103 Test Course 3 (1234569)\n\n# Take a slice of our course list\n\u003e\u003e\u003e courses[:2]\n[TST101 Test Course 1 (1234567), TST102 Test Course 2 (1234568)]\n```\n\n#### Keyword arguments\n\nMost of Canvas’s API endpoints accept a variety of arguments. CanvasAPI allows developers to insert keyword arguments when making calls to endpoints that accept arguments.\n\n```python\n# Get all of the active courses a user is currently enrolled in\n\u003e\u003e\u003e courses = user.get_courses(enrollment_state='active')\n```\n\nFor a more detailed description of how CanvasAPI handles more complex keyword arguments, check out the [Keyword Argument Documentation](http://canvasapi.readthedocs.io/en/stable/keyword-args.html).\n\n## CanvasAPI Projects\n\nSince its initial release in June 2016, CanvasAPI has amassed over 100 [dependent repositories](https://github.com/ucfopen/canvasapi/network/dependents). Many of these include various tools used to enhance the Canvas experience for both instructors and students. Here are a few popular repositories that use CanvasAPI:\n\n- [Canvas Grab](https://github.com/skyzh/canvas_grab)\n  - Canvas Grab is the most popular project using CanvasAPI. This tool, with one click, copies all files from Canvas LMS to local directory. CanvasAPI is used in this project to connect to a course and grab its files.\n- [Clanvas](https://github.com/marklalor/clanvas)\n  - Clanvas is a command-line client for Canvas. It uses the already available bash commands plus some additional ones to interact with various features of Canvas from the commmand line.\n- [CS221Bot](https://github.com/Person314159/cs221bot)\n  - CS221Bot is a Discord bot for the CPCS 221 course at University of British Columbia. CanvasAPI is used in this project to connect to and synchronize with a course and get its data, such as announcements, new assignments, and more.\n\nIf you have a project that uses CanvasAPI that you'd like to promote, please contact us!\n\n## Contact Us\n\nNeed help? Have an idea? Feel free to check out our [Discussions](https://github.com/ucfopen/canvasapi/discussions) board. Just want to say hi or get extended spport? Come join us on the [UCF Open Slack Channel](https://dl.ucf.edu/join-ucfopen) and join the `#canvasapi` channel!\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucfopen%2Fcanvasapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fucfopen%2Fcanvasapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucfopen%2Fcanvasapi/lists"}