rbhl is an R interface to the Biodiversity Heritage Library API.

Info

Authentication:

  • Get your Biodiversity Heritage Library API key at https://www.biodiversitylibrary.org/getapikey.aspx
  • Put your API key either in your .Renviron file (or similar) with the name BHL_KEY, or your .Rprofile file with the name bhl_key, and we’ll use your API key without you having to enter it every time you run a search.

Documentation:

Installation

Stable version

Development version

remotes::install_github("ropensci/rbhl")
library("rbhl")

Output formats

You can output various formats using the as parameter, setting to table, list, json or xml.

The default is usually table:

bhl_authorsearch(name='dimmock')
#> # A tibble: 6 x 4
#>   AuthorID Name                 CreatorUrl                               Dates  
#>   <chr>    <chr>                <chr>                                    <chr>  
#> 1 189035   "Dimmock, Anna Kath… https://www.biodiversitylibrary.org/cre… <NA>   
#> 2 59023    "Dimmock, G"         https://www.biodiversitylibrary.org/cre… <NA>   
#> 3 189042   "Dimmock, Geo "      https://www.biodiversitylibrary.org/cre… <NA>   
#> 4 189021   "Dimmock, George"    https://www.biodiversitylibrary.org/cre… <NA>   
#> 5 1970     "Dimmock, George,"   https://www.biodiversitylibrary.org/cre… 1852-  
#> 6 8126     "Dimmock, George,"   https://www.biodiversitylibrary.org/cre… 1852-1…

list output

bhl_authorsearch(name='dimmock', as='list')$Result[[1]]
#> $AuthorID
#> [1] "189035"
#> 
#> $Name
#> [1] "Dimmock, Anna Katherina"
#> 
#> $CreatorUrl
#> [1] "https://www.biodiversitylibrary.org/creator/189035"

XML output

bhl_authorsearch(name='dimmock', as='xml')
#> [1] "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Status>ok</Status><ErrorMessage /><Result><Author><AuthorID>189035</AuthorID><Name>Dimmock, Anna Katherina</Name><CreatorUrl>https://www.biodiversitylibrary.org/creator/189035</CreatorUrl></Author><Author><AuthorID>59023</AuthorID><Name>Dimmock, G</Name><CreatorUrl>https://www.biodiversitylibrary.org/creator/59023</CreatorUrl></Author><Author><AuthorID>189042</AuthorID><Name>Dimmock, Geo </Name><CreatorUrl>https://www.biodiversitylibrary.org/creator/189042</CreatorUrl></Author><Author><AuthorID>189021</AuthorID><Name>Dimmock, George</Name><CreatorUrl>https://www.biodiversitylibrary.org/creator/189021</CreatorUrl></Author><Author><AuthorID>1970</AuthorID><Name>Dimmock, George,</Name><Dates>1852-</Dates><CreatorUrl>https://www.biodiversitylibrary.org/creator/1970</CreatorUrl></Author><Author><AuthorID>8126</AuthorID><Name>Dimmock, George,</Name><Dates>1852-1930</Dates><CreatorUrl>https://www.biodiversitylibrary.org/creator/8126</CreatorUrl></Author></Result></Response>"

JSON output

bhl_authorsearch(name='dimmock', as='json')
#> [1] "{\"Status\":\"ok\",\"ErrorMessage\":\"\",\"Result\":[{\"AuthorID\":\"189035\",\"Name\":\"Dimmock, Anna Katherina\",\"CreatorUrl\":\"https://www.biodiversitylibrary.org/creator/189035\"},{\"AuthorID\":\"59023\",\"Name\":\"Dimmock, G\",\"CreatorUrl\":\"https://www.biodiversitylibrary.org/creator/59023\"},{\"AuthorID\":\"189042\",\"Name\":\"Dimmock, Geo \",\"CreatorUrl\":\"https://www.biodiversitylibrary.org/creator/189042\"},{\"AuthorID\":\"189021\",\"Name\":\"Dimmock, George\",\"CreatorUrl\":\"https://www.biodiversitylibrary.org/creator/189021\"},{\"AuthorID\":\"1970\",\"Name\":\"Dimmock, George,\",\"Dates\":\"1852-\",\"CreatorUrl\":\"https://www.biodiversitylibrary.org/creator/1970\"},{\"AuthorID\":\"8126\",\"Name\":\"Dimmock, George,\",\"Dates\":\"1852-1930\",\"CreatorUrl\":\"https://www.biodiversitylibrary.org/creator/8126\"}]}"

Get title metadata

bhl_gettitlemetadata(1726, items = TRUE, as = "list")$Result[[1]]$Items
#> [[1]]
#> [[1]]$ItemID
#> [1] 16800
#> 
#> [[1]]$ItemUrl
#> [1] "https://www.biodiversitylibrary.org/item/16800"

Get languages

bhl_getlanguages()
#> # A tibble: 75 x 2
#>    LanguageCode LanguageName        
#>    <chr>        <chr>               
#>  1 AFR          Afrikaans           
#>  2 ARA          Arabic              
#>  3 ARC          Aramaic             
#>  4 MAP          Austronesian (Other)
#>  5 BUL          Bulgarian           
#>  6 BUR          Burmese             
#>  7 CAR          Carib               
#>  8 CAT          Catalan             
#>  9 CEL          Celtic (Other)      
#> 10 CHI          Chinese             
#> # … with 65 more rows

Meta