Node.JS SDK for interacting with Khan Academy APIs
npm install khanacademyjs --save
Retrieve a list of all badges
var khanJS = require('khanacademyjs');
khanJS.badges.getBadges((err, response, badges)=>{
console.log(`Found ${badges.length} badges`);
});
{
"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": "you@gmail.com"
}
]
}
Retrieve a list of all badge categories.
var khanJS = require('khanacademyjs');
khanJS.badges.getBadgeCategories((err, response, categories)=>{
console.log(`Found ${categories.length} categories`);
});
{
"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);
});
var khanJS = require('khanacademyjs');
khanJS.videos.getVideo(videoReadableId, (err, response, video)=>{
console.log(`Found video`, video);
});
var khanJS = require('khanacademyjs');
khanJS.videos.getExercises(videoReadableId, (err, response, exercises)=>{
console.log(`Found ${exercises.length} exercises`);
});
var khanJS = require('khanacademyjs');
khanJS.exercises.getExercises((err, response, exercises)=>{
console.log(`Found ${exercises.length} exercises`);
});
var khanJS = require('khanacademyjs');
khanJS.exercises.getExercise(exerciseName, (err, response, exercises)=>{
console.log(`Found ${exercises.length} exercises`);
});
var khanJS = require('khanacademyjs');
khanJS.exercises.getExercise(exerciseName, (err, response, exercise)=>{
console.log(`Found exercise`, exercise);
});
var khanJS = require('khanacademyjs');
khanJS.exercises.getFollowupExercises(exerciseName, (err, response, followupExercises)=>{
console.log(`Found ${followupExercises.length} followup exercises`);
});
var khanJS = require('khanacademyjs');
khanJS.exercises.getVideos(exerciseName, (err, response, videos)=>{
console.log(`Found ${videos.length} videos`);
});
var khanJS = require('khanacademyjs');
khanJS.exercises.getPersusAutoComplete(exerciseName, (err, response, autoCompleteItems)=>{
console.log(`Found ${autoCompleteItems.length} autocomplete items`);
});