Skip to content

A nodejs library for interacting with the Khan Academy APIs

License

Notifications You must be signed in to change notification settings

Phanatic/KhanAcademyJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Khan Academy JS

Node.JS SDK for interacting with Khan Academy APIs

Install this package.

npm install khanacademyjs --save

SDK documentation

Badges

Retrieve a list of all badges

var khanJS = require('khanacademyjs');
khanJS.badges.getBadges((err, response, badges)=>{
	console.log(`Found ${badges.length} badges`);
});
Sample badge object
{
      "badge_category": 1,
      "description": "Going Transonic",
      "name": "greattimedproblembadge",
      "points": 500,
      "safe_extended_description": "Quickly & correctly answer 10 exercise problems in a row (time limit depends on exercise difficulty)",
      "user_badges": [
          {
              "badge_name": "greattimedproblembadge",
              "date": "2011-05-04T06:02:05Z",
              "kind": "UserBadge",
              "points_earned": 500,
              "target_context": {
              },
              "target_context_name": "Addition 1",
              "user": "[email protected]"
          }
			]		
  }

Retrieve a list of all badge categories.

var khanJS = require('khanacademyjs');
khanJS.badges.getBadgeCategories((err, response, categories)=>{
	console.log(`Found ${categories.length} categories`);
});
Sample badge category object
	{
	    "category": 0,
	    "chart_icon_src": "/images/badges/meteorite-small-chart.png",
	    "description": "Meteorite badges are common and easy to earn when just getting started.",
	    "icon_src": "/images/badges/meteorite-small.png",
	    "large_icon_src": "/images/badges/meteorite.png",
	    "type_label": "Meteorite Badges"
	}

Retrieve specific badge category identified by categoryId

var khanJS = require('khanacademyjs');
khanJS.badges.getBadgeCategory(categoryId, (err, response, category)=>{
	console.log(`Found category`, category);
});

Videos

Retrieve the video identified by readable_id or youtube_id.
var khanJS = require('khanacademyjs');
khanJS.videos.getVideo(videoReadableId, (err, response, video)=>{
	console.log(`Found video`, video);
});
Retrieve a list of all exercises associated with video video_id.
var khanJS = require('khanacademyjs');
khanJS.videos.getExercises(videoReadableId, (err, response, exercises)=>{
	console.log(`Found ${exercises.length} exercises`);
});

Exercises

Retrieve a filtered list of exercises in the library.
var khanJS = require('khanacademyjs');
khanJS.exercises.getExercises((err, response, exercises)=>{
	console.log(`Found ${exercises.length} exercises`);
});
Retrieve exercises identified by exerciseName.
var khanJS = require('khanacademyjs');
khanJS.exercises.getExercise(exerciseName, (err, response, exercises)=>{
	console.log(`Found ${exercises.length} exercises`);
});
Retrieve exercises identified by exerciseName.
var khanJS = require('khanacademyjs');
khanJS.exercises.getExercise(exerciseName, (err, response, exercise)=>{
	console.log(`Found exercise`, exercise);
});
Retrieve all the exercises that list exerciseName as a prerequisite.
var khanJS = require('khanacademyjs');
khanJS.exercises.getFollowupExercises(exerciseName, (err, response, followupExercises)=>{
	console.log(`Found ${followupExercises.length} followup exercises`);
});
Retrieve a list of videos associated with exerciseName.
var khanJS = require('khanacademyjs');
khanJS.exercises.getVideos(exerciseName, (err, response, videos)=>{
	console.log(`Found ${videos.length} videos`);
});
Retrieve a list of Perseus exercises used for autocomplete.
var khanJS = require('khanacademyjs');
khanJS.exercises.getPersusAutoComplete(exerciseName, (err, response, autoCompleteItems)=>{
	console.log(`Found ${autoCompleteItems.length} autocomplete items`);
});