arxiv

package
v0.1.1 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: 12 Imported by: 0

Documentation

Overview

Package arxiv is the library behind the arxiv command: the HTTP client, request shaping, and the typed data models for the arXiv Open Access API.

The API endpoint is https://export.arxiv.org/api/query. It returns Atom XML and requires no key. The arXiv ToS recommends no more than 3 requests per second; the default rate is 400 ms between calls.

Index

Constants

View Source
const DefaultUserAgent = "arxiv/dev (+https://github.com/tamnd/arxiv-cli)"

DefaultUserAgent identifies the client to arXiv.

View Source
const Host = "arxiv.org"

Host is the arXiv site this client represents.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when the API returns an empty entry list for a given id.

Functions

func ParsePaperID

func ParsePaperID(s string) (string, error)

ParsePaperID extracts a bare arXiv id (e.g. "1706.03762") from:

The version suffix is always stripped. Returns an error if s does not look like any recognized arXiv id form.

Types

type Category

type Category struct {
	Code        string `json:"code"`
	Description string `json:"description"`
}

Category is the static record used by the categories command.

type Client

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

Client talks to the arXiv Open Access API.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client with the given config.

func (*Client) Paper

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

Paper fetches the single paper with the given id (version suffix stripped). Returns ErrNotFound if the id produces an empty result.

func (*Client) Search

func (c *Client) Search(ctx context.Context, opts SearchOptions) ([]Paper, error)

Search returns up to opts.Limit papers matching the query.

func (*Client) SearchByAuthor

func (c *Client) SearchByAuthor(ctx context.Context, name string, n int) ([]Paper, error)

SearchByAuthor returns up to n papers authored by name, sorted newest first.

type Config

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

Config holds constructor parameters.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

type Domain added in v0.1.1

type Domain struct{}

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

func (Domain) Info added in v0.1.1

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) Register added in v0.1.1

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

Register installs the client factory and every operation onto app.

type Paper

type Paper struct {
	ID        string   `json:"id"        kit:"id" table:"id"`
	Title     string   `json:"title"              table:"title"`
	Authors   []string `json:"authors"            table:"authors"`
	Category  string   `json:"category"           table:"category"`
	Published string   `json:"published"          table:"date"`
	Updated   string   `json:"updated"            table:"-"`
	Summary   string   `json:"summary"            table:"-"`
	URL       string   `json:"url"                table:"abs,url"`
	PDF       string   `json:"pdf"                table:"pdf,url"`
}

Paper is the canonical record emitted for every search, paper, and author result. JSON keys are stable.

type SearchOptions

type SearchOptions struct {
	Query    string // free-text query
	Category string // "" = no category filter
	Sort     string // "relevance" | "date" | "updated"
	Limit    int
}

SearchOptions controls a Search call.

Jump to

Keyboard shortcuts

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