datacite

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package datacite is the library behind the datacite command line: the HTTP client, request shaping, and the typed data models for the DataCite DOI Registry API at api.datacite.org.

The DataCite REST API is open for public read-only data: no API key, no auth required. This package wraps the API with a rate-limited client that the kit operations consume.

Index

Constants

View Source
const DefaultUserAgent = "datacite-cli/0.1 (tamnd87@gmail.com)"

DefaultUserAgent identifies the client to DataCite honestly.

View Source
const Host = "datacite.org"

Host is the human-facing DataCite site.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a rate-limited HTTP client for the DataCite API.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) GetDOI

func (c *Client) GetDOI(ctx context.Context, id string) (*DOI, error)

GetDOI fetches a single DOI record by its identifier (e.g. "10.1234/example").

func (*Client) ListFunders

func (c *Client) ListFunders(ctx context.Context, page, size int) ([]Funder, error)

ListFunders fetches a page of DataCite funders.

func (*Client) ListMembers

func (c *Client) ListMembers(ctx context.Context, page, size int) ([]Member, error)

ListMembers fetches a page of DataCite members.

func (*Client) SearchDOIs

func (c *Client) SearchDOIs(ctx context.Context, query string, page, size int) ([]DOI, int, error)

SearchDOIs searches the DataCite DOI registry. Returns matching DOIs, the total count, and any error.

type Config

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

Config holds constructor parameters for Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults for api.datacite.org.

type DOI

type DOI struct {
	DOI         string `json:"doi" kit:"id"`
	Title       string `json:"title"`
	Creators    string `json:"creators"`
	Year        string `json:"year"`
	Publisher   string `json:"publisher"`
	Type        string `json:"type"`
	Description string `json:"description"`
	URL         string `json:"url"`
}

DOI is a single DataCite DOI record.

type Domain

type Domain struct{}

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

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into the canonical (uriType, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme and the identity the single-site binary inherits.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the canonical URL for a (uriType, id).

func (Domain) Register

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

Register installs the client factory and every operation onto app.

type Funder

type Funder struct {
	ID      string `json:"id" kit:"id"`
	Name    string `json:"name"`
	Region  string `json:"region"`
	Country string `json:"country"`
}

Funder is a single DataCite funder record.

type Member

type Member struct {
	ID         string `json:"id" kit:"id"`
	Name       string `json:"name"`
	Region     string `json:"region"`
	Country    string `json:"country"`
	MemberType string `json:"member_type"`
}

Member is a single DataCite member record.

Jump to

Keyboard shortcuts

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