Getting Started

The following methods are available to search the British National Bibliography (BNB) published as Linked Open Data:

SPARQL is a query language for RDF; full details can be found on the W3C website.

The following sample SPARQL queries illustrate some of the ways to query the BNB. You may find it helpful to refer to the published book data model, the forthcoming book data model or the serial data model.  For clarity the PREFIX declarations in each query have been omitted. It should be assumed that each query is preceded by the following PREFIX declarations:

PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX bio: <http://purl.org/vocab/bio/0.1/>
PREFIX blt: <http://www.bl.uk/schemas/bibliographic/blterms#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX isbd: <http://iflastandards.info/ns/isbd/elements/>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdau: <http://rdaregistry.info/Elements/u/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX umbel: <http://umbel.org/umbel#>
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

Not all of these declarations are required for all of the queries but they declare all the prefixes that are likely to be useful when querying the BNB.

There are four graphs: one for books (<http://bnb.data.bl.uk/id/graph/BNBBooks>); one for serials (<http://bnb.data.bl.uk/id/graph/BNBSerials>), one for new and forthcoming books (<http://bnb.data.bl.uk/id/graph/BNBCIP>) and one for VoID descriptions (<http://bnb.data.bl.uk/id/graph/Void>). You may query all four graphs by default, or speficy a particular graph.

There are four datasets: BNBBooks (<http://bnb.data.bl.uk/id/data/BNBBooks>), BNBSerials (<http://bnb.data.bl.uk/id/data/BNBSerials>), BNBCIP (<http://bnb.data.bl.uk/id/data/BNBCIP>) and the union of the three: BNB (<http://bnb.data.bl.uk/id/data/BNB>). BNBBooks, BNBSerials, BNBCIP have each been internally de-duplicated but some triples are duplicated between datasets.

Sample query no. 1

How do I search for a book with ISBN 9780729408745?

SELECT ?book ?bnb ?title WHERE {

  #Match the book by ISBN
  ?book bibo:isbn13 "9780729408745";

  #bind some variables to its other attributes
  blt:bnb ?bnb;
  dct:title ?title.
}

This retrieves the URI for the book, title and BNB number.

Sample query no. 2

Find books on a particular subject, e.g. crystallography

SELECT ?book ?isbn ?title WHERE {
?book dct:subject <http://bnb.data.bl.uk/id/concept/lcsh/Crystallography>;
 bibo:isbn13 ?isbn;
 dct:title ?title.

}

This retrieves the URI for the book, the ISBN and the title.

Sample query no. 3

Find books by a particular author, e.g. Iain Banks

SELECT DISTINCT ?book ?title ?isbn WHERE {
?book dct:creator ?author ;
       dct:title ?title.
?author foaf:name "Iain Banks".
OPTIONAL {?book bibo:isbn10 ?isbn}
OPTIONAL {?book bibo:ibsn13 ?isbn}

}

This retrieves the URI for the book, the title and the ISBN.

Sample query no. 4

Find books by a particular author, e.g. C.S. Lewis, with the most recently published books returned first

SELECT DISTINCT ?book ?isbn ?title ?year WHERE {

  #Match all books with Lewis as an author
  ?book dct:creator <http://bnb.data.bl.uk/id/person/LewisCS%28CliveStaples%291898-1963>;

	bibo:isbn10 ?isbn;
        dct:title ?title;
        #match the publication event
        blt:publication ?publication.

  #match the time of the publication event
  ?publication event:time ?time.
  #match the label of the year
  ?time rdfs:label ?year          
}

#order by descending year, after casting year as an integer
ORDER BY DESC( xsd:integer(?year) )

This retrieves the URI for the book, the ISBN, the title and the year of publication.

Sample query no. 5

Find 50 books published in a particular place, e.g. York

SELECT ?book ?isbn ?title WHERE {
  ?place rdfs:label "York" .
  ?publication event:place ?place.
 ?book 
        blt:publication ?publication;
        bibo:isbn10 ?isbn;
        dct:title ?title.
}
LIMIT 50


This retrieves the URI for the book, the ISBN and the title.

Note: This query will retrieve duplicates as there are duplicate triples (in this particular case, two triples with rdfs:label "York" - one in the book graph and one in the serials graph) in the triplestore. To obtain de-duplicated results, either change the query to SELECT DISTINCT or query the book graph separately.