npm.io
0.0.5 • Published 5 years ago

duolingo-api-js

Licence
MIT
Version
0.0.5
Deps
1
Size
11 kB
Vulns
25
Weekly
0
Stars
11

duolingo-js

Unofficial Duolingo API for browser and nodejs. This repo is heavily inspired by the Unofficial Python API found here. Credit to those folks. All http requests to duolingo return promises. Please read the documentation to find out which are and which are not promises.

I just started this wrapper for a side project. I will be updating the README and project as I go.

Make sure you use "type": "module" in your package.json

Installation

install with npm

npm install duolingo-api-js

Usage

import Duolingo from "duolingo-api-js";
const duo = new Duolingo({userName:'acspock', password:'password'});

duo.logIn()
    .then((result) => {
        duo.getData()
            .then(data => {
                //use returned data or use userData on duo instance
                console.log(duo.userData)
            })
            .catch(e => {
                //handle error
             });
    })
    .catch();

Documentation

Methods
Get User Information

duo.logIn()

Logs a user in

// Sample Request
duo.logIn()
    .then( data => {
        console.log('data', data);
    })
    .catch();

// Sample Response
 { response: 'OK', username: 'acspock', user_id: '11111' }

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Keywords