Giter Club home page Giter Club logo

canvasapi's Introduction

canvasapi

canvasapi is a Python package that allows for simple access to the Instructure Canvas API.

Installation

pip install canvasapi

Getting Started

The first thing to do is open a connection with Canvas. You will need to provide the URL for the API endpoint of your Canvas instance as well as a valid API key.

from canvasapi import Canvas

api_url = "https://example.com/api/v1/"  # URL of API for your Canvas instance
api_key = "p@$$w0rd"  # Your API key

canvas = Canvas(api_url, api_key)

You can now use canvas to begin making API calls. Here are some examples:

course = canvas.get_course('1111111')
user = canvas.get_user('5555555')
print user.name

Some calls will return a PaginatedList object instead of a single object.

users = course.get_users()
print users
<PaginatedList of type User>

This PaginatedList object is iterable. However, it doesn't contain any data until called. Calls to the API are made as-needed and results are stored in the object. You can use it like this:

for user in users:
    print user.name

You can also use indices:

print users[2].name

And even slices!

for user in users[2:]:
	print user.name

Warning: Presently, there is no way to determine the exact number of records Canvas might return without brute forcing through all the API calls. This means that PaginatedList is not aware of it's own length and negative indicies and slices (users[-1], users[-1:], etc.) are not possible at this time.

canvasapi's People

Contributors

thetwam avatar jessemcbride avatar devints47 avatar a-goetz avatar anthonyrodriguez726 avatar iturgeon avatar

Watchers

Joshua W Blumberg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.