Topic on Talk:Wikidata Query Service/Categories

Can we whitelist the endpoint ?

2
Jheald (talkcontribs)

Hi User:Smalyshev (WMF) !

Could we add the categories/sparql endpoint to the whitelist allowed for federation, so that it would be possible to make queries like

PREFIX gas: <http://www.bigdata.com/rdf/gas#>
prefix mediawiki: <https://www.mediawiki.org/ontology#> 

SELECT ?out ?depth WHERE {
    service <https://query.wikidata.org/bigdata/namespace/categories/sparql> {
        SELECT ?out ?depth WHERE {    
            SERVICE gas:service {
                gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" .
                gas:program gas:linkType mediawiki:isInCategory .
                gas:program gas:traversalDirection "Reverse" .
                gas:program gas:in <https://en.wikipedia.org/wiki/Category:Ducks>. # one or more times, specifies the initial frontier.
                gas:program gas:out ?out . # exactly once - will be bound to the visited vertices.
                gas:program gas:out1 ?depth . # exactly once - will be bound to the depth of the visited vertices.
                gas:program gas:maxIterations 8 . # optional limit on breadth first expansion.
           }
       }
   }
} ORDER BY ASC(?depth)

Try it!

or

prefix mediawiki: <https://www.mediawiki.org/ontology#> 

SELECT ?out ?depth WHERE {
    service <https://query.wikidata.org/bigdata/namespace/categories/sparql> {
        SELECT ?out ?depth WHERE {    
            SERVICE mediawiki:categoryTree {
                bd:serviceParam mediawiki:start <https://en.wikipedia.org/wiki/Category:Ducks> .
                bd:serviceParam mediawiki:direction "Reverse" .
                bd:serviceParam mediawiki:depth 5 .
            }
        }
    }
} ORDER BY ASC(?depth)

Try it!

Thanks! I have some people on en-wiki who would really like some Listeria pages for a set of queries, with articles in one particular category excluded. If federation were enabled, this ought to do the trick perfectly.

Smalyshev (WMF) (talkcontribs)

Yes, I've added those to whitelist and they'll be added to the production config after deployment on Monday.

Reply to "Can we whitelist the endpoint ?"