unpaywall

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

Package unpaywall is the library behind the unpaywall command line: the HTTP client, request shaping, and the typed data models for the Unpaywall public open-access API (api.unpaywall.org/v2).

The API requires no registration — pass your email as the identifying key. It is polite to pace requests to at most one per second.

Index

Constants

View Source
const BaseURL = "https://api.unpaywall.org/v2"

BaseURL is the v2 API root every request is built from.

View Source
const Host = "api.unpaywall.org"

Host is the API hostname.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the Unpaywall API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) LookupDOI

func (c *Client) LookupDOI(ctx context.Context, doi string) (*Paper, error)

LookupDOI fetches the open access status for a paper by its DOI. A 404 from the API is returned as errs.NotFound.

type Config

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

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible, polite defaults.

type Domain

type Domain struct{}

Domain is the unpaywall driver.

func (Domain) Classify

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

Classify turns an input into the canonical (type, id). A string starting with "10." is treated as a DOI; everything else is a query.

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

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

Locate returns the live https URL for a (type, id).

func (Domain) Register

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

Register installs the client factory and every operation onto app.

type Paper

type Paper struct {
	DOI        string `json:"doi" kit:"id"`
	Title      string `json:"title"`
	Journal    string `json:"journal"`
	Published  string `json:"published"`
	Year       int    `json:"year"`
	IsOA       bool   `json:"is_oa"`
	OAStatus   string `json:"oa_status"`
	BestURL    string `json:"best_url"`
	BestPDFURL string `json:"best_pdf_url"`
	HostType   string `json:"host_type"`
	License    string `json:"license"`
}

Paper is the canonical output record for a DOI lookup.

Jump to

Keyboard shortcuts

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