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

Is it possible to get the list of articles created by a user in SPARQL

3
PAC2 (talkcontribs)

Following the examples in the page https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI#Examples, I try to get the list of articles created by a user inside SPARQL. I've tried the following request :

SELECT ?title WHERE {
  SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:endpoint "fr‧wikipedia.org";
                     wikibase:api "Generator";
                     mwapi:generator "usercontribs"; 
                     mwapi:user "PAC2";
                     mwapi:show "new";.    
     ?title wikibase:apiOutput mwapi:title.
  } 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }    
}

Try it!

But this doesn't work. Is it possible to do it or not ?

Dipsacus fullonum (talkcontribs)

As you can see at API:Query "usercontribs" is only available in API action=query calls as a list parameter, and not as a generator. List queries are not a directly supported service for MWAPI. But a possible hack is that it is possible to make a query API call with both a generator and a list section. The drawback is that only one result can be fetched (to the same variables) per API call because the output configuration will be for the generator part of the call.

There is a recent example of an MWAPI call with a combined generator and list query for usercontribs at https://www.wikidata.org/wiki/Wikidata:Request_a_query/Archive/2021/02#Wikidata_items_I_created

PAC2 (talkcontribs)

Thanks for the tip. That's mysterious but really powerful. PAC2 (talk) 06:56, 3 March 2021 (UTC)

Reply to "Is it possible to get the list of articles created by a user in SPARQL"