On this page
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:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion