crossref

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2025 National Technology and Engineering Solutions of Sandia SPDX-License-Identifier: BSD-3-Clause

Copyright 2025 National Technology and Engineering Solutions of Sandia SPDX-License-Identifier: BSD-3-Clause

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.6.0

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

Client is a rate-limited client for the Crossref API. A Client is safe for concurrent use and should be shared by all work in one process.

func NewClient added in v0.6.0

func NewClient(options ...Option) *Client

NewClient returns a Crossref client limited to one request start every 334ms and at most three concurrent upstream requests.

func (*Client) Do added in v0.6.0

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do performs a rate-limited HTTP request.

func (*Client) QueryBibliographic added in v0.6.0

func (c *Client) QueryBibliographic(ctx context.Context, reference string, rows int) (*CrossrefResponse, error)

QueryBibliographic queries Crossref for reference matching.

type CrossrefResponse

type CrossrefResponse struct {
	Status  string `json:"status"`
	Message struct {
		Items        []CrossrefWork `json:"items"`
		TotalResults int            `json:"total-results"`
	} `json:"message"`
}

type CrossrefWork

type CrossrefWork struct {
	DOI    string   `json:"DOI"`
	Title  []string `json:"title"`
	Score  float64  `json:"score"`
	Author []struct {
		Given  string `json:"given"`
		Family string `json:"family"`
	} `json:"author"`
	Published struct {
		DateParts [][]int `json:"date-parts"`
	} `json:"published-print"`
	ContainerTitle []string `json:"container-title"`
}

CrossrefWork represents a work item from the Crossref API.

func (*CrossrefWork) ToString

func (w *CrossrefWork) ToString() string

type Option added in v0.6.0

type Option func(*Client)

Option configures a Client.

func WithDelayCallback added in v0.6.0

func WithDelayCallback(callback func(time.Duration)) Option

WithDelayCallback registers a callback for requests delayed by rate limiting.

func WithHTTPClient added in v0.6.0

func WithHTTPClient(client *http.Client) Option

WithHTTPClient replaces the HTTP client used for upstream requests.

type ReferenceMatchResult

type ReferenceMatchResult struct {
	BestMatch    *CrossrefWork
	SecondMatch  *CrossrefWork
	IsConclusive bool
	Error        error
}

Jump to

Keyboard shortcuts

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