Search code examples
apimediawikiwiktionary

Query Wiktionary only returns few words


I'm trying to get all spanish nouns from Wiktionary. I only need the titles, not the meaning of each word. Following other similar posts, I tried this query:

https://en.wiktionary.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Spanish_nouns&cmprop=title

But it only returns the 10 first:

 {
    "batchcomplete": "",
    "continue": {
        "cmcontinue": "page|4142414345524f0a4142414345524f|1173240",
        "continue": "-||"
    },
    "query": {
        "categorymembers": [{
                "ns": 0,
                "title": "aaleniano"
            },
            {
                "ns": 0,
                "title": "ab."
            },
            {
                "ns": 0,
                "title": "ababa"
            },
            {
                "ns": 0,
                "title": "abab\u00e1bite"
            },
            {
                "ns": 0,
                "title": "ababol"
            },
            {
                "ns": 0,
                "title": "abac\u00e1"
            },
            {
                "ns": 0,
                "title": "abacalera"
            },
            {
                "ns": 0,
                "title": "abacalero"
            },
            {
                "ns": 0,
                "title": "abacera"
            },
            {
                "ns": 0,
                "title": "abacer\u00eda"
            }
        ]
    }
 }

What should I do to get all the noun title's from A to Z?


Solution

  • You have to forward the value of cmcontinue to the next call as query parameter, in your case it would be cmcontinue=page|4142414345524f0a4142414345524f|1173240 :

    https://en.wiktionary.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Spanish_nouns&cmprop=title&cmcontinue=page|4142414345524f0a4142414345524f|1173240
    

    Check the api result

    Also, from this doc, you can set cmlimit=max in order to get the maximum result you can get for a single call. So the first call would be :

    https://en.wiktionary.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Spanish_nouns&cmprop=title&cmlimit=max
    

    Then, using cmcontinue:

    https://en.wiktionary.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Spanish_nouns&cmprop=title&cmlimit=max&cmcontinue=page|41434943414c41445552410a41434943414c4144555241|4536720