Help us shape the future of Go! Take the 2026 Go Developer Survey

oclcapis

package module
v0.0.0-...-ad62c4e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 7 Imported by: 1

README

Package oclcapis

A Go client for some of the free, public Web Services available from OCLC.

See the documentation for this package at https://godoc.org/github.com/nicomo/oclcapis

OCLC offers many web services not implemented here, some only accessible to member libraries. The web services are documented at https://platform.worldcat.org/api-explorer/apis

Status

This project is experimental/personal, use at your own risk.

Covered

  • VIAF : get other IDs e.g. LC, DNB, WKP, etc. from a Viaf ID or a bunch of Viaf IDs. You can ask for all the known IDs, just a LC number or just a Wikidata ID.
  • ViafTranslateSourceID: Translate a SourceID (identifier for an original source record at a specific institution) to a VIAF URI. For instance /viaf/sourceID/DNB%7c1034425390 Works with a single source ID or a bunch of them at once.
  • WCIRead uses the WorldCatIdentitiesRead web service: Read a single identity record in WorldCat Identities, for example http://www.worldcat.org/identities/lccn-n79032879/. You can send a bunch of LC numbers at it. Partial: does not return citations.

Not covered

Everything else, which is a lot.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ViafGetIDs

func ViafGetIDs(input string) (map[string]string, error)

ViafGetIDs finds all source IDs, e.g. LC, DNB, WKP, etc. from a VIAF ID

func ViafGetLCN

func ViafGetLCN(input string) (string, error)

ViafGetLCN finds a Library of Congress ID from a VIAF ID

func ViafGetLCNs

func ViafGetLCNs(input []string) (map[string]string, error)

ViafGetLCNs finds Library of Congress IDs from a slice of VIAF IDs in batches

func ViafGetWKP

func ViafGetWKP(input string) (string, error)

ViafGetWKP finds a Wikipedia ID from a VIAF ID

func ViafGetWKPs

func ViafGetWKPs(input []string) (map[string]string, error)

ViafGetWKPs finds Wikidata IDs from a slice of VIAF IDs in batches

func ViafTranslate

func ViafTranslate(input string) (string, error)

ViafTranslate takes an ID from an external source e.g. DNB, Sudoc, etc and retrieves the corresponding VIAF ID the input should be an url encoded string, e.g. SUDOC%7c033522448

func ViafTranslateBatch

func ViafTranslateBatch(input []string) (map[string]string, error)

ViafTranslateBatch takes a string of IDs from external sources e.g. DNB, Sudoc, etc and retrieves the corresponding VIAF IDs the input should be an url encoded string, e.g. SUDOC%7c033522448

Types

type AllIDsResult

type AllIDsResult struct {
	// contains filtered or unexported fields
}

AllIDsResult returns the input of a request to ViafGetAllIDs (e.g. 123456) and the result in the form map[DNB]{"TYU6756"}, with the error if any

func ViafGetAllIDs

func ViafGetAllIDs(input []string) ([]AllIDsResult, error)

ViafGetAllIDs finds all source IDs, e.g. LC, DNB, WKP, etc. from a bucn of VIAF ID

type AudLevel

type AudLevel struct {
	Avg Avg `xml:"avg"`
}

AudLevel is embedded in WCIdentity represents the "audience level" of the author's works

type Avg

type Avg struct {
	Text  string `xml:",chardata"`
	Level string `xml:"level"`
}

Avg is embedded in AudLevel

type Date

type Date struct {
	Text  string `xml:",chardata"`
	Count string `xml:"count,attr"`
}

Date is embedded in Dates

type Dates

type Dates struct {
	Date []Date `xml:"date"`
}

Dates is embedded in NameInfo

type Lang

type Lang struct {
	Code  string `xml:"code,attr"`
	Count string `xml:"count,attr"`
}

Lang is embedded in Languages

type Languages

type Languages struct {
	Count string `xml:"count,attr"`
	Lang  []Lang `xml:"lang"`
}

Languages is embedded in NameInfo

type NameInfo

type NameInfo struct {
	Type          string    `xml:"type,attr"`
	RawName       RawName   `xml:"rawName"`
	Languages     Languages `xml:"languages"`
	BirthDate     string    `xml:"birthDate"`
	Dates         Dates     `xml:"dates"`
	TotalHoldings string    `xml:"totalHoldings"`
	WorkCount     string    `xml:"workCount"`
	RecordCount   string    `xml:"recordCount"`
}

NameInfo is embedded in WCIdentity

type RawName

type RawName struct {
	Suba string `xml:"suba"`
}

RawName is embedded in NameInfo

type SourceID

type SourceID struct {
	Src   string `json:"src"`
	SrcID string `json:"src_id"`
}

SourceID store a single source ID, e.g. SUDOC / 1234567

type SourceIDs

type SourceIDs []SourceID

SourceIDs stores multiple IDs

type Sources

type Sources struct {
	Source interface{} `json:"source"`
}

Sources is used to unmarshal data about other sources ID into an interface (JSON structure subject to change on the OCLC end)

type ViafData

type ViafData struct {
	ViafID          string    `json:"viafID"`
	NameType        string    `json:"nameType"`
	Sources         Sources   `json:"sources"`
	SourceIDs       SourceIDs // SourceIDs is the value extracted from Sources above
	XLinks          XLinks    `json:"xLinks"`
	WCIdentitiesURL string    // WCIdentitiesURL is the value extracted from XLinks above
}

ViafData is used to unmarshal the response coming from the VIAF GetDataInFormat web service

type WCIReadResult

type WCIReadResult struct {
	Input       string
	Output      WCIdentity
	ErrorString string
}

WCIReadResult returns the input of a request to WCIBatchRead and the result in the form WCIdentity, with the error if any

func WCIBatchRead

func WCIBatchRead(input []string) ([]WCIReadResult, error)

WCIBatchRead manages concurrent calls to WCIRead

type WCIdentity

type WCIdentity struct {
	Pnkey    string   `xml:"pnkey"`
	AudLevel AudLevel `xml:"audLevel"`
	NameInfo NameInfo `xml:"nameInfo"`
}

WCIdentity stores the unmarshalled result from the WorldCat Identities web service

func WCIRead

func WCIRead(input string) (WCIdentity, error)

WCIRead calls the WorldCat Identities web service for a given LC number (i.e. authority number)

type XLinks struct {
	XLink interface{} `json:"xLink"`
}

XLinks is embedded in ViafData the shape of the returned JSON changes according to the content :-( we have to unmarshal to an empty interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL