Constructor
new DuolingoClient()
Creates a new client. New instances are in a logged-out state.
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. |
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.
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.
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. |
(async) getShopItems() → {Promise.<Array.<Item>>}
Gets items available for purchase by the logged-in user.
Requires authentication.
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. |
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. |
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. |
Returns:
- Type
- Promise.<void>
logout() → {void}
Logs out and discards credentials.
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. |
(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. |
Returns:
A list of translations for every word.
- Type
- Array.<Array.<string>>