rdnb
is an R wrapper for the Deutsche Nationalbibliothek (German National Library) API, available at http://www.dnb.de. As the German central archival library, the German National Library is collecting, archiving, bibliographically classifying all German and German-language publications, foreign publications about Germany, translations of German works, and the works of German-speaking emigrants published abroad between 1933 and 1945.
All bibliographic data of the German National Library are provided free of charge and can be freely re-used under “Creative Commons Zero” (CC0 1.0) terms. The metadata and online interfaces are provided with no guarantee of their being continuous, punctual, error-free or complete, or of their not infringing the rights of third parties (e.g. personal rights and copyright).
A personal access token is required for usage and can be requested by sending an e-mail to the Interface Service (schnittstellen-service@dnb.de). The e-mail must include the required catalogue “Catalogue of German National Library (DNB) / Katalog der Deutschen Nationalbibliothek (DNB)” and the access option “via access token / über Zugangscode”.
If you do not want to enter your token for each R session, put the following in your .Renviron or .Rprofile file: DNB_TOKEN=PUTYOURTOKENHERE
.
About the DNB; About the interface and access requirements; The DNB web search
rdnb
is available on CRAN and GitHub. Install from CRAN:
install.packages("rdnb")
To install the development version from GitHub the devtools
-package is required.
if(packageVersion("devtools") < 1.6) {
install.packages("devtools")
}
devtools::install_github("chgrl/rdnb")
library(rdnb)
##
## This is rdnb 0.1-0
##
## Type changes("rdnb") to see changes/bug fixes, help(rdnb) for documentation
## or citation("rdnb") for how to cite rdnb.
##
rdnb
provides two approaches to expose a search. For common search requests use the simple dnb_search
function. More complex requests are possible using the dnb_advanced
function.
dnb_search
Use the title
parameter to search in titles, including subtitle, short title, volume title, etc.
single.title <- dnb_search(title="katze")
## 5895 records found (request limited to 10 records)
A vector of strings combines search terms. Strings in a vector are “OR”-combined by default. Logical operators can be changed by starting a string with +
or -
, thus the following code searches for titles containing one of “katze” or “kater”, “maus” but not “hund”.
multi.title <- dnb_search(title=c("katze", "kater", "+maus", "-hund"))
## 171 records found (request limited to 10 records)
Use the year
parameter to limit the year(s) of publication. Set year
to a single integer value to specify a single year. Set the parameter to a sequence to specify start and end. Or set the parameter to a vector of integer values to specify a set of years.
single.year <- dnb_search(title="katze", year=2015)
## 213 records found (request limited to 10 records)
sequence.of.years <- dnb_search(title="katze", year=2010:2015)
## 1149 records found (request limited to 10 records)
set.of.years <- dnb_search(title="katze", year=c(2010:2013, 2015))
## 929 records found (request limited to 10 records)
Publisher name and/or location may be limited by the publisher
parameter. Logical operators can be set as explained above.
single.publisher <- dnb_search(title="katze", publisher="kiepenheuer")
## 4 records found (request limited to 10 records)
single.publisher.location <- dnb_search(title="katze", publisher="*verlag leipzig*")
## 5 records found (request limited to 10 records)
pub.or.pub <- dnb_search(title="katze", publisher=c("kiepenheuer", "piper"))
## 27 records found (request limited to 10 records)
pub.and.pub <- dnb_search(title="katze", publisher=c("*kinder*", "+*berlin*"))
## 37 records found (request limited to 10 records)
pub.not.pub <- dnb_search(title="katze", publisher=c("pi*", "-piper"))
## 26 records found (request limited to 10 records)
Keyword (subjects, persons, locations, organisations, etc.) search is available using the keyword
parameter. Logical operators can be set as explained for title search.
single.keyword <- dnb_search(keyword ="katze")
## 4152 records found (request limited to 10 records)
keyword.or.keyword <- dnb_search(keyword=c("katze", "hund"))
## 10761 records found (request limited to 10 records)
keyword.and.keyword <- dnb_search(keyword=c("katze", "+hund"))
## 436 records found (request limited to 10 records)
keyword.not.keyword <- dnb_search(keyword=c("katze", "-hund"))
## 3716 records found (request limited to 10 records)
The DNB discriminates between several publication types:
The type
parameter can be specified as single string value (named above) or a vector of string values, that will be combined by “OR”. Short terms of the available types usually work.
single.type <- dnb_search(title="katze", type="books")
## 4548 records found (request limited to 10 records)
single.type.part <- dnb_search(title="katze", type="bio") # biographicaldoc
## no records found
set.of.types <- dnb_search(title="katze", type=c("books", "articles", "online"))
## 5181 records found (request limited to 10 records)
The DNB also archives publications in other languages than German, e.g. when they are about Germany or publicated in Germany. The language(s) can be filtered by ISO 639-2/B code, like “ger” (German), “eng” (English), “fre” (French), “spa” (Spanish) or “gsw” (Swiss German). A vector of string values is combined by “OR”.
single.language <- dnb_search(title="cat", language="eng")
## 540 records found (request limited to 10 records)
set.of.languages <- dnb_search(title=c("cat", "katze"), language=c("eng", "ger"))
## 3300 records found (request limited to 10 records)
Use the limit
parameter to set the number and optionally the starting point of the results returned. A single integer value (possible values: 1-100) specifies the number of results only. Use a vector of two integer values to specify the number of results (first value of vector) and the first result (1 or higher). Set limit
to “all” for a complete list of results.
first.result <- dnb_search(title="katze", limit=1)
five.results.starting.with.the.21st <- dnb_search(title="katze", limit=c(5, 21))
all.results <- dnb_search(title="katze", year=2016, limit="all")
Per default no results are printed. Set print
to TRUE
to print the data.frame
with the results.
cats <- dnb_search(title="katze", limit=3, print=TRUE)
## 5895 records found (request limited to 3 records)
## id link
## 1 1116362198 http://d-nb.info/1116362198
## 2 1120516579 http://d-nb.info/1120516579
## 3 1125403497 http://d-nb.info/1125403497
## author
## 1 Teckentrup, Britta (ill); Teckentrup, Britta (aut)
## 2 Frey, Alexander Moritz (aut)
## 3 Krokowski, Carola (aut)
## title subtitle
## 1 Alles Natur - Meine kleine Katze <NA>
## 2 Birl, die kühne Katze Ein Märchen
## 3 Blutwerte - Pferd, Hund, Katze Blutwerte verstehen!
## publisher year language isbn
## 1 Ars Edition, München 2017 ger 9783845815886
## 2 Elsinor Verlag, Coesfeld 2017 ger 9783942788373
## 3 Igelsburg Verlag, Habichtswald 2017 ger 9783941933200
## price pages
## 1 Pappe : EUR 7.99 (DE), EUR 8.30 (AT), CHF 11.90 (freier Preis) 16
## 2 Broschur : circa EUR 12.80 (DE), circa EUR 13.20 (AT) 88
## 3 : EUR 29.95 (DE), EUR 29.95 (DE), EUR 30.80 (AT), EUR 30.30 (AT) 2
## format edition keyword toc
## 1 17.3 cm x 17.3 cm <NA> <NA> <NA>
## 2 19 cm x 12 cm 1. Auflage, neue Ausgabe <NA> <NA>
## 3 <NA> 1. Auflage <NA> <NA>
## description
## 1 http://deposit.d-nb.de/cgi-bin/dokserv?id=992efedfe14a4b06ad7dc4f344cd9e87&prov=M&dok_var=1&dok_ext=htm
## 2 <NA>
## 3 <NA>
## cover
## 1 https://portal.dnb.de/opac/mvb/cover.htm?isbn=978-3-8458-1588-6
## 2 https://portal.dnb.de/opac/mvb/cover.htm?isbn=978-3-942788-37-3
## 3 https://portal.dnb.de/opac/mvb/cover.htm?isbn=978-3-941933-20-0
The following data is stored in the data.frame
(if available):
Variable | Description |
---|---|
id | DNB record ID |
link | link to record |
author | author(s) |
title | main title |
subtitle | subtitle |
publisher | publisher |
year | year of publication |
language | language (abbreviation) |
isbn | ISBN (13-digit or 10-digit) |
price | price (as string, usually prices for DE, AT and CH) |
pages | pages |
format | size and weight (partial) |
edition | edition |
keyword | keyword(s) |
toc | link to table of contents |
description | link to description |
cover | link to cover image |
dnb_advanced
dnb_advanced
allows for complex requests using the Contextual Query Language (CQL). See the DNB advanced search help pages for available indices and a list of examples.
The following advanced search returns a list of german or english children’s books titled with ‘cat’, excluding titles containing ‘dog’, since the year 2011:
cats <- dnb_advanced("( (tit=katze OR tit=kater NOT tit=hund) OR (tit=cat NOT tit=dog) ) AND jhr>2010 AND mat=books AND (spr=ger OR spr=eng) AND sgt=K", limit="all")
##
|
| | 0%
|
|====================================== | 59%
|
|========================================================= | 88%
|
|=================================================================| 100%
## 341 records found
Use n_rec
to get the total number of records found by a request:
n_rec(cats)
## [1] 341
To print the query used for a DNB-search, call print_query
:
print_query(cats)
## [1] "( (tit=katze OR tit=kater NOT tit=hund) OR (tit=cat NOT tit=dog) ) AND jhr>2010 AND mat=books AND (spr=ger OR spr=eng) AND sgt=K"
You can use this query (or an edited version) directly with the dnb_advanced
function:
cat.q <- print_query(cats)
cat.q <- gsub("jhr>2010", "jhr>=2015", cat.q) # change year
dnb_advanced(cat.q)
## 145 records found (request limited to 10 records)