我如何访问我所有学生的数据?
How do I access data for all of my students?
我正在制作一个应用程序,用 KA 的 API 对教练进行身份验证,以便提供有关每个学生进度的统计数据和报告。
如何查看 "For whom am I a coach"(/api/v1/user.coaches
的倒数)?
或者以其他方式请求我所有学生的用户和进度数据?
您可以请求/api/v1/user/students
获取当前已验证用户的学生列表。请注意,这是一个未记录的端点,不确定这是不是故意的,但我怀疑这只是一个疏忽,因为 IIRC 我看到他们过去在 github 问题上引用过它。
我将该端点添加到此 PR 中的 khan
npm 模块:https://github.com/weo-edu/khan/pull/4
需要注意的一个重要警告是,截至撰写本文时,您无法代表已对您的应用程序进行身份验证的用户请求学生,只能代表创建您当前使用的应用程序的用户。
换句话说:如果我创建一个名为“hello”的应用程序,同时以“Jeffrey”身份登录,我可以通过使用“hello”应用程序进行身份验证来获得 Jeffrey 的所有学生。但是,如果我通过“hello”应用程序(通过 oauth,例如 passport-khan)以 Lisa 身份登录,我将获得一个访问令牌,但 Khan API 将拒绝我的请求,因为 Lisa 没有创建“你好”应用程序。
这种行为在 this wiki page 中有记录(虽然有点混乱),这里是相关段落:
It is recommended that schools have one teacher/coach account that registers for an API key. This enables a situation where the logged-in user is the same as the third-party developer, who then can access their own students' data pursuant to Khan Academy's "coach" relationship. For example, suppose the principal of Riverdale High wished to export data for multiple students via the API. The principal would create a teacher/coach account, perhaps called "RiverdaleHighAPI," and register for an API key. The principal would then ask all students of Riverdale High to add "RiverdaleHighAPI" as a coach, either directly or via several class codes. When accessing the API with "RiverdaleHighAPI" as the logged in user, the principal would be able to access the data for all students that have added "RiverdaleHighAPI" as a coach. The app would not have access to any other coaches' student data, even if another coach logged in through the app. To protect student privacy, we do not allow indirect consent through the coach, and we require each student to explicitly grant permission to access their data. Please note that we are working to improve this functionality; for the time being, this "RiverdaleHighAPI" account should only be used by the school's API client, not by any actual teacher or coach.
最后,khan 实际上鼓励 public 使用他们的内部 API。他们建议在登录 khan 时打开你的开发者控制台,并寻找 return 你想要的数据的端点。 (参见 this note on their authentication document)。
这显然是一种相当不标准的做法,我假设端点会在没有警告的情况下发生重大变化。此外,您将免费获得飞行文件。也就是说,对于您的目的而言,这种方法可能是最可靠的选择。这是他们的 wiki 为后代引用的引述:
The API explorer documents our public API, which has URLs starting with /api/v1, but unfortunately it's not very well-maintained and lacking in a few areas.
If you're feeling adventurous, though, you're welcome to use any internal undocumented API endpoints. For example, if you load a Khan Academy video page and use your browser's developer tools to look at the ajax requests being sent, you'll see that it gets a URL like /api/internal/videos/aubZU0iWtgI/transcript, which contains a JSON response with the video subtitles. That "internal" in the name means that we don't provide documentation, and we may remove the endpoint or change the format in the future, but you're welcome to use any internal endpoints if you keep those caveats in mind.
我正在制作一个应用程序,用 KA 的 API 对教练进行身份验证,以便提供有关每个学生进度的统计数据和报告。
如何查看 "For whom am I a coach"(/api/v1/user.coaches
的倒数)?
或者以其他方式请求我所有学生的用户和进度数据?
您可以请求/api/v1/user/students
获取当前已验证用户的学生列表。请注意,这是一个未记录的端点,不确定这是不是故意的,但我怀疑这只是一个疏忽,因为 IIRC 我看到他们过去在 github 问题上引用过它。
我将该端点添加到此 PR 中的 khan
npm 模块:https://github.com/weo-edu/khan/pull/4
需要注意的一个重要警告是,截至撰写本文时,您无法代表已对您的应用程序进行身份验证的用户请求学生,只能代表创建您当前使用的应用程序的用户。
换句话说:如果我创建一个名为“hello”的应用程序,同时以“Jeffrey”身份登录,我可以通过使用“hello”应用程序进行身份验证来获得 Jeffrey 的所有学生。但是,如果我通过“hello”应用程序(通过 oauth,例如 passport-khan)以 Lisa 身份登录,我将获得一个访问令牌,但 Khan API 将拒绝我的请求,因为 Lisa 没有创建“你好”应用程序。
这种行为在 this wiki page 中有记录(虽然有点混乱),这里是相关段落:
It is recommended that schools have one teacher/coach account that registers for an API key. This enables a situation where the logged-in user is the same as the third-party developer, who then can access their own students' data pursuant to Khan Academy's "coach" relationship. For example, suppose the principal of Riverdale High wished to export data for multiple students via the API. The principal would create a teacher/coach account, perhaps called "RiverdaleHighAPI," and register for an API key. The principal would then ask all students of Riverdale High to add "RiverdaleHighAPI" as a coach, either directly or via several class codes. When accessing the API with "RiverdaleHighAPI" as the logged in user, the principal would be able to access the data for all students that have added "RiverdaleHighAPI" as a coach. The app would not have access to any other coaches' student data, even if another coach logged in through the app. To protect student privacy, we do not allow indirect consent through the coach, and we require each student to explicitly grant permission to access their data. Please note that we are working to improve this functionality; for the time being, this "RiverdaleHighAPI" account should only be used by the school's API client, not by any actual teacher or coach.
最后,khan 实际上鼓励 public 使用他们的内部 API。他们建议在登录 khan 时打开你的开发者控制台,并寻找 return 你想要的数据的端点。 (参见 this note on their authentication document)。 这显然是一种相当不标准的做法,我假设端点会在没有警告的情况下发生重大变化。此外,您将免费获得飞行文件。也就是说,对于您的目的而言,这种方法可能是最可靠的选择。这是他们的 wiki 为后代引用的引述:
The API explorer documents our public API, which has URLs starting with /api/v1, but unfortunately it's not very well-maintained and lacking in a few areas.
If you're feeling adventurous, though, you're welcome to use any internal undocumented API endpoints. For example, if you load a Khan Academy video page and use your browser's developer tools to look at the ajax requests being sent, you'll see that it gets a URL like /api/internal/videos/aubZU0iWtgI/transcript, which contains a JSON response with the video subtitles. That "internal" in the name means that we don't provide documentation, and we may remove the endpoint or change the format in the future, but you're welcome to use any internal endpoints if you keep those caveats in mind.