2

Is there a way to get a json with the whole exercise tree using the API, like this (array or object)?

Math
    "Early Math"...
    ...
    "Algebra II"
       "Advanced Functions"
           "Determine the domain of funs"
           ...
           "Compare features of funs"
...

Tnx.

MaxD
  • 574
  • 3
  • 10

1 Answers1

1

The topictree endpoint has all of this information, and you can use the kind filter to show exercises (and topics). http://www.khanacademy.org/api/v1/topictree?kind=Exercise

You can also load individual topics to navigate the entire tree (not just videos and exercises). For example, this URL gets direct information about the "combining-functions" topic:

http://www.khanacademy.org/api/v1/topic/combining-functions?format=pretty

From there, you can see that there's a child article with ID "xd2620963". You can load JSON information about that article using the /api/v1/articles endpoint (which unfortunately isn't documented):

http://www.khanacademy.org/api/v1/articles/xd2620963?format=pretty

Or, with many topics, they will have child topics that you can navigate to.

(That format=pretty at the end just makes the JSON response a little more human-readable; you should leave it off when accessing the JSON programmatically.)

Alan Pierce
  • 4,083
  • 2
  • 22
  • 21
  • 1
    Is there any documentation on the tree structure? – MaxD Dec 12 '15 at 22:48
  • There's some documentation here: http://api-explorer.khanacademy.org/group/api/v1/topictree . But some of it is out of date, and unfortunately there isn't any field-by-field documentation. Generally, though, the tree consists of Topic values, which contain children, and those children can either be other Topics or Videos, and this nesting matches the structure of the content on the website. – Alan Pierce Dec 13 '15 at 00:55
  • Tnx, I got the whole tree. I also found that kind=Video gives another big json. However, for example here: [link](https://www.khanacademy.org/math/algebra2/manipulating-functions/combining-functions) there are three articles inside, and the Ex tree has no children for Topic=Combining Functions... how do I get that info about articles? – MaxD Dec 29 '15 at 06:42
  • You can use /api/v1/topic/ to load just that topic, which will include all articles, videos, exercises, etc that it directly contains. I edited my answer to explain that in more detail. – Alan Pierce Jan 02 '16 at 10:29
  • Tnx! Articles appear as part of tutorials, but is there a better way to get this info other than invoking 2k urls with the tutorial node_slug? (I am working with one of the translation teams, and trying to replicate the ex/descr/art/video tree, so that we can build a system to control the team tasks) – MaxD Jan 04 '16 at 06:20
  • Within the public API, I think that's the best you can do. You can try using http://www.khanacademy.org/api/v2/topics/topictree , which is a bit experimental still (not documented and may change in the future) but may be useful to you. Also, if you have contacts on the KA International team, you might try reaching out to them. We may be able to prioritize some engineering work to make things easier for you. – Alan Pierce Jan 05 '16 at 07:21
  • OK, for now v2 helps to know which topics have video/articles inside. Yes, we are in touch with i18n, but your info here has been very useful. – MaxD Jan 06 '16 at 00:23
  • @Alan_Pierce Today I downloaded the v1 tree; but now it's missing whole domains, like Arts&Hum, Econ, Partner, ... is this a bug, or is the tree being reorganized? Tnx. – MaxD Jul 01 '16 at 07:06
  • @Alan_pierce Also the v2 url (mentioned in your last comment) has been broken for the last few days – MaxD Jul 04 '16 at 01:27
  • I don't get why there isn't better documentation for the topic tree -- the json file is literally 60+ MB, a size that isn't really feasible to crawl through unless you already have experience with large JSON files – zthomas.nc Mar 04 '17 at 22:18
  • this is the best guide on Khan API I've found. I'm running on a similar problem than MaxD I've thought maybe I could add a question here. I'm working on an Android admissions app and what I need to do is a simple Khan search by keyword functionality where you just type a keyword and API retrieves all topics / exercises / videos containing that keyword, but it's been days struggling my head with this without being able to find a solution. Do you think it is possible without falling in the only way that is downloading a 70mb json file (what of course it's a craziness for a mobile app)?? – Diego Perez May 10 '17 at 17:07