6

I would like to get all the members of a specific category from Wikidata. For example, I would like to get all the films (instances of film: P31 Q11424) from the category "Category:Films set in Stockholm" (Q7519614). However, I can't seem to find what the relationship would be. DBpedia uses "subject of" but the Wikidata equivalent (P805) doesn't return any results.

I also thought I could bootstrap my way to the answer with this query, but to no avail:

SELECT ?s ?p ?pLabel WHERE {
  ?s ?p wd:Q7519614.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
user2987808
  • 1,387
  • 1
  • 12
  • 28
  • **DBpedia uses "subject of"** Note that when browsing DBpedia data, you'll often see "Foo prop of Bar" which means that the triple in the data is *Bar prop Foo*, not *Foo prop Bar*. Are you sure that the triple pattern `?s ?p wd:Q7519614.` is in the right direction? – Joshua Taylor Aug 24 '16 at 16:57
  • As @JoshuaTaylor said, "PROPERTY of" means the inverse direction, in your case `?o dcterms:subject ` instead of ` dcterms:subject ?o` – UninformedUser Aug 24 '16 at 18:27

2 Answers2

3

The API offers "Categorymembers" to get a List of pages that belong to a given category, ordered by page sort title. Parameters are documented here.

WBT
  • 2,249
  • 3
  • 28
  • 40
2

May be an indirect answer, but worth trying

When you look for the property related to an entity like Q7519614, it's often worth trying https://www.wikidata.org/wiki/Special:WhatLinksHere/Q7519614 (What links here?)

In this case the answer is empty which means there IS NO relation encoded in WIKIDATA for this information. (it means you need to rely on 3rd parties tool to access WIKIPEDIA information)

The second way to see your question is also encoded with P360 (is a list of)

In this case it says that it's a list of Film with (Q11424) with filming location (P915) equal to Stockholm (Q1754)

So the closest query you're looking at is

SELECT ?film 
WHERE { 
 ?film wdt:P31 wd:Q11424;
       wdt:P915 wd:Q506250.                    
}
innovimax
  • 440
  • 5
  • 8