Skip to content

HAL API reference

Generated from the source with mkdocstrings. Every name below is importable from bibliofabric.hal; nested value models stay importable from bibliofabric.hal.models.

Client

bibliofabric.hal.HalClient

Client for the HAL search and referential API.

The API needs no credentials. The client sends Accept: application/json on every request and wt=json on every route.

documents: DocumentsResource cached property

The /search/ document index.

structures: StructuresResource cached property

The /ref/structure research structures.

journals: JournalsResource cached property

The /ref/journal journals.

authors: AuthorsResource cached property

The /ref/author author references.

domains: DomainsResource cached property

The /ref/domain HAL domains.

instances: InstancesResource cached property

The /ref/instance portal instances.

anr_projects: ProjectsResource cached property

The /ref/anrproject ANR funding projects.

european_projects: ProjectsResource cached property

The /ref/europeanproject European funding projects.

metadata: MetadatasResource cached property

The /ref/metadatalist metadata value tables.

document_types: DocumentTypesResource cached property

The /ref/doctype document type table.

in_portal(code: str) -> DocumentsResource

Return the document index of one portal instance.

The code is lowercase (tel, hal); the case after /search/ decides between portal and collection upstream.

in_collection(code: str) -> DocumentsResource

Return the document index of one collection.

The code is uppercase (FRANCE-GRILLES); the case after /search/ decides between portal and collection upstream.

Settings

bibliofabric.hal.HalSettings

HAL-specific client settings.

Inherits timeout, max_retries, max_retry_wait, max_requests_per_second, max_concurrency, user_agent and mailto from :class:bibliofabric.config.BaseApiSettings and sets HAL defaults (3 req/s, concurrency 2). The API needs no credentials.

Resources

bibliofabric.hal.DocumentsResource

Client for the /search/ document index.

search, iterate, collect, first, and count come from the framework; iterate walks the result set with Solr cursorMark tokens and sorts on docid asc unless the caller sorts otherwise. batch_get ORs ids into one docid/halId_s/doiId_s query; pass field= with a model attribute name (docid, hal_id, or doi).

get(id: str | int, *, select: Sequence[str] | None = None, params: Mapping[str, Any] | None = None) -> HalDocument async

Fetch one document by docid, HAL identifier, DOI, or record URL.

A HAL identifier without a version suffix matches the newest record of that identifier; 404-less upstream answers with zero results raise :class:NotFoundError.

exists(id: str | int) -> bool async

Return True when a document matches the id.

by_doi(doi: str, *, select: Sequence[str] | None = None, params: Mapping[str, Any] | None = None) -> list[HalDocument] async

Return the documents that carry doi (records can share a DOI).

bibliofabric.hal.StructuresResource

Client for /ref/structure, the research structures.

bibliofabric.hal.JournalsResource

Client for /ref/journal, the journals.

bibliofabric.hal.AuthorsResource

Client for /ref/author, the author references.

A docid has the <form>-<person> form, for example 164005-0.

bibliofabric.hal.DomainsResource

Client for /ref/domain, the HAL domains.

bibliofabric.hal.InstancesResource

Client for /ref/instance, the portal instances.

This index has no docid field, so it pages by start offset and sorts on its own id field instead. The route ignores q and answers the full table for every query, so get() and exists() match the requested id against that table on the client side.

get(id: str | int, *, select: Sequence[str] | None = None, params: Mapping[str, Any] | None = None) -> HalInstance async

Fetch one portal instance by its id.

exists(id: str | int) -> bool async

Return True when a portal instance has this id.

bibliofabric.hal.ProjectsResource

Client for /ref/anrproject and /ref/europeanproject.

The client exposes the two routes as separate instances (client.anr_projects and client.european_projects); the class itself carries the ANR path.

bibliofabric.hal.MetadatasResource

Client for /ref/metadatalist, the metadata value tables.

bibliofabric.hal.DocumentTypesResource

Client for /ref/doctype.

The route takes no paging and answers the full table in one request.

list_types() -> list[Doctype] async

Return the document types with their subtypes.

Models

bibliofabric.hal.HalDocument

One HAL document record (a Solr doc of /search/).

The declared fields cover the stable core of the schema. A record carries only the fields the caller selected with fl; the remaining keys of the raw document stay reachable through model_extra.

author_id_hal: SafeList[str] = Field(default_factory=list, alias='authIdHal_s') class-attribute instance-attribute

HAL author identifiers, for example pascal-tilmant.

doc_type: SafeStr = Field('', alias='docType_s') class-attribute instance-attribute

ART, COMM, COUV, THESE, HDR, OUV, ...

docid: SafeStr = Field('', alias='docid') class-attribute instance-attribute

Internal numeric identifier, unique across the HAL referentials.

file_main: SafeStr = Field('', alias='fileMain_s') class-attribute instance-attribute

URL of the main deposited file (.../document), empty without one.

first_abstract: str property

The first abstract, or "" when the record carries none.

hal_id: SafeStr = Field('', alias='halId_s') class-attribute instance-attribute

Public identifier, for example hal-03923934 or tel-00999994.

label: SafeStr = Field('', alias='label_s') class-attribute instance-attribute

Ready-made citation string HAL renders for the record.

main_title: str property

The first title, or "" when the record carries none.

submit_type: SafeStr = Field('', alias='submitType_s') class-attribute instance-attribute

file, notice, or file+notice.

uri: SafeStr = Field('', alias='uri_s') class-attribute instance-attribute

Canonical public URL, versioned (.../hal-03923934v1).

bibliofabric.hal.HalStructure

One research structure of /ref/structure.

type: SafeStr = Field('', alias='type_s') class-attribute instance-attribute

laboratory, institution, regroupinstitution, ...

valid: SafeStr = Field('', alias='valid_s') class-attribute instance-attribute

VALID, OLD, or INCOMING.

bibliofabric.hal.HalJournal

One journal of /ref/journal.

valid: SafeStr = Field('', alias='valid_s') class-attribute instance-attribute

VALID, OLD, or INCOMING.

bibliofabric.hal.HalAuthor

One author reference of /ref/author.

A docid has the form <form>-<person> (for example 164005-0); form_i is the numeric form part.

valid: SafeStr = Field('', alias='valid_s') class-attribute instance-attribute

VALID, OLD, or INCOMING.

bibliofabric.hal.HalDomain

One HAL domain of /ref/domain.

code: SafeStr = Field('', alias='code_s') class-attribute instance-attribute

Domain code, for example chim or info.info-io.

bibliofabric.hal.HalInstance

One portal instance of /ref/instance.

code: SafeStr = Field('', alias='code') class-attribute instance-attribute

Portal code used in /search/<code>/ paths, for example tel.

bibliofabric.hal.HalProject

One funding project of /ref/anrproject or /ref/europeanproject.

reference: SafeStr = Field('', alias='reference_s') class-attribute instance-attribute

Grant reference, for example ANR-06-BLAN-0273.

valid: SafeStr = Field('', alias='valid_s') class-attribute instance-attribute

VALID, OLD, or INCOMING.

bibliofabric.hal.HalMetadata

One metadata value of /ref/metadatalist.

meta_name: SafeStr = Field('', alias='metaName_s') class-attribute instance-attribute

Metadata field name, for example dumas_degreeSubject.

meta_value: SafeStr = Field('', alias='metaValue_s') class-attribute instance-attribute

Numeric code of the value.

bibliofabric.hal.Doctype

One document type of /ref/doctype.

children holds the subtypes (for example ARTREV under ART).

Filters and helpers

bibliofabric.hal.DocumentFilters

Filters for the /search/ document index.

The aliases are the Solr field names of the HAL index; the documentation lists the full schema at https://api.archives-ouvertes.fr/docs/search.

collection: StrFilter = Field(None, alias='collCode_s') class-attribute instance-attribute

Collection codes, for example FRANCE-GRILLES.

doc_type: StrFilter = Field(None, alias='docType_s') class-attribute instance-attribute

Document type codes: ART, COMM, COUV, THESE, HDR, ...

domain: StrFilter = Field(None, alias='domain_s') class-attribute instance-attribute

HAL domain codes, for example chim or info.info-io.

has_doi: bool | None = Field(None, alias='has_doi') class-attribute instance-attribute

Presence filter: doiId_s:["" TO *] or its negation.

language: StrFilter = Field(None, alias='language_s') class-attribute instance-attribute

ISO 639 codes, for example en or fr.

portal_instance: StrFilter = Field(None, alias='instance_s') class-attribute instance-attribute

Portal instance code, for example tel or hal.

submit_type: StrFilter = Field(None, alias='submitType_s') class-attribute instance-attribute

file, notice, or file+notice.

year: StrFilter = Field(None, alias='producedDateY_i') class-attribute instance-attribute

Production year, one value or a Solr range ([2000 TO 2013]).

bibliofabric.hal.document_query(id: str | int) -> str

Build the Solr query that addresses one document id.

Accepts a bare docid (3923934), a HAL identifier (hal-03923934), a DOI, or a record URL (the last path segment is used, its v<n> version suffix dropped).