v0.6.2
Deno and Node.js API module for OAI-PMH.
Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
What is this?
It’s a “blazingly fast” OAI-PMH Version 2.0 API client module for Node.js and Deno.
Install for Node.js
npm i oai_pmh_v2
Note For Node.js users this is an ESM only module. Read more here and maybe here.
Example
// Node.js
import { OAIPMH, OAIPMHParser } from "oai_pmh_v2";
// Deno
import {
OAIPMH,
OAIPMHParser,
} from "https://deno.land/x/oai_pmh_v2/src/mod.ts";
// You can find OAI-PMH providers here (although a lot of them might be non functional):
// https://www.openarchives.org/Register/BrowseSites
const oaiPmh = new OAIPMH({
baseUrl:
"http://bibliotecavirtual.asturias.es/i18n/oai/oai_bibliotecavirtual.asturias.es.cmd",
});
const info = await oaiPmh.identify({ signal: AbortSignal.timeout(17000) });
console.log(info);
for await (
const records of oaiPmh.listRecords(
{ metadataPrefix: "marc21" },
{ signal: AbortSignal.timeout(17000) },
)
) {
// if records.metadata is not undefined, then it should be cast
// as expected type or better yet validated via for example a zod schema
console.log(records);
}
Warning Arrays require special attention because in XML there’s no distinction between single element array property or just a property with that element. Properties of type
T[]
should be defined asT | T[]
, and always checked withArray.isArray()
, unless absolutely sure the array is always of length 2 or greater.
Note Parsed XML attributes are prefixed with
@_
, while XML text is parsed into#text
property.
Find examples for all methods in examples directory. Some things are only documented via types for now.