KartikTalwar / Duolingo

Unofficial Duolingo API Written in Python
MIT License
825 stars 128 forks source link

Proposal: Add method to retrieve word's dictionary entry #68

Closed ghost closed 4 years ago

ghost commented 4 years ago

Duolingo exposes /api/1/dictionary_page?lexeme_id that will return the dictionary entry for the given lexeme_id. Sample response below:

{
    "alternative_forms": [
        {
            "case": null,
            "gender": null,
            "word": "जूलिया",
            "tts": "https://d1vq87e9lcf771.cloudfront.net/aditi/96ee15d0b8ad10ffbbdadf249d6089e1",
            "text": "यह जूलिया है।",
            "discussion": null,
            "number": null,
            "invalid": false,
            "highlighted": true,
            "translation_text": "This is Julia.",
            "link": "/dictionary/Hindi/%E0%A4%9C%E0%A5%82%E0%A4%B2%E0%A4%BF%E0%A4%AF%E0%A4%BE/eae018a989bee60a236427f4883015c2",
            "example_sentence": "यह जूलिया है।",
            "word_value_matched": true,
            "translation": "This is <span class=\"highlighted\">Julia</span>."
        }
    ],
    "has_tts": true,
    "word": "जूलिया",
    "language_information": {},
    "from_language_name": "English",
    "tts": "https://d1vq87e9lcf771.cloudfront.net/aditi/0aeea139ce8205bb4f38e88130b97bac",
    "learning_language": "hi",
    "translations": "Julia (female name)",
    "learning_language_name": "Hindi",
    "pos": null,
    "from_language": "en",
    "is_generic": false,
    "lexeme_id": "eae018a989bee60a236427f4883015c2",
    "canonical_path": "/dictionary/Hindi/%E0%A4%9C%E0%A5%82%E0%A4%B2%E0%A4%BF%E0%A4%AF%E0%A4%BE/eae018a989bee60a236427f4883015c2"
}

I propose adding get_word_definition_by_id(id) or some such method to make this request.

ghost commented 4 years ago

@KartikTalwar I would be happy to open a PR after some initial discussions

KartikTalwar commented 4 years ago

yes, that'd be great!

Irio commented 4 years ago

@jgolden17 Did you have the chance to work on that? Otherwise, I'm interested in bringing that function in.

ghost commented 4 years ago

@Irio This was completed with #69