@grimille/duolingo-js

0.4.1 • Public • Published

@grimille/duolingo-js [2021 UPDATE]

Use the Duolingo API and power up your Node.js application (non-official) This is WIP, feel free to contact me for additions or any issues. 🦉

Installation

Use npm to install this dependency. ⬇️⬇️⬇️

npm install @grimille/duolingo-js

Usage

Start by creating a client :

const { Duolingo } = require('@grimille/duolingo-js');
const client = new Duolingo(<username|email>, <password>);

And use async IFEE :

// ...
(async() => {
	// your code here
	
	let logged  =  await client.login(); // True / false
	let totalXP = client.getTotalXP(); //Get your total XP
	
	await client.setUser('RandomUser');
	
	totalXP = client.getTotalXP(); //Get "RandomUser"'s total XP
})();

Notice: If you don't use async, you'll block your main thread during querying.

Avalaible Methods

Retrieving the data asynchronously

  • loadSelfUserData() - Reload your own Duolingo data is the API. Done by default when login.
  • getUserData(username) - Get the full JSON payload of a Duolingo user.
  • setUser(username) - Load a user into the API (cache the data)

Using the cache when retrieved

  • getXpGoal() - Get the XP Goal (could be undefined)
  • getTotalXP() - Get the total XP earned of all courses
  • getStreak() - Get the current streak
  • getUsername() - Get the username
  • getDisplayName() - Get the display name
  • isPremium() - Get if the user is premium (Duolingo Plus) or not.

Todos

  • Implement new API calls (Buy a freeze… 👀)
  • More testing and more support
  • Tell me your needs

Links

Contributing

No contributions for the moment as the API is in working progress.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @grimille/duolingo-js

Weekly Downloads

9

Version

0.4.1

License

MIT

Unpacked Size

9.86 kB

Total Files

10

Last publish

Collaborators

  • grimille