query-773fdfe4285838c5a1320569cc743643

rq turtle/ttl

title:Find a reference from a specific URL SELECT ?statement ?subject ?subjectLabel ?property ?propertyLabel ?object ?objectLabel ?refURL WITH { SELECT DISTINCT ?subject WHERE { { SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "www.wikidata.org"; wikibase:api "Generator"; mwapi:generator "exturlusage"; mwapi:geulimit "500"; mwapi:geuquery "digitalcollections.nypl.org"; mwapi:geuprotocol "http"; mwapi:geunamespace "0" . ?title wikibase:apiOutput mwapi:title. } } UNION { SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "www.wikidata.org"; wikibase:api "Generator"; mwapi:generator "exturlusage"; mwapi:geulimit "500"; mwapi:geuquery "digitalcollections.nypl.org"; mwapi:geuprotocol "https"; mwapi:geunamespace "0" . ?title wikibase:apiOutput mwapi:title. } } BIND(IRI(CONCAT(STR(wd:), ?title)) AS ?subject) } } AS %items { INCLUDE %items .

hint:Query hint:optimizer "None".

?subject ?p ?statement . ?statement prov:wasDerivedFrom/pr:P854 ?refURL . FILTER (CONTAINS(str(?refURL), 'digitalcollections.nypl.org')) . # update orange/brown text to whatever URL string you want...keep the single 'quotes' also update URLs lines 7 and 12

?property wikibase:claim ?p . ?property wikibase:statementProperty ?ps . ?statement ?ps ?object .

SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title:Find a reference from a specific URL
SELECT ?statement ?subject ?subjectLabel ?property ?propertyLabel ?object ?objectLabel ?refURL {

{
  SELECT DISTINCT ?subject WHERE {
    {
      SERVICE wikibase:mwapi {
        bd:serviceParam wikibase:endpoint "www.wikidata.org"; wikibase:api "Generator"; mwapi:generator "exturlusage"; mwapi:geulimit "500"; mwapi:geuquery "digitalcollections.nypl.org"; mwapi:geuprotocol "http"; mwapi:geunamespace "0" .
        ?title wikibase:apiOutput mwapi:title.
      }
    } UNION {
      SERVICE wikibase:mwapi {
        bd:serviceParam wikibase:endpoint "www.wikidata.org"; wikibase:api "Generator"; mwapi:generator "exturlusage"; mwapi:geulimit "500"; mwapi:geuquery "digitalcollections.nypl.org"; mwapi:geuprotocol "https"; mwapi:geunamespace "0" .
        ?title wikibase:apiOutput mwapi:title.
      }
    }
    BIND(IRI(CONCAT(STR(wd:), ?title)) AS ?subject)
  }
}.



  ?subject ?p ?statement .
  ?statement prov:wasDerivedFrom/pr:P854 ?refURL .
  FILTER (CONTAINS(str(?refURL), 'digitalcollections.nypl.org')) .    # update orange/brown text to whatever URL string you want...keep the single 'quotes' also update URLs lines 7 and 12

  ?property wikibase:claim ?p .
  ?property wikibase:statementProperty ?ps .
  ?statement ?ps ?object .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?object"):::projected v4("?p") v6("?property"):::projected v7("?ps") v1("?refURL"):::projected v5("?statement"):::projected v3("?subject"):::projected v2("?title") a1((" ")) c3(["bd:serviceParam"]):::iri c19(["https"]):::literal c5(["www.wikidata.org"]):::literal c1(["digitalcollections.nypl.org"]):::literal c26(["en"]):::literal c16(["0"]):::literal c11(["500"]):::literal c9(["exturlusage"]):::literal c14(["http"]):::literal c18(["mwapi:title"]):::iri c7(["Generator"]):::literal f0[["contains(str(?refURL),'digitalcollections.nypl.org')"]] f0 --> v1 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c3 --"mwapi:endpoint"--> c5 c3 --"mwapi:api"--> c7 c3 --"mwapi:generator"--> c9 c3 --"mwapi:geulimit"--> c11 c3 --"mwapi:geuquery"--> c1 c3 --"mwapi:geuprotocol"--> c19 c3 --"mwapi:geunamespace"--> c16 v2 --"mwapi:apiOutput"--> c18 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c3 --"mwapi:endpoint"--> c5 c3 --"mwapi:api"--> c7 c3 --"mwapi:generator"--> c9 c3 --"mwapi:geulimit"--> c11 c3 --"mwapi:geuquery"--> c1 c3 --"mwapi:geuprotocol"--> c14 c3 --"mwapi:geunamespace"--> c16 v2 --"mwapi:apiOutput"--> c18 end end union0r <== or ==> union0l end bind1[/"concat(str('wd:'),?title)"/] v2 --o bind1 bind1 --as--o v3 v3 -->v4--> v5 v5 --"prov:wasDerivedFrom"--> a1 a1 --"pr:P854"--> v1 v6 --"mwapi:claim"--> v4 v6 --"mwapi:statementProperty"--> v7 v5 -->v7--> v8 subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c3 --"mwapi:language"--> c26 end