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

quizlet.js

v3.0.1

Published

Quizlet.JS is a node.js client for the Quizlet Live API

Downloads

37

Readme

Quizlet.JS

Version 3.0

Stable NPM:NPM

Stable GitHub:GitHub release

Installing

This package can be installed using NodeJS's package manager, npm.

npm install quizlet.js

Importing

To use the new ESM syntax, set your type to module in your package.json. Click me for more information

  • You can import the entire package into a single variable (esm)

    import * as Quizlet from 'quizlet.js'
  • You can import certain parts of the package into different variables (esm)

    import {Class, StudySet, User, Live, Folder} from 'quizlet.js'
  • You can also import this package into non-esm modules (commonjs)

    var Quizlet = await import("quizlet.js")

Features

  • StudySet (Quizlet.StudySet)

    One of the main things about Quizlet is the unique study sets. This class allows you to access these sets
    • Methods

      staticgetByID | Parameter | Type | Default | Description | |-----------|-------------------|----------|-------------| | id | string number | Required | The Set ID |

      Promise<StudySet>Gets a study set via it's ID

      await StudySet.getByID("123456")

      staticgetFromUser | Parameter | Type | Default | Description | |-----------|-------------------|----------|-------------| | id | string number | Required | The User ID |

      staticgetFromClass | Parameter | Type | Default | Description | |-----------|-------------------|----------|-------------| | id | string number | Required | The Class ID |

      Promise<StudySet[]>Gets all the sets that exist within a class

      await StudySet.getFromClass("123456")

      staticgetFromFolder | Parameter | Type | Default | Description | |-----------|-------------------|----------|-------------| | id | string number | Required | The Folder ID |

      Promise<StudySet[]>Gets all the sets that exist within a folder

      await StudySet.getFromFolder("123456")

      dynamicgetTermsNonePromise<Term>:PropertyTypeDescriptiontermPropertyTypeDescriptiontextstringThe content's textaudiostringThe content's audio (Always a TTS from my testing)The term's termdefinitionPropertyTypeDescriptiontextstringThe content's textaudiostringThe content's audio (Always a TTS from my testing)The term's definitionranknumberThe term's index, or rank in the setimagestringThe image URL of the term.setIdnumberThe ID of the set that this term belongs inidnumberThe ID of this termGets all the terms in a study set

      await mySet.getTerms()

      dynamicgetCreatorNonePromise<User>Gets the creator of a study set.

      await mySet.getCreator()
    • Properties

      urlstringThe set URLidnumberThe set's IDcreatorIdnumberThe ID of the set's creatortermLangstringThe languages of the terms in the setdefLangstringThe languages of the definitions in the settitlestringThe set title/namedescriptionstringThe set's descriptionthumbnailstringThe icon for the setnumTermsnumberThe number of terms in this set

  • User (Quizlet.User)

    The User class allows you to see details about users on Quizlet
    • Methods

      staticgetByID | Parameter | Types |Default| Description | |--- |--- |--- |-| | id | string number|Required | The user ID |

      Promise<User>Gets a user by their IDstaticgetByEmail | Parameter | Types |Default| Description | |----------- |---------- |-|------------------ | | email | string |Required| The user's email |

      Promise<User>Gets a user from a registered emailstaticgetByUsername | Parameter | Types | Description | |------------ |---------- |--------------------- | | username | string | The user's username |

      Promise<User>Gets a user from the user's usernamedynamicgetSetsNonePromise<StudySet[]>Gets all the sets that a user has createddynamicgetClassesNonePromise<Class[]>Gets all the classes that the user is a member ofdynamicgetFoldersNonePromise<Folder[]>Gets all the folders that the user has sets in

    • Properties

      | Property | Types | Description | |--- |--- |--- | | id | number | The user's ID | | username | string | The user's username | | avatar | string | The URL to the user's display image | | numClasses | number | The number of classes that this user is a memberof | | type | 0 1 2 | The type of the user this is. 0 means that the user is a student.2 means that the user is a teacher.If you find out what 1 means for the user, please let me know |

  • Class (Quizlet.Class)

    The Class class allows you to access classes created within Quizlet
    • Methods

      staticgetByID | Parameter | Types | Default | Description | |----------- |------------------- |---------- |-------------- | | id | string number | Required | The class ID |

      Promise<Class>Gets a class by its IDstaticgetByCode | Parameter | Type | Default | Description | |----------- |---------- |---------- |----------------------- | | code | string | Required | The class's join code |

      Promise<Class>Gets a class by its join codestaticgetFromSchool | Parameter | Types | Default | Description | |----------- |------------------- |---------- |-------------- | | id | string number | Required | The school's ID |

      Promise<Class[]>Gets all the classes in a schoolstaticgetFromUser | Parameter | Types | Default | Description | |----------- |------------------- |---------- |-------------- | | id | string number | Required | The user's ID |

      Promise<Class[]>Gets all the sets that a user has createdstaticgetClassesNonePromise<Class[]>Gets all the classes that the user is a member ofdynamicgetMembersNonePromise<User[]>Gets all the members of a classdynamicgetSetsNonePromise<Set[]>Gets all of the sets linked to the class

    • Properties

      | Property | Type | Description | |--------------- |---------- |------------------------------------- | | id | number | The class's ID | | title | string | The class's title/name | | description | string | The class's course description | | creatorId | number | The ID of the class's creator | | numMembers | number | The number of members in this class | | numSets | number | The number of sets in this class |

  • Folder (Quizlet.Folder)

    The Folder class allows you to see folders made by the many users of Quizlet
    • Methods

      staticgetByID | Property | Type | Default | Description | |---------- |---------- |---------- |----------------- | | id | number | Required | The folder's ID |

      Promise<Folder>Gets a folder by its IDstaticgetFromUser | Property | Type | Default | Description | |---------- |---------- |---------- |----------------- | | id | number | Required | The user's ID |

      Promise<Folder[]>Gets all the folders that belong to a userdynamicgetCreatorNonePromise<User>Gets the creator of a folderdynamicgetSetsNonePromise<Set[]>Gets all of sets in a folder

    • Properties

      | Property | Type | Description | |--------------- |---------- |-------------------------------------- | | id | number | The folder's ID | | creatorId | number | The ID of the folder's creator | | title | string | The folder's name | | description | string | The folder's description | | url | string | The folder's publicly accessible URL |

  • Live (Quizlet.Live)

    When using this package to join any kind of Quizlet Live game, the classes should be setup in the following mannor:
    // First, create a new instance of "Classic" or "Checkpoint"
    /* Quizlet Checkpoint game pins start with the letter "C" (CXX-XXX), any other pins are Quizlet Live game pins */
    const game = new Quizlet.Live.Classic();
    
    // Once your class is initialized, setup all the events
    /* Refer to each individual class's documentation to see what events are supported */
    game.on("question", (question, options) => {
        // Both Classic and Checkpoint game modes have this event, but each event behaves differently.
        // The main thing throughout both classes is that it is highly recommended to call the `game.answer(...)` method from within this event
        game.answer(options[0])
    })
    
    // After your events are prepared, you can go ahead and join the game
    game.joinGame("XXXXXX" /* The game pin */, "RedYetiDev" /* username */, "https://assets.quizlet.com/...." /* Your avatar */)
    • Classic (Quizlet.Live.Classic)

      • Methods

        staticgetGame | Parameter | Type | Default | Description | |---------- |---------- |--------- |-------------- | | code | number |Required | The game code |

        Promise<Object>Gets a game via it's code (The return object is not typed, as you won't really ever need it, but typings may be added in the future)dynamicjoinGame | Parameter | Type | Default | Description | |---------- |---------- |-------------------------------------------------------------------------------------------- |---------------------------------------------------------------------------------------------------- | | pin | number | Required | The game pin | | name | string | "Quizlet.JS Bot" | The username to join with | | image | string | "https://assets.quizlet.com/a/j/dist/app/i/live_game/default-avatar.610344da6feae31.png" | The avatar to use when joining. (This avatar's URL must have the root domain of *.quizlet.com) |

        dynamicanswer | Parameter | Types | Description | |----------- |-------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | answer | string number Term | string: If answer is of type string, it is considered to be the content text of the correct answernumber: If answer is of type number, it is considered to be the index of the correct answer in the options array returned from the question event.Term: If answer is an instance of Term, it is considered to contain the same text content of the correct answer |

      • Properties

        | Property | Types | Description | |---------------- |------------ |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | active | boolean | Whether the game currently active | | pin | string | The game pin | | gamemode | 0 1 | Whether the game is a Classic game (1) or a Checkpoint game (0) | | name | string | The username that game is joining with | | image | string | The avatar that the user is using to join the game | | token | string | The multiplayer join token for the game | | id | string | The user's unique ID (Similar to a UUID) | | gameInstance | object | The game instance | | statuses | string[] | The status that are currently being sent between the client and the server | | socket | Socket | The socket that connects the client to the server (a Socket.IO connection) | | set | StudySet | The set that the host is using to play Quizlet Live | | terms | Term[] | The terms that currently in play. The length of this array can range between 6 and 12 | | type | number | Whether the game is a singleplayer game (2), or a multiplayer game (not 0) | | teams | object[] | The teams in the game | | team | object | My team in the game | | index | number | The currently active question's index | | streak | number | How many attempts a team has made. Your team starts the game with a streak of 0 When your team gets a question wrong, and you have to start over, your streak increments by 1 | | players | object | All the players within the game | | gameOptions | object | The game's settings |

      • Events

        answer | Property | Types | Description | |---------------- |----------- |---------------------------------------------------- | | streak | number | The streak is how many tries the team has taken | | index | number | The index of the question that was answered | | isCorrect | boolean | Whether the question was answered correctly or not | | answeredBy | object | The player object of the question's answerer | | answeredWith | Term | The term that the player chose as their answer | | answeredAt | Date | The exact moment that the question was answered |

        replayNoneFired when the host replays the gamelobbyNoneFired when the host moves the game into the lobby, or when the player joins the lobbyteams | Property | Types | Description | |------------ |------------ |---------------------------------- | | myTeam | object | The team that the client is on | | allTeams | object[] | All of the teams within the game |

        endedNoneFired when the game endsstartNoneFired when the game startsquestion | Property | Types | Description | |------------ |----------------------- |------------------- | | question | Term | The question term | | options | Term[] | The option terms |

        Fired when it is time for the client to answer a question. (It is highly recommended that the answer method be called within the listener for this event)

    • Checkpoint (Quizlet.Live.Checkpoint)

      • Methods

        dynamicjoinGame | Parameter | Type | Default | Description | |---------- |---------- |-------------------------------------------------------------------------------------------- |---------------------------------------------------------------------------------------------------- | | pin | number | Required | The game pin | | name | string | "Quizlet.JS Bot" | The username to join with | | image | string | "https://assets.quizlet.com/a/j/dist/app/i/live_game/default-avatar.610344da6feae31.png" | The avatar to use when joining. (This avatar's URL must have the root domain of *.quizlet.com) |

        dynamicanswer | Parameter | Types | Default | Description | |----------- |-------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | answer | string Content | Required | string:If answer is of type string, it is considered to be the content text of the correct answerContent:If answer is an instance of Content, it is considered to contain the same sub-content as the correct answer |

      • Properties

        activebooleanWhether the game is currently runningpinnumberThe game pingamemode0 1Whether the game is a Checkpoint (0) or a Classic (1) gamenamestringThe display name that the client is joining the game withimagestringThe URL of the avatar that the client is joining the game withtokenstringThe checkpoint game token that the client needs to connect to serveridstringThe player's starting connection id (This id is only used for socket connection. For everything else, the uid property is used)socketSocketThe socket that connects the client to the server (A Socket.IO socket)uidstringThe player's internal IDcqPropertyTypesDescriptionpromptContent: | Property | Types | Description | |---------- |---------- |------------------------------------------------------------- | | text | string | The content's text | | image | string | The URL to the content's image | | audio | string | The URL to the content's audio (Usually a Text-To-Speech) |

        answernumber stringThe question's answeroptionsContent[]The question's possible answersidnumberThe item ID for the questiontype"WrittenQuestion" "MultipleChoiceQuestion"The question type. (See Excluded Features the question types that are not supported])The current question dataisCorrectbooleanWhether you were correct on the last question that you answered

      • Events

        joinNoneFired when the client joins the gameendNoneFired when the game has endedstartNoneFired when the game startsanswerisCorrectFired when the answers have been gradeddisconnect | Property | Types | Description | |---------- |------- |----------------------- | | reason | * | The disconnect reason |

        questioncqFired when it is time for the client to answer a question

Excluded Features

The following features are not supported by Quizlet.JS at this time. I do not have Quizlet+, and am unable to implement these features.

Most of these features are only available with Quizlet+

  • SeparatedOptionMatchingQuestion
  • FillInTheBlankQuestion
  • MixedOptionMatchingQuestion
  • RevealSelfAssessmentQuestion
  • TrueFalseQuestion
  • SpellingQuestion
  • FITBTextSegment
  • FITBWrittenBlankSegment
  • LocationAttribute

Licensing Information

This package is licensed under an MIT License by RedYetiDev.

That does mean that if you intend to extend on this package, you do need to provide proper credit.

Here is an example of what proper credit can look like:

[Quizlet.JS](https://github.com/RedYetiDev/Quizlet.JS) was created by [RedYetiDev](https://github.com/RedYetiDev)

Quizlet.JS was created by RedYetiDev


Credit

Got is a great Node.JS web requests package by Sindresorhus

Socket.IO is also a really cool WebSocket client and server software