Get KA exercise hierarchy

2019-07-11 20:13发布

问题:

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.

回答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.)