New Khan API
So is there anyway to use the new API like the old one or is it permanently just for Khan guardians and staff to use? And if it is for public use, like the old one, then is there some project where someone explains how to use it?
So is there anyway to use the new API like the old one or is it permanently just for Khan guardians and staff to use? And if it is for public use, like the old one, then is there some project where someone explains how to use it?
how are the parents supposed to know if their children are doing enough? like how do we know if they finish the school year? there is no way for the parents to know and there is nobody to contact to ask these questions, there is no progress bars, nothing.
The old API was accessed with GET requests, which meant data could be loaded with an opaque response (without CORS enabled) by loading it in a <script> tag. That was always more of a hack than anything, but it worked well enough.
The new API uses POST requests, which means the <script> tag trick no longer works. You can still access the API from a server (which ignores CORS headers), but it can't be accessed from the kasandbox domain unless the CORS headers are added to the API responses. In other words, you can't use it from a KA program.
(On another note for the KA devs if they see this, the GraphQL "safe-list" system is really dumb; if you have a list of every request clients are making, and only allow those specific requests, then just make them REST endpoints and ditch the 2KB request bodies. The point of GraphQL is to request only the data you need, but you're forcing 3rd party users to request way more data than they need to match the safe list, which defeats the entire purpose of GraphQL. There's plenty of other ways to prevent DoS attacks that don't have this caveat.)
How does one get access to this new API? Is there a procedure to register with KA as an authorized 3rd party user to get API access?
Nah, there are no "authorized" 3rd party users. It's an internal API, same as the old one. You just copy the request from the developer console. You can delete everything except the body and method. If you change even a single character of whitespace in the body, then it won't work any more (because of the safe-list thing), so don't try to format it properly or anything.
For example, this would fetch my top 40 programs, but only works on www.khanacademy.org (from the dev console) or in Node.js:
await fetch("https://www.khanacademy.org/api/internal/graphql/projectsAuthoredByUser", {
"body": "{\"operationName\":\"projectsAuthoredByUser\",\"query\":\"query projectsAuthoredByUser($kaid: String, $pageInfo: ListProgramsPageInfo, $sort: ListProgramSortOrder) {\\n user(kaid: $kaid) {\\n id\\n programs(pageInfo: $pageInfo, sort: $sort) {\\n complete\\n cursor\\n programs {\\n id\\n key\\n authorKaid\\n authorNickname\\n displayableSpinoffCount\\n imagePath\\n sumVotesIncremented\\n translatedTitle: title\\n url\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n}\\n\",\"variables\":{\"kaid\":\"kaid_585930138674289802884730\",\"sort\":\"TOP\",\"pageInfo\":{\"cursor\":\"\",\"itemsPerPage\":40}}}",
"method": "POST",
}).then(res => res.json())
@nicoletellez01, I’m pretty sure you can see all of that by going to the learner’s profile and selecting “Progress” on the left side. Also, this is unrelated to the topic, you should’ve made your own support request (preferably directly to the KA team).
Vous devez vous connecter pour laisser un commentaire.