Experimenting with the Khan Academy API

In the last month or so, I've managed to more than triple the number of Earth badges I have on Khan Academy just by focussing on getting the Sub-light Speed and 299,792,458 Meters per Second badges, particularly on the simple exercises. I worked out on which exercises to focus by creating a spreadsheet of all the exercises and all the badges I had for each exercise. I filled out the spreadsheet with a combination of screen-scraping and manual data-entry.

And after that, I wondered if there was an API for the Khan Academy, and of course there is. It is described here. Using the API you can find out all sorts of useful information. Using the oauth example, you can get your personal information to find out, for example, how many hours of video you've watched in total and how many questions you've attempted.

The text below is a now-out-of-date description of what I'd done when I wrote this blog post. I now have a still ugly app at http://whatbadgenext.appspot.com. I've left the text below as a record of what I did and what the stats at the time were.

Playlist times

Using the API, you can get a list of all the videos in each playlist and how long each lasts using, so you can work out how long each playlist is. You can also add all these together to get the total length of videos on Khan Academy (which at present is 19 days, four and half hours), although it's a slight overestimate as it will count videos in multiple playlists multiple times.

I've been also been experimenting with Google App Engine, and so far I've managed to make a very ugly table of Khan Academy playlist times, which you can see at: http://whatbadgenext.appspot.com/. It's not a hugely useful table, but it's interesting to see that there are 16 playlists for which you can get the Ludicrous Listener badge (assuming you don't rewatch any videos). I'm quite pleased to see that Linear Algebra is the longest playlist because it was the first playlist I watched all the way through. It's slightly scary to think that it's nearly a day and a half of video.

The page may take a while to load because it's quite inefficient and makes a new API call every time you visit the page. The reason for the app name is that I'm hoping to make an app that can tell you which badges you are closest to achieving, but first I need to sort out how to get OAuth to work on Google App Engine.

Using the OAuth example manually, I was able to find in which playlist I'm closest to getting a new Listener badge. I also discovered that, at the time of writing, I've watched nearly a week of videos on Khan Academy and done just over 28000 exercises. Which seems a lot.

Exercise Speeds

One question I've often wondered is how fast I need to answer exercises on Khan Academy to get one of the speed badges (Picking Up Steam etc.). The answer is in the API; you can see it at: http://whatbadgenext.appspot.com/exercise_times. This information will be essential for working out which badges are easily achievable, and which require more work. The most time consuming questions are the rate and kinematic problems, and various solving systems of equations exercises.

It's also interesting to note that the shortest times, as I write, are for the exercises Proportions 1 and Proportions 2, which are currently the newest exercises. This confirms what I had suspected, which is that it's almost impossible to get the speed badges for new exercises. Presumably, they wait until a sufficient number of people have tried the exercises so they can work out a suitable time. So many times, I've tried in vain to get a speed badge on a new, easy exercise, but failed even if I answer as quickly as I can type.

Something else I noticed after getting this information is that you don't necessarily get the speed badges even if you have completed the exercises within the time: you need to get them all in a single session. For example, even though I had previously done 60 exercises within the time limit, I still have to do another 75 before I get the 299,792,458 Meters per Second badge. I suspect this has something to do with when the program checks to see whether you've completed enough exercises, or maybe the streak is reset if the time limits are reset.

Comments

There is another point earner which you have missed Peter. For watching a video, you receive 750 points. The points scored are the same for every video, regardless of length. So watching a 2 minute video scores you the same points as watching a 20 minute video. So in theory, if you were able to identify the play time of each individual video via the api, you could speed up your point earnings by watching the shortest videos first.

That's a good point. I could make a list of the shortest videos relatively easily. What I've done so far is more focused on badges than points.

Thanks for that great website, but I'm having trouble using it today.

I am not able to login. Whenever I enter my details, and hit enter, it redirects to the page which says login.

I though maybe that the password was changed, but it is okay. I could log into Khan with my account, but not on your website.

You're right. I was messing about with it at the weekend and I don't know what I did. I've reverted to an older version so it should work now.

Yes, thank you. Its working now, although some information it gives is wrong.

Here - 

 

"You are successfully logged in as ↑←hkapur97→↓.

You have:

  • Been a member of Khan Academy for 62 days.
  • Earned 5,960,772 energy points and 8646 badges.
  • Watched 6 days 2 hr 16 min of video.

You will log out automatically when you close your browser, but you can also logout here."

 

I don't have 8646 badges. I know the number on top-right of my screen says that, but thats only because of a bug in some exercises, which gives you badges on every problem.  I actually have ~2500 badges or so only.

I can only use the data from the Khan Academy API. If they say you have 8646 badges, then I have no way to say otherwise.

hmm...anyways, thanks for the other data. I've already made 1 more sun badge, along with several more earth badges with the help of your site.

I noticed that if we replay a couple of videos simultaneously, we are not credited with the time we watch. But I guess thats alright...

I've reported the badge issue a problem to them. I hope they fix it soon. 1001 earth badges on the top-right of the screen doesn't make me value too much the one I get after doing 75 problems quickly and correctly in each exercise.

1) Awesome work!

2) The badge count bug discussed above has been fixed. Sorry about that! And thanks for the heads-up from both of you.

Your web page is absolutely amazing. Thank you very much for creating it.

Thanks Ben and Ray!

There's still a lot I'd like to add to the site, but it's slowly becoming useful (to me at least). At some point I should also try to make it look a little less ugly.

Thank you for this amazing site!

This page is great. I have been trying to create a report that lists exercises that have the lowest seconds_per_fast_problem values and that I do not yet have the 299,792,458 Meters per Second badge.

Are you willing to share your source? What language did you use?

Hi Ben,

I have some code that lists the exercises for which I need the speed of light badge and the predicted time based on seconds_per_fast_problem. I haven't put it on the website as it takes over a minute to get the data back from KA. The code is in Python. I can send it to you if you email me (use the Contact Me on the left hand side).

Hi Ben again,

I went through my code for looking for speed badges (like 299,792,458 Meters per Second) and found it wasn't so slow so have added it to my site: http://whatbadgenext.appspot.com/speed_badges. It should now show you want you want if you sign in.

Hi Peter,

Thanks so much for making this fantastic website.  I recently finished watching all of the K.A. videos and have done all of the math exercises.  I'm now in the process of earning all of the speed badges to get a Black Hole Badge.  

I was wondering if you are currently working on the site.  I have not been able to login over the past 12 hours.  Again, thank you for making this valuable tool.

Greg Boyle

Hi Greg,

I was working on it yesterday and accidentally broke it so only my development site worked. I didn't notice when I updated it as I was already logged in. Thanks for pointing it out, it should be fixed now.

I can't make it update for khan academy resources

Hiw do you get Guardian? I've flagged a lot of posts.

Hi Reid,

There seems to be a bug with Khan Academy resources, I think because it used to be a playlist of videos and now it is a group of playlists. Thanks for pointing it out, I'll see if I can fix it.

I got the Guardian badge because Khan Academy emailed me and asked if I wanted to help moderate the forums. I'm not sure what their selection process was, but I had flagged a lot of posts, voted on a lot of posts, and written a lot of highly voted answers. If you spend time making the forums better in that way it's possible they will also ask you, but I don't know for sure.

Thanks. By the way I have 

Been a member of Khan Academy for 297 days.

Earned 609,089 energy points and 411 badges.Watched 1 day 8 hr 15 min of video.I am nine.

It broke. It says all videos are discontinued even though they are not. Can you fix that?

Yeah, I know what's happened. I'll fix it when I get home this evening.

Thanks Peter I looked.

@ Ben Kamens Khan academy is broken everything is a blank page please fix nobody can get on it.

Hi Peter,

I've tried logging into the Khan Academy API for the last couple of days and receive a server error message.  Thought you would like to know.

Regards,

Greg

Hi Peter,

Although I was aware of KA over the past few years, I formally signed up DEC of last year. Talk about being addictive; I blazed through the math curriculum - videos, exercises and all - within a month!

As I went on the forum, I saw the great work you were doing there and was fortunate to learn out about your web site. Since then, it's been an invaluable resource in the "badge quest".

It's been a regular part of my routine and is usually rock solid, but seems to be down. Just a heads-up, in case it's not intentional - feels like a vital piece of my toolkit is missing. :)

Many thanks for your continued contributions to the KA movement.

Best,

Omman

Hi Omman,

Good to hear from you, it's nice to know people are using the site. Thanks for letting me know about the problem. I was working on the site over the weekend, making some minor fixes and managed to use up all my database usage for the day. It should be working now.

Hi Peter,

I was wondering if you could provide a link to where the badge requirements are in the Khan Academy code?  I just noticed that a few new badges have appeared.

Sun Badge - Da Vinci - Master 500 unique exercises.

Black Hole - Artemis.

I really want to look to see if they changed the requirements for Atlas and Tesla.  

Thanks for your help,

Greg Boyle

 

Hi Greg,

Yes, they have changed the requirements. I keep meaning to update my blog post, but I'm not sure I will reveal the secret as it doesn't seem right now. If you have access to KA's Phabricator then I can tell you where to find the code (if I can remember).

Why cant i log into khan academy? it keeps on saying that the webpage is out of date! this is soooo frustrating. you better fix it fast. 

 

Hi.

My name is John.

I joined 2 months ago.

And I have 1144443 energy points and watched 536 videos.

What are the requirements for Artemis?

Hello Peter Collingridge. I have been admiring you since long time ago.  Congrats on the Tesla badge. Could you please, please, please tell me the requirements for at least Artemis Black Hole Badge? On your program "Go" (Ba-duk), it doesn't work. Could you fix it? Thank you for everything.

Peter, please respond, thanks for the help on the draggable rectangle by the way. Will the requirements for Tesla change in the future? Because I'm trying so hard for it and the requirement might go out of reach. Link to my profile:

https://www.khanacademy.org/profile/donotlookatmyprofileyoustalker/

Hi Peter, your website isn't working right now. Whenever I try to log on it either directs me to a page that says Error: Server Error. The server encountered an error. This shows on Internet Explorer and Google Chrome. The other page it directs me to is sometimes a KA page that says "Oops, we made a mistake". There trying to fix it, etc. Please fix as I would like to try your website out.

Thanks, Amy

Post new comment

The content of this field is kept private and will not be shown publicly.