npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

khan-graphql

v1.7.1

Published

Helper methods to get your data from Khan Academy

Downloads

45

Readme

khan-graphql

Helper methods to get your data from Khan Academy

The problem

Khan Academy shut down their API, leaving you wondering how you could continue to keep your student data in sync between your LMS and Khan Academy.

This isn't...

This is not like the full Khan API. It is not meant for use in user facing environments.

This is..

If you need to get your data from Khan Academy using a backend service, this is for you.

Setup

This is run on Node. It uses axios to log into Khan Academy, and stores the cookies with tough-cookie and axios-cookiejar-support. Once authenticated, you should be able to get various data through the /api/internal/graphql endpoints.

install with

npm i --save khan-graphql

Usage

const { KhanApi } = require("khan-graphql")

const CREDS = {
  identifier: "your coach account",
  password: "your password",
}

const main = async () => {
  let kapi = new KhanApi()

  // always authenticate before retrieving data
  await kapi.authenticate(CREDS.identifier, CREDS.password)

  // now that we are authenticated, we can retrieve data. Let's get the coach data
  // with a helper method
  let data = await kapi
    .getCoach()
    .then((res) => res.data)
    .catch((err) => console.error(err))

  console.log({ data: JSON.stringify(data, null, 2) })

  // or inspect the network calls in Chrome dev tools while on Khan Academy to find
  // another endpoint, and use that. See CONTRIBUTING.md for more details

  let payload = {
    operationName: "getClassList",
    variables: {},
    query:
      "query getClassList {\n  coach {\n    id\n    joined\n    studentLists: coachedStudentLists {\n      name\n      id\n      cacheId\n      key\n      topics {\n        id\n        slug\n        title: translatedTitle\n        iconPath\n        domainSlug\n        learnableContentSummary {\n          countExercises\n          __typename\n        }\n        __typename\n      }\n      autoGenerated\n      countStudents\n      topicTitle\n      classroomDistrictInfo {\n        id\n        isNweaMapSynced\n        __typename\n      }\n      __typename\n    }\n    demoClassProgress {\n      completed\n      selectedTopics {\n        id\n        slug\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n  user {\n    id\n    tosForFormalTeacherStatus\n    schoolAffiliation {\n      id\n      name\n      postalCode\n      location\n      __typename\n    }\n    affiliationCountryCode\n    __typename\n  }\n}\n",
  }
  let customData = await kapi.getGraphQL("/getClassList", payload)

  console.log({ customData })
}

main()

Contributing

I would gladly welcome any contributers to this project. There are many GraphQL endpoints on Khan Academy, with some great data. I would like to get some wrapper around those to make it easier to users to find their students' data.

Please see CONTRIBUTING.md for ideas on how you can help.