Topic on Talk:Wikidata Query Service/User Manual/MWAPI

Document more Input params

8
Vladimir Alexiev (talkcontribs)

This page and Wikidata Query Service/User Manual#MediaWiki API give examples using the following params:

gsrsearch, gsrlimit, gcmprop, gcmlimit

Where are they documented?

The page says "It is permissible to add input parameters not specified in the configuration, they will be passed to the service query. Please refer to the API documentation for the lists of parameters each service has". I searched in API:Query#Generators and can't find them there.

It would be very useful for SPARQL devs to have a full list of params listed on this page, maybe with links to their definitions in the MW API page.

Smalyshev (WMF) (talkcontribs)

These are the same parameters you put in actual API request, e.g. when using API sandbox. There's no full list of parameters, because each API has its own parameters and those can be anything. So what I would suggest is using API tool - like API sandbox - first to assemble the API call and ensure it works properly, and then copy the parameter names/values from there to MWAPI call in WDQS.

Vladimir Alexiev (talkcontribs)

It would be very useful if you could illustrate finding info in the API sandbox. Eg I wanted to see the params for "Generator" but the sandbox field "action" doesn't have such choice. API:Query#Generators doesn't mention "gsrsearch".

Please make it easier for folk who know SPARQL but not MWAPI to use this exension. Thanks in advance!

120.21.201.69 (talkcontribs)

I agree with Vladimir - I found these through a random StackOverflow answer. Further attempts to understand how they work (or even what they are doing) have been fruitless, because seemingly there is zero - zip - nada - no documentation whatsoever. I can't even find the source code to read!

Mormegil (talkcontribs)
Vladimir Alexiev (talkcontribs)

I'm sure the interactive API and the automatically generated documentation are very useful as a reference, if you already know the MWAPI well. But they are hard to use if it's the first time you're trying MWAPI.

Mormegil (talkcontribs)

When you select action=query, a section for action=query appears in the main tree on the left. When you click the section, all available parameters for action=query are offered, and generator is among them. You can choose search in its dropdown; after that, the corresponding generator=search section appears in the main tree again. When you click on it, all parameters for generator=search appear, and among those, gsrsearch, gsrlimit. (gcmprop and gcmlimit are properties for generator=categorymembers, so, by choosing categorymembers for generator, and by clicking on generator=categorymembers which appears in the main tree, you’ll see offered those).

Vladimir Alexiev (talkcontribs)

Take a look at the Examples at the bottom of the last page:

Search for meaning.
api.php?action=query&list=search&srsearch=meaning [open in sandbox]
Search texts for meaning.
api.php?action=query&list=search&srwhat=text&srsearch=meaning [open in sandbox]
Get page info about the pages returned for a search for meaning.
api.php?action=query&generator=search&gsrsearch=meaning&prop=info [open in sandbox]

A novel user like me would have the following questions:

  • What's the difference between list=search and generator=search, and how do I know which to use in which case?
  • Why two links use srsearch but one uses gsrsearch, and how do I know which to use when?

What is even the difference between the 3 examples?

  • How is "search for" different from "search texts for"? The two examples return the same data
  • Ok, I get how the third call is different: it returns page title and metadata, not search hits. From this I can surmise that generator returns a list of pages, whereas list returns a list of search hits
Reply to "Document more Input params"