Documentation
¶
Overview ¶
Package openalex is the library behind the openalex command line: the HTTP client, request shaping, and the typed data models for openalex.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.
Index ¶
- Constants
- type Author
- type Client
- func (c *Client) GetPage(ctx context.Context, p string) (*Page, error)
- func (c *Client) GetWork(ctx context.Context, id string) (*Work, error)
- func (c *Client) PageLinks(ctx context.Context, p string, limit int) ([]*Page, error)
- func (c *Client) SearchAuthors(ctx context.Context, query string, limit int) ([]Author, error)
- func (c *Client) SearchInstitutions(ctx context.Context, query string, limit int) ([]Institution, error)
- func (c *Client) SearchTopics(ctx context.Context, query string, limit int) ([]Topic, error)
- func (c *Client) SearchWorks(ctx context.Context, query string, limit int) ([]Work, error)
- type Config
- type Domain
- type Institution
- type Page
- type Topic
- type Work
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "openalex-cli/dev (https://github.com/tamnd/openalex-cli; mailto:bot@example.com)"
DefaultUserAgent identifies the client to OpenAlex. The mailto: hint opts into the polite pool for higher rate limits.
const Host = "api.openalex.org"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Author ¶
type Author struct {
Rank int `json:"rank"`
ID string `json:"id"` // OpenAlex ID e.g. A27320202
Name string `json:"name"`
WorksCount int `json:"works_count"`
CitedByCount int `json:"cited_by_count"`
HIndex int `json:"h_index"` // from summary_stats.h_index
Affiliation string `json:"affiliation"` // last institution name
}
Author is an individual researcher with career statistics.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to OpenAlex over HTTP.
func (*Client) SearchAuthors ¶
SearchAuthors queries the OpenAlex /authors endpoint and returns up to limit results.
func (*Client) SearchInstitutions ¶ added in v0.1.1
func (c *Client) SearchInstitutions(ctx context.Context, query string, limit int) ([]Institution, error)
SearchInstitutions queries the OpenAlex /institutions endpoint.
func (*Client) SearchTopics ¶ added in v0.1.1
SearchTopics queries the OpenAlex /topics endpoint.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunables for the client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults for the OpenAlex API.
type Domain ¶
type Domain struct{}
Domain is the openalex 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.
type Institution ¶ added in v0.1.1
type Institution struct {
Rank int `json:"rank"`
ID string `json:"id"` // OpenAlex ID e.g. I63966007
Name string `json:"name"`
CountryCode string `json:"country_code,omitempty"`
Type string `json:"type,omitempty"`
WorksCount int `json:"works_count"`
CitedByCount int `json:"cited_by_count"`
URL string `json:"url,omitempty"` // homepage_url
}
Institution is a research institution (university, lab, etc.).
type Page ¶
type Page struct {
ID string `json:"id" kit:"id"`
URL string `json:"url"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty" kit:"body"`
}
Page is used by the kit domain driver as the URI-addressable resource.
type Topic ¶ added in v0.1.1
type Topic struct {
Rank int `json:"rank"`
ID string `json:"id"` // OpenAlex ID e.g. T12345
Name string `json:"name"`
WorksCount int `json:"works_count"`
Description string `json:"description,omitempty"`
Field string `json:"field,omitempty"` // subfield display name
}
Topic is a research topic cluster.
type Work ¶
type Work struct {
Rank int `json:"rank"`
ID string `json:"id"` // OpenAlex ID e.g. W2741809807
DOI string `json:"doi"`
Title string `json:"title"`
Year int `json:"year"`
Type string `json:"type"` // article, preprint, book, etc.
OpenAccess bool `json:"open_access"`
CitedByCount int `json:"cited_by_count"`
Authors []string `json:"authors"` // first 3 author display names
PrimaryVenue string `json:"primary_venue"` // journal or source name
URL string `json:"url"` // doi URL or landing page
}
Work is a single scholarly work (paper, preprint, book, dataset, etc.).