-
Notifications
You must be signed in to change notification settings - Fork 4
/
README.Rmd
157 lines (113 loc) · 4.86 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
output: github_document
editor_options:
chunk_output_type: console
---
```{r echo=FALSE}
knitr::opts_chunk$set(
warning = FALSE,
message = FALSE,
collapse = TRUE,
comment = "#>",
cache.path = "inst/cache/"
)
```
# `oai`: General Purpose 'Oai-PMH' Services Client <img src="man/figures/logo.png" align="right" width="20%" />
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![R-check](https://github.com/ropensci/oai/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ropensci/oai/actions/workflows/R-CMD-check.yaml)
[![cran checks](https://cranchecks.info/badges/worst/oai)](https://cranchecks.info/pkgs/oai)
[![codecov.io](https://codecov.io/github/ropensci/oai/coverage.svg?branch=master)](https://codecov.io/github/ropensci/oai?branch=master)
[![rstudio mirror downloads](https://cranlogs.r-pkg.org/badges/oai?color=2ED968)](https://github.com/r-hub/cranlogs.app)
[![cran version](https://www.r-pkg.org/badges/version/oai)](https://cran.r-project.org/package=oai)
[![](https://badges.ropensci.org/19_status.svg)](https://github.com/ropensci/software-review/issues/19)
`oai` is an R client to work with OAI-PMH (Open Archives Initiative Protocol for Metadata Harvesting) services, a protocol developed by the Open Archives Initiative (https://en.wikipedia.org/wiki/Open_Archives_Initiative). OAI-PMH uses XML data format transported over HTTP.
OAI-PMH Info:
* Wikipedia (https://en.wikipedia.org/wiki/Open_Archives_Initiative_Protocol_for_Metadata_Harvesting)
* OAI V2 specification (http://www.openarchives.org/OAI/openarchivesprotocol.html)
`oai` is built on `xml2` and `httr`. In addition, we give back data.frame's whenever possible to make data comprehension, manipulation, and visualization easier. We also have functions to fetch a large directory of OAI-PMH services - it isn't exhaustive, but does contain a lot.
OAI-PMH instead of paging with e.g., `page` and `per_page` parameters, uses (optionally) `resumptionTokens`, optionally with an expiration date. These tokens can be used to continue on to the next chunk of data, if the first request did not get to the end. Often, OAI-PMH services limit each request to 50 records, but this may vary by provider, I don't know for sure. The API of this package is such that we `while` loop for you internally until we get all records. We may in the future expose e.g., a `limit` parameter so you can say how many records you want, but we haven't done this yet.
## Install
Install from CRAN
```{r eval=FALSE}
install.packages("oai")
```
Development version
```{r eval=FALSE}
devtools::install_github("ropensci/oai")
```
```{r pkg-load}
library("oai")
```
## Identify
```{r identify}
id("http://oai.datacite.org/oai")
```
## ListIdentifiers
```{r list-identifiers}
list_identifiers(from = '2018-05-01T', until = '2018-06-01T')
```
## Count Identifiers
```{r count-identifiers, cache=TRUE}
count_identifiers()
```
## ListRecords
```{r list-records}
list_records(from = '2018-05-01T', until = '2018-05-15T')
```
## GetRecords
```{r get-records}
ids <- c("87832186-00ea-44dd-a6bf-c2896c4d09b4", "d981c07d-bc43-40a2-be1f-e786e25106ac")
get_records(ids)
```
## List MetadataFormats
```{r list-metadataformats}
list_metadataformats(id = "87832186-00ea-44dd-a6bf-c2896c4d09b4")
```
## List Sets
```{r list-sets}
list_sets("http://api.gbif.org/v1/oai-pmh/registry")
```
## Examples of other OAI providers
### Biodiversity Heritage Library
Identify
```{r bhl-identify}
id("http://www.biodiversitylibrary.org/oai")
```
Get records
```{r bhl-get-records}
get_records(c("oai:biodiversitylibrary.org:item/7", "oai:biodiversitylibrary.org:item/9"),
url = "http://www.biodiversitylibrary.org/oai")
```
## Acknowledgements
Michał Bojanowski thanks National Science Centre for support through grant 2012/07/D/HS6/01971.
## Meta
* Please [report any issues or bugs](https://github.com/ropensci/oai/issues).
* License: MIT
* Get citation information for `oai` in R doing `citation(package = 'oai')`
* Please note that this project is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By participating in this project you agree to abide by its terms.
```{r logo, include = FALSE, eval = FALSE}
library(hexSticker)
library(magick)
download.file(
"https://wiki.epc.ub.uu.se/download/thumbnails/34212946/images.png?version=1&modificationDate=1511952524492&api=v2",
dest = fig <- tempfile()
)
image_read(fig) |>
image_crop(geometry = "x90%") |>
image_write(path = fig2 <- tempfile())
sticker(
fig2,
package = "oai",
url = "https://docs.ropensci.org/oai/",
s_x = 1,
s_y = 0.83,
s_width = 0.7,
p_size = 25,
p_y = 1.5,
u_color = "#ffffff",
u_size = 5,
h_fill = "#0C0F2E",
h_color = "black",
filename = "man/figures/logo.png"
)
```