This project was started in 2017. Throughout the years, Duolingo changed their API significantly, rendering older versions of the code useless.
You can start using DuoApi in your project via JitPack.
First, add the repo
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Then, add the dependency
<dependency>
<groupId>com.github.llusx</groupId>
<artifactId>DuoApi</artifactId>
<version>0.1-beta</version>
</dependency>
Finally, enjoy!
Main class containing functionality for various operations allowed by Duolingo API.
You need to authenticate with Duolingo before being able to use DuoApi.
DuoApi duoApi = new DuoApi("<USERNAME>","<PASSWORD>");
It throws an java.lang.IllegalArgumentException: Incorrect username or password
if the credentials are incorrect.
duoApi.getCurrentLanguage();
This will return a string of the current language’s abbreviation. For example es
for Spanish.
duoApi.getLanguageFromAbbreviation("sv");
This will print the full name of the language. In this example you’ll get Swedish
.
duoApi.getLanguages(true);
Will return a List<String>
where the elements are abbreviations.
duoApi.getLanguages(false);
Will return a List<String>
where the elements are the full names.
Example:
List<String> fullLangs = duoApi.getLanguages(false);
System.out.println("Full names: " + fullLangs);
List<String> abbrLangs = duoApi.getLanguages(true);
System.out.println("Abbreviated: " + abbrLangs);
prints out:
Full names: [Esperanto, Spanish, Russian, Dutch, French, German, Hebrew, Swedish, Arabic]
Abbreviated: [eo, es, ru, dn, fr, de, he, sv, ar]
Use getKnownWords()
to get a List<String>
of known words in the current language being learned.
duoApi.getKnownWords();
New wrapper dataclass for information extracted from the DuoApi
class.
Singleton class to fetch url of the audio file for a word