Pandarus is a Ruby gem client library for the Canvas LMS API. It is auto-generated from the Canvas api documentation.
Included in this repo is also the code generator that has the potential to generate Canvas API support for other programming languages.
Pandarus uses the Swagger 1.2 spec. It depends on the canvas-lms API documentation to be accurate. If the documentation is accurate, the generated code should work. However, there are several known cases where the api documentation cannot conform to the spec, and these cases are broken. We'll try to document known broken cases below.
Please think carefully about whether or not Pandarus makes sense for your use case. It might make sense to write a smaller wrapper around just the api endpoints that you need.
Potential Risks:
cache_pages: false
to disable
this.Potential Benefits:
Pandarus was created internally as an experiment, and is only used sporadically internally. As such, it's only updated sporadically as well. It's provided as a way to experiment with the Canvas API, but please understand the risks before using it in a production application.
gem install pandarus
require 'pandarus'
client = Pandarus::Client.new(
prefix: "https://pandamonium.instructure.com/api",
token: "[YOUR API TOKEN HERE]")
client.get_single_course_courses(1)
# => <Pandarus::Course :id=>1 ...>
See the Canvas API documentation that Pandarus is built from:
Pandarus method names are very similar to the descriptions in the documentation. If you follow three rules, you will be able to access the full API:
/courses
and
/sections
) then add a _courses
or _sections
suffixExamples:
get_single_account
reserve_time_slot
get_single_course_courses
OR
get_single_course_accounts
because there are two ways to access the API.To generate the Ruby gem from Canvas's api-docs.json file:
brew install maven
)CANVAS_DIR
if your canvas checkout is not
located at the relative path ../canvas-lms
../build-all
api/
- This is a copy of the api swagger docs generated by canvas. It is
autogenerated and should not be modified by hand.clients/
- This is where the Ruby gem lives.
clients/ruby/lib/pandarus/{models/*,api_base.rb,models.rb}
are all
auto-generated.api_base.rb
is where all the
individual api calls live.codegen/
- This is the scala code that uses Swagger to run the
code gen.GroupMembership
or Progress
) depending on the input params, which
Swagger does not handle.processing_warnings
and
processing_errors
which are arrays of arrays. This datatype can't be
expressed in Swagger.