orcidtools

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2018 License: BSD-3-Clause Imports: 7 Imported by: 1

README

orcidtools

Orcid Tools

A command line tool called orcid, a set of Bash scripts and Go template for working with the Public ORCID API.

Configuration

The orcid tool and Bash scripts share a common configuration. These are set via environment variables. The following are supported, the first three required.

  • ORCID_API_URL
  • ORCID_CLIENT_ID
  • ORCID_CLIENT_SECRET
  • ORCID_ACCESS_TOKEN (known on successful login to the API)

If you want to use the API URL https://pub.orcid.org then you'll need to register an application to generate your client id and secret. This is free for most uses, if you follow the instructions

If you want to experiment with the orcid public api to test code (e.g. say test this package) you can use the Sandbox API which is full of fake data. ORCID has provided an example client id and secret described in their documentation along with the sandbox API URL of https://pub.sandbox.orcid.org.

The bash scripts provided in the repository rely on a few environment variables. You can define those variables in a Bash script, sourcing that script will then expose those variables in your current Bash session.

Below is an example of setup script that would be sourced to access the sandbox

    #!/bin/bash
    export ORCID_API_URL="https://pub.sandbox.orcid.org"
    export ORCID_CLIENT_ID="APP-01XX65MXBF79VJGF"
    export ORCID_CLIENT_SECRET="3a87028d-c84c-4d5f-8ad5-38a93181c9e1""

the ORCID tool

The command line tool works simularly to the bash scripts. You source a configuration then run the tool. Unlike the shell scripts login is automatic so you can focus on the command you need. The command line tool expacts an ORCID id as a command line parameter so it can get back a specific record.

    . etc/sandbox.sh
    orcid -works 0000-0003-0900-6903

Would list the works for the ORCID id of "0000-0003-0900-6903". The resulting document would be in JSON form.

Taking things a step further you can generate a BibTeX from the works in your ORCID using the orcid tool and mkpage tool together with the templates included in this repository.

    . etc/sandbox.sh
    orcid -works-detailed 0000-0003-0900-6903 > 0000-0003-0900-6903-works.json
    mkpage "data=0000-0003-0900-6903-works.json" templates/works-detailed-to-bibtex.tmpl > 0000-0003-0900-6903.bib

We also include a simple example of tranferring an ORCID profile to a test file. This works on a record that has standard metadata present.

. etc/sandbox.sh
orcid -works-detailed 0000-0003-4476-2464 > 0000-0003-4476-2464-works.json
mkpage "data=0000-0003-4476-2464-works.json" templates/orcid2txt.tmpl > 0000-0003-0900-6903.txt

Working with the scripts

Assuming you saved this script as "etc/sandbox.sh" you would source it with the command

    . etc/sandbox.sh

You could then login to the API with

    ./scripts/api-login.sh

This will provide you with an Access token (you would cut and paste from the console to set that into the environment). Once ORCID_ACCESS_TOKEN is defined in your environment you then can use the other scripts to query the ORCID API for profile, bio and works data.

Putting it together

    . etc/sandbox.sh
    ./scripts/api-login.sh
    # Cut and past the 'export ORCID_ACCESS_TOKEN' line into the console
    # Then you can get the "works" for 0000-0003-0900-6903 with
    ./scripts/api-get-works.sh 0000-0003-0900-6903

Reference

Documentation

Overview

Package orcidtools is a library for working with the ORCID API

@author R. S. Doiel, <rsdoiel@caltech.edu>

Copyright (c) 2018, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of ot nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

View Source
const (
	// Version of ot package
	Version = `v0.0.6`

	// License string suitable to populate via cli
	LicenseText = `` /* 1519-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {

	// Timeout is the client time out period, default is 10 seconds
	Timeout time.Duration
	// contains filtered or unexported fields
}

func New

func New(apiURL, clientID, clientSecret string) (*API, error)

func (*API) Request

func (api *API) Request(method, docPath string, payload map[string]string) ([]byte, error)

Request contacts the ORCID API and returns the full read response body, and error

Directories

Path Synopsis
cmd
orcid command
*
*

Jump to

Keyboard shortcuts

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