Page MenuHomePhabricator

Enable the MWAPI endpoint name to be defined via a variable (currently: endpoint name needs to be a constant)
Closed, ResolvedPublic

Description

Currently a request like the below throws an error: "java.lang.IllegalArgumentException: Endpoint name should be a constant"

SELECT *
WITH
{  
  SELECT ?link ?title ?endpoint
  {
    VALUES ?link { wd:Q8523541 }
    [] schema:about ?link; schema:isPartOf ?ws; schema:name ?title .
    MINUS { ?ws wikibase:wikiGroup "wikiquote" }    
    BIND( strbefore(strafter(str(?ws),"//"),"/") as ?endpoint)       
  }
} as %categories
WHERE
{  INCLUDE %categories
   SERVICE wikibase:mwapi {
        bd:serviceParam wikibase:api "Generator" .
        bd:serviceParam wikibase:endpoint ?endpoint .
        # bd:serviceParam wikibase:endpoint "eo.wikipedia.org" .
        bd:serviceParam mwapi:gcmtitle ?title .
        bd:serviceParam mwapi:generator "categorymembers" .
        bd:serviceParam mwapi:gcmprop "ids|title|type" .
        bd:serviceParam mwapi:gcmlimit "max" .
        ?article wikibase:apiOutput mwapi:title  .
        ?item wikibase:apiOutputItem mwapi:item .
        ?ns wikibase:apiOutput "@ns" .    
  }
}

To query several endpoints based on sitelinks on one or several items, it would be interesting if the endpoint name could be defined in a variable.

It would avoid to list specific endpoints in lines like:

bd:serviceParam wikibase:endpoint "eo.wikipedia.org" .

Event Timeline

Esc3300 created this task.Jul 21 2017, 1:51 PM
Restricted Application added projects: Wikidata, Discovery. · View Herald TranscriptJul 21 2017, 1:51 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Smalyshev triaged this task as Normal priority.Jul 22 2017, 12:04 AM
Restricted Application added a subscriber: PokestarFan. · View Herald TranscriptJul 22 2017, 12:04 AM
Smalyshev renamed this task from endpoint name can be a variable (currently: endpoint name should be a constant) to MWAPI endpoint name can be a variable (currently: endpoint name should be a constant).Jul 30 2018, 11:49 PM
Daniel_Mietchen renamed this task from MWAPI endpoint name can be a variable (currently: endpoint name should be a constant) to Enable the MWAPI endpoint name to be defined via a variable (currently: endpoint name needs to be a constant).Aug 14 2018, 11:12 PM

As PetScan has some troubles these days, I'm using query server/mwapi:generator "categorymembers" again.

This reminds that the above would be helpful.

Codewise, is this complex or just a matter in which step the variable is defined?

Esc3300 updated the task description. (Show Details)Jun 13 2019, 7:42 PM

I changed the sample in the description above.

Change 517160 had a related patch set uploaded (by Smalyshev; owner: Smalyshev):
[wikidata/query/rdf@master] Enable variable endpoint for MWAPI

https://gerrit.wikimedia.org/r/517160

Esc3300 updated the task description. (Show Details)Jun 15 2019, 5:59 PM

Change 517160 merged by jenkins-bot:
[wikidata/query/rdf@master] Enable variable endpoint for MWAPI

https://gerrit.wikimedia.org/r/517160

Smalyshev closed this task as Resolved.Wed, Jun 26, 5:54 AM
Esc3300 updated the task description. (Show Details)Wed, Jun 26, 11:49 AM

excellent. Works fine. Thanks.

BTW, I edited the sample above to exclude Wikiquote. It isn't supported, but I wont miss it.

Esc3300 updated the task description. (Show Details)Wed, Jun 26, 11:51 AM