dataciteapi

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 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.0.2"

	// ReleaseDate, the date version.go was generated
	ReleaseDate = "2024-02-26"

	// ReleaseHash, the Git hash when version.go was generated
	ReleaseHash = "9c33303"

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

)

Variables

This section is empty.

Functions

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.

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) 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 command
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