Canvas Object

class canvasapi.canvas_object.CanvasObject(requester, attributes)

Base class for all classes representing objects returned by the API.

This makes a call to canvasapi.canvas_object.CanvasObject.set_attributes() to dynamically construct this object’s attributes with a JSON object.

  • requester (canvasapi.requester.Requester) – The requester to pass HTTP requests through.
  • attributes (dict) – The JSON object to build this object with.

Load this object with attributes.

This method attempts to detect special types based on the field’s content and will create an additional attribute of that type.

Consider a JSON response with the following fields:

    "name": "New course name",
    "course_code": "COURSE-001",
    "start_at": "2012-05-05T00:00:00Z",
    "end_at": "2012-08-05T23:59:59Z",
    "sis_course_id": "12345"

The start_at and end_at fields match a date in ISO8601 format, so two additional datetime attributes are created, start_at_date and end_at_date.

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