hal

package
v0.1.0 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: 10 Imported by: 0

Documentation

Overview

Package hal is the library behind the hal command line: the HTTP client, request shaping, and the typed data models for archives-ouvertes.fr (HAL Open Archive).

The Client sets a real User-Agent, paces requests, and retries transient failures (429 and 5xx). Build endpoint calls and JSON decoding on top of it.

Index

Constants

View Source
const Host = "api.archives-ouvertes.fr"

Host is the API host for HAL open archive.

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 HAL API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client built from cfg.

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context, halID string) (*Document, error)

GetDocument fetches a single document by HAL ID (e.g., "hal-04987097").

func (*Client) Recent

func (c *Client) Recent(ctx context.Context, limit int) ([]*Document, error)

Recent returns the most recently modified documents.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, limit, start int) ([]*Document, int, error)

Search performs a full-text search. Returns documents, total count, and any error.

func (*Client) SearchByDomain

func (c *Client) SearchByDomain(ctx context.Context, domain string, limit, start int) ([]*Document, int, error)

SearchByDomain searches publications within a specific domain (e.g., "math", "cs", "physics").

type Config

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

Config holds all tuneable Client parameters.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults: 300 ms pacing, 3 retries, 30 s timeout.

type Document

type Document struct {
	ID       string   `json:"id"                kit:"id"`
	Title    string   `json:"title"`
	Authors  []string `json:"authors,omitempty"`
	Year     int      `json:"year,omitempty"`
	DocType  string   `json:"doc_type,omitempty"`
	Domain   string   `json:"domain,omitempty"`
	Language string   `json:"language,omitempty"`
	URI      string   `json:"uri,omitempty"`
	Abstract string   `json:"abstract,omitempty"`
}

Document is a single HAL publication record.

type Domain

type Domain struct{}

Domain is the HAL Open Archive kit driver.

func (Domain) Classify

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

Classify turns any accepted input into (type, id). Any non-empty string is treated as a document ID.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, hostnames, and identity for the hal binary.

func (Domain) Locate

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

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

func (Domain) Register

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

Register installs the client factory and all commands onto app.

Jump to

Keyboard shortcuts

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