npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

viaf-wrapper

v0.1.4

Published

Wrapper for the VIAF XML API

Downloads

1

Readme

VIAF Wrapper

Build Status

A NODE API wrapper for the VIAF.org search and get XML endpoints. A tool for bibliographic authority control.

npm install viaf-wrapper --save

In node:

var viaf = require('viaf-wrapper')

viaf.searchPreferredName("Jack Kerouac")
  .then(function(records){

  	for (var x in records){
  		console.log(records[x])
  	}

  })
  .fail(function(error){
  	console.log(error))
  })

Callback method is also supported.

On the command line install by installing it globablly:

npm install viaf-wrapper -g

Command line execute:

$ viaf searchPreferredName "Jack Kerouac"

You can pipe it into jq for example:

$ viaf searchPreferredName "Jack Kerouac" | jq '.[0]'

Use viaf --help for all command line options


API

Several search modes are supported by the wrapper:

var viaf = require('viaf-wrapper')

//Search All Fields
viaf.searchAny

//The server chooses which index to search using this value
viaf.searchServerChoice

//Corporate names
viaf.searchCorporate

//Geographic names (only jurisdictional names so far)
viaf.searchGeographic

//Search LCCN (Library of Congress Number) headings
viaf.searchLCCN

//Search in preferred name headings
viaf.searchPreferredName

//Search all name headings
viaf.searchNames

//Search all person name headings
viaf.searchPersonalNames

//Search source record
viaf.searchSourceRecord

//Search titles
viaf.searchTitle

//Search uniform titles (Expressions)
viaf.searchExpression

//Search uniform titles (Works)
viaf.searchWorks

The following options are supported by passing a object with the request

Operators:

//One or more terms
viaf.ONE_OR_MORE

//Exact term
viaf.EXACT

//Any term
viaf.ANY

//All terms listed
viaf.ALL

//Self explanatory
viaf.LESS
viaf.LESS_EQUAL
viaf.GRATER
viaf.GRATER_EQUAL
viaf.NOT

viaf.ALL is default operator

For example to search for this exact name heading:

var viaf = require('viaf-wrapper')

viaf.searchNames("Kerouac, Jack, 1922-1969.",{operator:viaf.EXACT})
.then(function(records){
	console.log(records.length)
})

> 1

You can also limit by original source of the authority records:

viaf.VIAF
viaf.AUSTRALIA
viaf.BELGIUM
viaf.CANADA
viaf.CZECH
viaf.EGYPT
viaf.FRANCE_BNF
viaf.FRANCE_SUDOC
viaf.GERMANY
viaf.GETTY
viaf.HUNGARY
viaf.ISRAEL
viaf.ITALY
viaf.LOC
viaf.NORWAY
viaf.POLAND
viaf.PORTUGAL
viaf.SPAIN
viaf.SWEDEN
viaf.SWISS_NL
viaf.SWISS_RERO
viaf.RUSSIA
viaf.VATICAN
viaf.XA

To only search the French authoirty records:

viaf.searchNames("Kerouac, Jack, 1922-1969.",{operator: viaf.EXACT, limit: viaf.FRANCE_BNF})
.then(function(records){
	console.log(records.length)
})

You can also specify what record to start on:

{operator: viaf.EXACT, limit: viaf.FRANCE_BNF, start: 11}

This is important as VIAF will only return 10 full records at a time. Normally the website interface returns "BriefVIAF" data layout which does not have the full record. To get more than 10 records you will need to fire another request.

You can also get a record if you know the VIAF id or LCCN with the .getViaf and .getLccn methods:

viaf.getViaf('27066713')
.then(function(record){
	console.log(record)
})

viaf.getLccn('n80036674')
.then(function(record){
	console.log(record)
})

Data

Here is the full layout of the records type. Search returns an array of these, get returns a single. The property names follow the XML namespace.

https://gist.github.com/thisismattmiller/becffc95f9765e72fd94

Take a look at the data represented here which is all available in the wrapper: http://viaf.org/viaf/27066713/

These are the highest level values returned:

viafID
primaryTopic
nameType
length
birthDate
deathDate
dateType
sources
mainHeadings
gender
x400s
x500s
coauthors
publishers
dates (dates of publication by decade)
RecFormats
RelatorCodes
ISBNs
covers
countries
languageOfEntity
nationalityOfEntity
xLinks
titles
history (of the viaf cluster)

//the wrapper provides these
titlesTop      (the title with the most authorities reporting it)
nationalityOfEntityTop  (the country that had the highest nationalityOfEntity entries)
languageOfEntityTop    (the language that had the highest languageOfEntity entries)