Duolingo icon indicating copy to clipboard operation
Duolingo copied to clipboard

Mobile app API inventory

Open tschuy opened this issue 9 years ago • 9 comments

General

https://www.duolingo.com/api/1/version_info
https://www.duolingo.com/api/1/users/show?id=?????
https://www.duolingo.com/api/1/store/get_items

Skills:

  1. main skill page https://api.duolingo.com/api/1/skills/show?id=?????
  2. lessons https://api.duolingo.com/api/1/sessions?device=mobile&select_capable=true&offline=true&lesson_number=???&type=lesson&skill_id=????&speak_capable=true

Sentence: http://d2.duolingo.com/words/hints/de/en?sentence=plus+separated+words.&format=new It appears this API can take arbitrary sentences.

Other The cloudflare URL should be replaced with static.duolingo.com, which is the value returned by https://www.duolingo.com/api/1/version_info for the TTS CDN url.

tschuy avatar Jul 10 '15 04:07 tschuy

Fresh Login

There's a cookie, duo_ab, with some unknown value. it's included in the GET of the first request. My guess is some kind of device ID.

  1. https://www.duolingo.com/api/1/version_info

I log in.

  1. POST https://www.duolingo.com/login.
    • password: (password)
    • login: (username)

This request sets a cookie auth_tkt.

Response body: {'response': 'OK', 'username': (username), 'user_id': (user id)}

  1. GET https://www.duolingo.com/api/1/users/show?id={user_id}
  2. GET https://www.duolingo.com/api/1/version_info. The response body appears to be the same.
  3. GET https://www.duolingo.com/api/1/store/get_items.

After that, it starts getting the next available skills, including every lesson and their sentence audio.

tschuy avatar Jul 10 '15 05:07 tschuy

Switching Languages

  1. POST /api/1/me/switch_language
  • from_language: en
    • learning_language=fr

response body: an object with

  • languages (incl. ones not being learned, with current_learning set to True or False)
    • language_data
  • fr (or chosen language)
    • various info about the language, incl. skills. It's the same as the language_data returned by the users/show?id={user_id} endpoint.

tschuy avatar Jul 10 '15 05:07 tschuy

Looks like the mobile API is a much better base for writing the duolingo API than the web api, since it doesn't allow the developers to do things like embed their TTS url in the webpage.

tschuy avatar Jul 10 '15 05:07 tschuy

I've been writing some documentation here: http://tschuy.com/duolingo/duolingo.html

tschuy avatar Jul 10 '15 07:07 tschuy

@tschuy

http://tschuy.com/duolingo/duolingo.html

Is a broken link - are the docs up yet?

samwest88 avatar Jul 12 '15 12:07 samwest88

@samwest88 FYI http://tschuy.com/duolingo/ doesnt look recent

tylerwhipple avatar Nov 26 '15 09:11 tylerwhipple

@tylerwhipple @samwest88 it's on github: https://github.com/tschuy/duolingo/blob/master/docs/source/api/endpoints.rst I broke the Github Pages hosting for now, I'll get around to it eventually :P

tschuy avatar Nov 28 '15 03:11 tschuy

https://github.com/tschuy/duolingo/blob/master/docs/source/api/data.rst <-- explains a bit more about the data they return.

tschuy avatar Nov 28 '15 03:11 tschuy

Regarding the value of the cookie duo_ab: It refers to Duolingo's A/B tests and is two fields concatenated together. The first is a 40-byte hex-encoded (160 bits in binary) hash (probably SHA-1) of the second field. The second field is Base64-encoded JSON containing the following fields (as of this post):

  • schools_new_signup_test
  • web_branded_mobile_buttons_test
  • signup_modal_buttons_experiment
  • login_modal_experiment

Each field can be true or false independently.

CJDennis avatar Nov 12 '16 05:11 CJDennis