RubyKhan: a Khan Academy API gem
This is a wrapper for the Khan Academy API. It is a work in progress, and only supports part of the API. Any assistance with implementing extra calls would be appreciated!
Installation
Add this line to your application's Gemfile:
gem 'rubykhan'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rubykhan
Usage
So far, this gem only accesses the publically available parts of the API. For authentication, try Khan Academy OmniAuth gem.
In your main.rb file:
require 'rubykhan'
Information from Khan academy's API is accessed through topic keywords called "slugs" that you can use in your API requests. Topics are arranged hierarchically from the most general (e.g. "math", "science", "humanities") to the very specific.
To see an array of all the nested topic slugs (which you can use for future queries):
KhanAcademy::Topic.all
You can always pass in a key if you are looking for different information:
KhanAcademy::Topic.all('slug')
KhanAcademy::Topic.all('title')
KhanAcademy::Topic.all('node_slug')
You can get a Topic object by directly calling .retrieve
:
algebra = KhanAcademy::Topic.retrieve("algebra")
algebra.title
algebra.description
More specific topics (e.g. "differential-equations", "buddhist-art", "blood-vessels") can return exercises and videos:
buddhist_art = KhanAcademy::Topic.get_exercises("buddhist-art").first
buddhist_art.title
buddhist_art.ka_url
blood_vessels_videos = KhanAcademy::Topic.get_videos("blood-vessels").first
blood_vessels_videos.description
blood_vessels_videos.title
blood_vessels_videos.ka_url
You can also get a list of all Exercises:
exercises = KhanAcademy::Exercise.all
More information about the Khan Academy API can be found at the Khan Academy API Explorer.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Please make sure the tests pass (rake spec
) and add your own before asking for a pull request.
FAQ:
Q: What's up with the name?
A: It's a pun on Crossing the Rubicon. Julius Caesar would've used Ruby in his conquest of Gaul, and we want you to be able to use Ruby in your Khan Academy app. :)