SPARQL API examples

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

The following examples illustrate SPARQL API usage.

Query builders

  // Does there exist a user by the name john.smith?
  sparql_ask()->
    where('?user', rdf::type, rdf_curie('drupal:user'))->
    where('?user', dc::title, 'john.smith');

  // Select the titles of all blog posts promoted to the front page
  sparql_select('?title')->
    where('?node', rdf::type, rdf_curie('drupal:node'))->
    where('?node', 'node:type', 'blog')->
    where('?node', 'node:promote', TRUE)->
    where('?node', 'node:title', rdf_var('?title'));

Help improve this page

Page status: Not set

You can: