Documentation
¶
Overview ¶
Package openalex is a thin HTTP client for api.openalex.org that resolves DOIs and runs cross-field search, mapping the returned Work records into coldp.Reference values.
LIFT-TO-SFLIB CANDIDATE. Every SFBorg tool that touches references wants this. Kept self-contained (no reach into hive-internal state, no singleton) so migration to sflib is a clean copy.
Polite pool etiquette: OpenAlex asks clients to identify themselves via User-Agent or a mailto=<email> query param. Identified requests land in a higher-priority pool. Callers thread the curator email through New(email); empty is legal (anonymous pool, slower).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("openalex: work not found")
ErrNotFound is returned when OpenAlex has no work for the given DOI. Distinct from network failures so calling code can tell "DOI is bad" from "OpenAlex is down."
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is concurrent-safe (net/http.Client is). One instance per process is plenty.
func (*Client) ResolveDOI ¶
ResolveDOI fetches the OpenAlex Work record for a DOI and maps it to a coldp.Reference. The DOI may be a bare identifier ("10.1234/abcd") or a full URL ("https://doi.org/10.1234/abcd"). Returns ErrNotFound on 404.
The returned Reference carries no ID; the caller assigns one before persisting. OpenAlex's own W-IDs aren't preserved into sfga; a curator wanting that linkage can add it to col__alternative_id.
func (*Client) Search ¶
Search runs OpenAlex's cross-field search (title / abstract / author) and returns up to `limit` results mapped to coldp.Reference. Search is fuzzy — OpenAlex handles typos and word ordering itself.
Empty query returns nil rather than "everything"; callers filtering by name+year should compose a query string themselves.