dataciteapi

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: BSD-3-Clause Imports: 14 Imported by: 3

README

dataciteapi

This is a go package for working with the DataCite API. It is inspired by work my colleague Tom Morrel has done in Python. This package is meant to follow the guidelines for interacting with the public API at api.datacite.org. It also follows the same form as the golang CrossRef API developed previously at Caltech Library.

Go package example

    appName := path.Base(os.Args[0])
    client, err := dataciteapi.NewDataCiteClient(appName, "jane.doe@library.example.edu")
    if err != nil {
        // handle error...
    }
    works, err := client.Works("10.1037/0003-066x.59.1.29")
   
    if err != nil {
        // handle error...
    }
    // continue processing your "works" result...

Command line example

    dataciteapi -mailto="jane.doe@library.example.edu" works "10.1037/0003-066x.59.1.29"

Reference

Documentation

Index

Constants

View Source
const (
	// Version number of release
	Version = "1.1.0"

	// ReleaseDate, the date version.go was generated
	ReleaseDate = "2024-04-11"

	// ReleaseHash, the Git hash when version.go was generated
	ReleaseHash = "48fc786"

	LicenseText = `` /* 1524-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func ArXivToDOI added in v1.0.3

func ArXivToDOI(s string) string

ArXivToDOI converts an arXiv id to a DOI (without the "https://doi.org/" prefix) formatted id per Instructions in the announcement that all arXiv gets DOI at https://blog.arxiv.org/2022/02/17/new-arxiv-articles-are-now-automatically-assigned-dois/

func ArXivURLtoArXiv added in v1.0.3

func ArXivURLtoArXiv(s string) string

ArXivURLtoArXiv will convert an absolute arxiv.org URL to an arXiv id format.

func DisplayLicense added in v1.0.2

func DisplayLicense(out io.Writer, appName string, license string)

func DisplayUsage added in v1.0.2

func DisplayUsage(out io.Writer, appName string, flagSet *flag.FlagSet, description string, examples string, license string)

func DisplayVersion added in v1.0.2

func DisplayVersion(out io.Writer, appName string)

func FmtHelp added in v1.0.2

func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string

FmtHelp lets you process a text block with simple curly brace markup.

func IsArXiv added in v1.0.3

func IsArXiv(s string) bool

Checks if a string is an ArXiv id.

Types

type DataCiteClient

type DataCiteClient struct {
	AppName           string
	MailTo            string `json:"mailto"`
	API               string `json:"api"`
	RateLimitLimit    int    `json:"limit"`
	RateLimitInterval int    `json:"interval"`
	Status            string
	StatusCode        int
	LastRequest       time.Time `json:"last_request"`
}

func NewDataCiteClient

func NewDataCiteClient(appName string, mailTo string) (*DataCiteClient, error)

NewDataCiteClient creates a client and makes a request and returns the JSON source as a []byte or error if their is a problem.

func (*DataCiteClient) Dois added in v1.1.0

func (c *DataCiteClient) Dois(doi string) (Object, error)

Dois returns the "dois" object from `https://api.datacite.org/dois/` path

func (*DataCiteClient) DoisJSON added in v1.1.0

func (c *DataCiteClient) DoisJSON(doi string) ([]byte, error)

DoisJSON return the "dois" JSON source from `https://api.datacite.org/dois/` path

func (*DataCiteClient) Works

func (c *DataCiteClient) Works(doi string) (Object, error)

Works return the Work unmarshaled into a Object (i.e. map[string]interface{})

func (*DataCiteClient) WorksJSON

func (c *DataCiteClient) WorksJSON(doi string) ([]byte, error)

WorksJSON return the work JSON source or error for a client and DOI

type Object

type Object = map[string]interface{}

Object is the general holder of what get back after unmarshaling json

Directories

Path Synopsis
cmd
dataciteapi
dataciteapi.go is a command line tool for access the DataCite API given a specific DOI.
dataciteapi.go is a command line tool for access the DataCite API given a specific DOI.

Jump to

Keyboard shortcuts

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