DuolingoClient

duolingo-client. DuolingoClient

A high-level client for the Duolingo API.

Constructor

new DuolingoClient()

Creates a new client. New instances are in a logged-out state.
Source:

Methods

(async) buyItem(itemId) → {Promise.<boolean>}

Buy an item for the logged-in user.

Requires authentication.

Parameters:
Name Type Description
itemId string The id of the item to buy.
Source:
Returns:
Returns true if the item was bought, or false if this user already has the item.
Type
Promise.<boolean>

(async) buyStreakFreeze() → {Promise.<boolean>}

Buys streak freeze for the logged-in user.

Requires authentication.

Source:
Returns:
Returns true if streak freeze was bought, or false if this user already has streak freeze.
Type
Promise.<boolean>

(async) getCourses() → {Promise.<Array.<Course>>}

Gets all available courses.
Since:
  • 2.0.0
Source:
Returns:
All available courses.
Type
Promise.<Array.<Course>>

(async) getCourseSkills(courseId, username)

Gets the skills taught in a course.

Requires authentication.

Note: This currently requires a user that is currently taking the course but the result does not include any user-specific data. This requirement may be dropped if a better Duolingo API is discovered.

Parameters:
Name Type Description
courseId string The course to get the skills from.
username string A user who is currently studying the course.
Since:
  • 2.0.0
Source:

(async) getShopItems() → {Promise.<Array.<Item>>}

Gets items available for purchase by the logged-in user.

Requires authentication.

Source:
Returns:
The items available.
Type
Promise.<Array.<Item>>

(async) getSkillWords(skillId) → {Promise.<Array.<String>>}

Gets the words taught in a skill.

Requires authentication.

Parameters:
Name Type Description
skillId string The id of the skill to get words from.
Since:
  • 2.0.0
Source:
Returns:
The words in the skill.
Type
Promise.<Array.<String>>

(async) getUser(username) → {Promise.<User>}

Gets a user by username.
Parameters:
Name Type Description
username string The username to fetch.
Source:
Returns:
The user.
Type
Promise.<User>

(async) login(username, password) → {Promise.<void>}

Logs in as a the specified user. Future API calls requiring authentication will use this user's credentials. Unauthenticated calls will still be made without credentials.

If previously logged-in, those credentials will be overwritten, effectively logging out.

Parameters:
Name Type Description
username string The username to login as.
password string The user's password.
Source:
Returns:
Type
Promise.<void>

logout() → {void}

Logs out and discards credentials.
Source:
Returns:
Type
void

(async) setCurrentCourse(courseId)

Switches the active course for the logged-in user.

Requires authentication.

Parameters:
Name Type Description
courseId string The course to switch to.
Since:
  • 2.0.0
Source:

(async) translate(courseId, words) → {Array.<Array.<string>>}

Translates a list of words from a course. Each word may have more than one possible translation.
Parameters:
Name Type Description
courseId string The id of the course that the words belong to.
words Array.<string> The list of words to translate.
Source:
Returns:
A list of translations for every word.
Type
Array.<Array.<string>>