Lately some of the articles have imbedded videos, but they are not listed in the JSON responses when querying the API; not even in a "related videos" type of attribute. Only the normal videos are available via the API.
Asked
Active
Viewed 52 times
1 Answers
1
Unfortunately I don't think there is. For our older articles, which are just a blob of HTML, /api/v1/articles/<id>
will give you a htmlContent
field will presumably contain some iframe
. For our newer articles, the perseusContent
field has the data we use to render it; I don't know that we document the format anywhere but the code that renders it is open-source so you could take a look at that, or just look at some actual articles with videos and see what they look like. Sorry we don't have a more direct way to do this!

Ben Kraft
- 494
- 3
- 9
-
What I actually want is the YouTube IDs of the videos. Now I have to go to each article and check if it has videos and then start them and right-click and copy URL to get it. A royal pain. Can't they add an 'imbedded-videos' or some such array to the JSON API result of the articles that in turn point to video structures? All other videos are 'documented' via the API - it would make sense to add these as well. (I use the YouTube IDs to download the videos for offline re-viewing later on - bandwidth is expensive in South Africa.) – Jannie Gerber Jun 02 '16 at 06:19
-
Unfortunately things aren't really set up on the backend to make that easy, at least not yet. I'd suggest just searching the `htmlContent` and `perseusContent` for URLs, say, matching the regex `https?://www.youtube.com/[^ "]*`, and extracting the Youtube ID from there. I believe at the moment that should find you all videos. In the future it's possible we'll change the format of `perseusContent` to just specify the Youtube ID, in which case you could just extract it from the JSON. – Ben Kraft Jun 03 '16 at 17:50
-
Thanks for your feedback. At least I found a way to get the YouTube IDs for the videos in the CS scratchpad tutorials - /api/internal/scratchpads/tutorial?verbose=false. Even though it's an internal specification and therefore not guaranteed to keep working. – Jannie Gerber Jun 05 '16 at 17:17
-
The [topic tree endpoint](http://api-explorer.khanacademy.org/group/api/v1/topictree) (which is documented, although I'm not sure if the particular fields you want are documented) should have the scratchpad YouTube IDs, too, I think. – Ben Kraft Jun 06 '16 at 22:37
-
1I checked it, but it doesn't contain them. Anyway, topictree is about 50MB - I don't want to download such a big file every time (bandwidth is still expensive here in South Africa and 3G can be slow with congestion.) scratchpads/tutorial?verbose=false is only about 144KB. – Jannie Gerber Jun 08 '16 at 07:01