orcid

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

domain.go exposes orcid as a kit Domain: a driver that a multi-domain host (ant) enables with a single blank import,

import _ "github.com/tamnd/orcid-cli/orcid"

exactly as a database/sql program enables a driver with `import _ "github.com/lib/pq"`. The init below registers it; the host then dereferences orcid:// URIs by routing to the operations Register installs. The same Domain also builds the standalone orcid binary (see cli.NewApp), so the binary and a host share one source of truth.

Package orcid is the library behind the orcid command line: the HTTP client, request shaping, and typed data models for the ORCID public registry (pub.orcid.org).

The ORCID public API is free and requires no API key. All requests must include Accept: application/json to receive JSON responses. The Client paces requests, retries transient failures (429 and 5xx) with exponential backoff, and decodes the deeply nested ORCID JSON into clean typed structs.

Three operations are provided: person profile (Person), list of works (Works), and researcher search (Search).

Index

Constants

View Source
const BaseURL = "https://pub.orcid.org/v3.0"

BaseURL is the API base path including the API version.

View Source
const Host = "pub.orcid.org"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to pub.orcid.org over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Person

func (c *Client) Person(ctx context.Context, orcidID string) (*Person, error)

Person fetches the researcher profile for the given ORCID identifier. The orcidID must be in the format 0000-0002-1825-0097.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, limit int) ([]SearchResult, error)

Search searches ORCID researchers by keyword query. It returns up to limit results.

func (*Client) Works

func (c *Client) Works(ctx context.Context, orcidID string, limit int) ([]Work, error)

Works fetches the list of works for the given ORCID identifier. It returns up to limit works; pass 0 for all.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds tunable knobs for the HTTP client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults for production use.

type Domain

type Domain struct{}

Domain is the orcid driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Person

type Person struct {
	ORCID      string      `json:"orcid"`
	GivenName  string      `json:"given_name"`
	FamilyName string      `json:"family_name"`
	Bio        string      `json:"bio,omitempty"`
	Keywords   []string    `json:"keywords,omitempty"`
	URLs       []PersonURL `json:"urls,omitempty"`
}

Person holds the profile data for one ORCID researcher.

type PersonURL

type PersonURL struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

PersonURL is a researcher-provided URL.

type SearchResult

type SearchResult struct {
	ORCID      string `json:"orcid"`
	GivenName  string `json:"given_name,omitempty"`
	FamilyName string `json:"family_name,omitempty"`
}

SearchResult is one entry returned by the search endpoint.

type Work

type Work struct {
	PutCode int64  `json:"put_code"`
	Title   string `json:"title"`
	Type    string `json:"type,omitempty"`
	Year    int    `json:"year,omitempty"`
	Journal string `json:"journal,omitempty"`
	DOI     string `json:"doi,omitempty"`
	URL     string `json:"url,omitempty"`
}

Work holds one publication entry from an ORCID profile.

Jump to

Keyboard shortcuts

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