Khan / khan-api

Documentation for (and examples of) using the Khan Academy API
http://www.khanacademy.org
378 stars 74 forks source link

api/v1/topictree - Video URLs, Slugs and JSON nestings #57

Closed kdadmin closed 11 years ago

kdadmin commented 11 years ago

Regarding api/v1/topictree:

There are 94 empty video download urls, like this:

"download_urls": { nothing here }

Also, below are some extended slugs, shown in the order recieved.

"coach-res" ----"science/projects/robots/Solderless-Spout-Bot" ----"science/projects/robots/Spider_bot" ----"science/projects/robots/Bit-zee" ----"science/projects/robots/Spout-Bot-with-Solder" "discovery-lab/robots" ----"science/projects/Reverse-Eng/reverse-engineering" ----"science/projects/Reverse-Eng/hair_dryer" ----"science/projects/Reverse-Eng/dvd_player" ----"science/projects/Reverse-Eng/digital_camera" "discovery-lab/Reverse-Eng" ----"science/projects/discoveries/magnetism ----"science/projects/discoveries/magnetic-fields ----"science/projects/discoveries/measure-magnets" ----"science/projects/discoveries/batteries" ----"science/projects/discoveries/Electromagnet" ----"science/projects/discoveries/resistance" ----"science/projects/discoveries/electromangetism-discovery" ----"science/projects/discoveries/electric_motor" ----"science/projects/discoveries/electrostatics" "discovery-lab/discoveries" "discovery-lab/Projectile_launcher" "discovery-lab/Thermodynamics" "discovery-lab/discovery-lab-2013" "discovery-lab/Discovery-Lab-2012" "discovery-lab"

The ones prefaced with ----, are indented (nested) one less time than the number of items in the slug. I'm refering to object nesting with curly braces, in JSON terms.

Perhaps the "science/projects" portion of the slug was meant to be "discovery-lab", which would be one less nesting.

For example: "science/projects/robots/Solderless-Spout-Bot" would be: "discovery-lab/robots/Solderless-Spout-Bot"

Do let me know what you think, as my parser currently treats the above as errors and discards the download.

Thanks,

tomyedwab commented 11 years ago

The empty download_urls list is accurate; we do not have a download link available immediately for newly posted videos, so API consumers need to handle that condition gracefully.

As for the extended_slug inconsistency, I just discovered the problem a few minutes ago and I hope it will be corrected by tomorrow. However, I'm not certain why you are relying on the length of the slug matching the nesting level in the structure, and I can readily imagine situations in the future where those might diverge, so going forward I advise you to reconsider using "extended_slug" at all. If you want the URL of the topic, use "relative_url".

kdadmin commented 11 years ago

Works fine now. Thanks.

I compare the parent-child relationship implied by JSON to that of the extended_slug, along with other tests, to validate the response.

I can drop the test easily enough, but would argue it's a good test of the structure and content of the response.