(Unofficial) Duolingo API (No Auth)
This api will get your Duolingo profile's metadata. Will not require any
authentication. You will only need your username or profile ID.
To find your profile ID...
- log into duolingo.com through your
browser.
- Right-click, inspect on your profile picture.
- and then it should be the string of numbers after the
/avatars/
path
- e.g. //duolingo-images.s3.amazonaws.com/avatars/123456789/Pn_6nmPqRS/medium
- 123456789 is the profile ID in this example
Usage
const Duolingo = require('duolingo-api');
const credential = {
username: 'JohnDoe1',
id: 123456789
};
let duolingo = new Duolingo(credential);
Only one identifier is required, either username
or id
.
username
property can be empty or omitted, if you are providing an id
.
id
property can be empty or omitted, if you are providing a username
.
Get By Fields
const availableFields = [
"name", "emailVerified", "learningLanguage", "globalAmbassadorStatus",
"username", "streak", "canUseModerationTools", "hasPhoneNumber",
"observedClassroomIds", "joinedClassroomIds", "courses",
"privacySettings", "bio", "inviteURL", "id", "hasPlus",
"roles", "_achievements", "currentCourseId", "creationDate",
"picture", "fromLanguage", "hasFacebookId", "optionalFeatures",
"hasRecentActivity15", "hasGoogleId", "totalXp", "achievements"
];
If you want to see an example of what each fields' data populates,
look at UnauthenticatedFullResponse.json
If you're only wanting a select number of fields, create an array of fields that you want.
Then use getDataByFields()
method.
In this example, I only want the totalXp
and courses
fields.
async function getMyFields() {
const myFields = ['totalXp', 'courses'];
return await duolingo.getDataByFields(myFields);
}
getMyFields.then(data => {
console.log('My Fields Data: ', data);
});
Get All (raw) Metadata
If you just want all the metadata (as-is) available to you, then use the getMetadata()
method.
async function getMetadata() {
return await duolingo.getRawData();
}
getMetadata.then(data => {
console.log('My Metadata: ', data);
});
The data would print out something similar to UnauthenticatedFullResponse.json.
The output is the raw format/values of what the duolingo unauthenticated response will give.
Get All (processed) Metadata
Some things it doesn't include is friendlier display names for your achievements,
and the legacy levels that it once had. Levels eventually got replaced by Crowns
on how Duolingo would track progress.
async function getMetadata() {
return await duolingo.getProcessedData();
}
getMetadata.then(data => {
console.log('My Processed Metadata: ', data);
});
data
will give a result similar to UnauthenticatedProcessedResponse.json.
Endpoints
duolingo.getRawData();
duolingo.getProcessedData();
let fields = [];
duolingo.getDataByFields();
let xp = 1650;
duolingo.translateXpToLevels(xp);
let courses = [];
duolingo.addLevelToCourses(courses);
let achievements = [];
duolingo.translateAchievements(achievements);
- legacy/modern achievements
- based on my observation, most of the achievements being passed back by noauth/auth responses;
it is still using legacy and doesn't include the current implementation of achievements.
- experience to level table
- this table was used on how I converted XP to Levels when calling
getProcessedMetadata()