@biblioteksentralen/oai-pmh-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@biblioteksentralen/oai-pmh-client

Usage

import { OaiPmhClient } from "@biblioteksentralen/oai-pmh-client";
import { pino } from "pino";

const log = pino(); // Any logger implementing the TypeScript Abstract Logger interface can be used.

const oaiPmhClient = new OaiPmhClient({
  url: "https://stord.bib.no/cgi-bin/oai",
  metadataPrefix: "marc21",
  log,
});

const options = { from: "2023-05-10" };
for await (const { record } of oaiPmhClient.listRecords(options)) {
  console.log(`Fetched record ${record.header.identifier}`);
  // doSomethingWithRecord(response.record)
}

The listRecords() method is implemented as an async generator and handles resumption and automatic retries under the hood. Custom timeout and retry options can be set when constructing the client. For example, to disable automatic retries, set attempts to 1:

const oaiPmhClient = new OaiPmhClient({
  url: "https://stord.bib.no/cgi-bin/oai",
  metadataPrefix: "marc21",
  log,
  retry: { attempts: 1 },
});

Error handling

If we receive an error from the OAI-PMH server, a OaiPmhError error will be raised, containing the OAI-PMH error. These are typically returned for invalid argument values or other client errors.

Readme

Keywords

none

Package Sidebar

Install

npm i @biblioteksentralen/oai-pmh-client

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

24.6 kB

Total Files

5

Last publish

Collaborators

  • hansjeigergram
  • danmichaelo-bs
  • jfulse
  • tjommy
  • winsvold