I don't use the topic tree API call - it returns about 50 MB of data. I rather traverse the nodes of the tree individually using the API call "http://www.khanacademy.org/api/v1/topic/%s" where %s is the "node_slug" field, starting with a "node_slug" of "root".
From there you use the "children" and "child_data" entries to traverse the sub-nodes. "children" has the details and "child_data" basically just the order in which they appear.
For each node, there are two important fields to look at, "kind" and "render_type".
"kind" can have the values:
- "Topic"
- "Video"
- "Exercise"
- "Article"
- "Scratchpad"
- "Separator"
"render_type" can have the values:
- "Root"
- "Domain"
- "Subject"
- "Topic"
- "Tutorial"
- "UncuratedTutorial"
So, from "root" you iterate through the child nodes looking for nodes with "render_type" = "Domain". That will give you stuff like "math", "science", etc. Now you can use the "math" node to iterate through the subjects under it, looking for "render_type" = "Subject". Among those you will find 7th Grade, etc.
Note: Both domain and subject nodes have "kind" = "Topic", so you should make sure you check for these and then use the "render_type" to find the domain or subject distinction.
What I also do is to cache the JSON responses so that the application doesn't have to reload them from the website. I have an option to refresh them from the website when needed.
Then you can use the subject node to further iterate through its children for the videos, exercises, articles, etc.