Search code examples
wikipedia-apiwiktionary

Wiktionary API: Get tags for a word, and specify language


For example, if the word is dog, I want to get the following, but only the English section, not other language sections like ==Afrikaans==, ==Danish== and so on. What API should I use? I saw the API page, but it was difficult to understand. The only thing I could find was parse (https://en.wiktionary.org/w/api.php?action=parse&page=dog), but that gives me the HTML, not the tags, it has a warning "Unrecognized parameter: url", and I don't know how to specify the language.

[[Image:YellowLabradorLooking.jpg|thumb|A dog (a [[Labrador retriever]])]]

===Alternative forms===
* {{l|en|darg}}, {{l|en|dawg}}, {{l|en|dug}} {{qualifier|dialectal}}
* {{l|en|doggie}}, {{l|en|doggy}} {{qualifier|childish}}

===Pronunciation===
* {{a|RP}} {{IPA|en|/dɒɡ/}}
...

Solution

  • This looks to do what you want:

    https://en.wiktionary.org/w/api.php?action=parse&page=dog&section=1&prop=wikitext

    You probably want to check that it starts with ==English==, but I think if you are using en.wiktionary, section 1 will always be English.