CanvasKit is a Work in Progress—the architecture is still prone to change and not all off the API endpoints are implemented.
CanvasKit is a library that will help you integrate your own third party app with Canvas by Instructure.
CanvasKit is built on the Canvas API. CanvasKit is designed to allow for great flexibility while providing an easy to use interface. You can use CanvasKit to build apps for open source versions of Canvas as well as instances hosted by Instructure.
- Download CanvasKit and try out the included iPhone example app
- Take a look at the Canvas API for a complete list of endpoints
NOTE: Canvas Kit is not yet a cocoapod but will be soon
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like CanvasKit in your projects. See the "Getting Started" guide for more information.
platform :ios, '7.0'
pod "CanvasKit", "~> 2.0"
CanvasKit 2.0 is a major refactor from the previous version of CanvasKit. Until now CanvasKit has only been used on internal projects at Instructure. One of our major goals of the recent refactor was to make CanvasKit open source and easy to use for third party developers.
In order to use CanvasKit with Instructure mangaged instances of Canvas LMS you must obtain a Client ID and Shared Secret. CanvasKit uses OAuth 2 for authentication. Request your Client ID and Shared Secret by sending an email to [email protected]. Make sure to give us your name, email, and what you are hoping to do with CanvasKit.
The CKIClient
is in charge of all the networking in CanvasKit. Insantiate a CKIClient
with your client ID and shared secret like so:
CKIClient *client = [CKIClient clientWithBaseURL:url clientID:ClientID sharedSecret:SharedSecret];
If the client is not logged in, you may do so by calling -login
. This method will handle displaying a
modal webview to the user and deal with the OAuth process for you. At the end you may look
[[self.client login] subscribeError:^(NSError *error) {
// do somethign with the error
} completed:^{
// login completed successfully. do something.
}];
If you would like to get information about the currently logged in user, you may do so by accessing the client.currentUser
property. See CKIUser
for more information.
CanvasKit includes classes for many of the objects found in the Canvas LMS. Along with these model classes CanvasKit includes networking categories on CKIClient
for accessing the API endpoints. For example, to fetch all the courses for the current user, you would do this:
[[client fetchCoursesForCurrentUser] subscribeNext:^(NSArray *courses) {
// handle a page of courses
}];
Each networking method begins with 'fetch' making it easy for you to see all available options with Xcode auto-complete.
One thing to note is that CanvasKit uses ReactiveCocoa, however, it is not necessary to have any knowledge of ReactiveCocoa in order to use CanvasKit (although undertanding ReactiveCocoa will allow you to do much more powerful things). Each networking call returns a RACSignal
object. Simply call subscribeNext:
on that signal to process the data. Essentially the paginated data will be processed as a stream of pages, i.e. your subscribeNext:
block will be called once for every page.
CanvasKit is available under the MIT license. See the LICENSE file for more info.