npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

duolingo-api

v1.0.2

Published

(Unofficial) Duolingo API - No Authentication

Downloads

10

Readme

(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
    • Find Profile ID

Usage

const Duolingo = require('duolingo-api');
const credential = {
    username: 'JohnDoe1',
    id: 123456789
};
// can also be {username: 'JohnDoe1}, or {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);
    // My Fields Data: {
    //     "courses": [
    //         {
    //         "placementTestAvailable": false,
    //         "healthEnabled": false,
    //         "learningLanguage": "ja",
    //         "crowns": 102,
    //         "xp": 6751,
    //         "id": "DUOLINGO_JA_EN",
    //         "authorId": "duolingo",
    //         "fromLanguage": "en",
    //         "title": "Japanese",
    //         "preload": false
    //       }
    //     ],
    //     "totalXp": 15385
    // };
});

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

// Gets raw metadata from duolingo. No pre/post-processing 
duolingo.getRawData();

// Gets processed metadata from duolingo. Post-processing of adding display name for achievements,
// Adding level for each course and adding total level based on XP.
duolingo.getProcessedData();

// Gets selected fields metadata
let fields = [];
duolingo.getDataByFields();

// Identifies which level based on xp.
let xp = 1650; // or "1650"
duolingo.translateXpToLevels(xp);

// Adds a "level" property to a list of objects, as long as "xp" field is present.
let courses = [];
duolingo.addLevelToCourses(courses);

// Adds a "displayName" property to a list of objects, as long as "name" field is present.
let achievements = [];
duolingo.translateAchievements(achievements);

Extra Info

  • 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()