Skip to content

API reference

Generated from the source with mkdocstrings.

Client

bibliofabric.pubmed.PubmedClient

Client for the NCBI E-utilities (eutils.ncbi.nlm.nih.gov), the programmatic interface of PubMed.

The client answers JSON everywhere except efetch.fcgi, whose PubmedArticleSet XML it parses into :class:bibliofabric.pubmed.PubmedArticle models. Without an API key the upstream allows 3 requests per second, which the default settings pace; with api_key the ceiling rises to 10 per second and PUBMED_MAX_REQUESTS_PER_SECOND=10 uses it. api_key rides every request as the api_key query parameter and is redacted from logs; tool and email ride as plain contact parameters, as NCBI asks every caller to send them.

ids: IdsResource cached property

The esearch.fcgi resource: uid search, counts, and paging.

summaries: SummariesResource cached property

The esummary.fcgi resource: document summaries.

records: RecordsResource cached property

The efetch.fcgi resource: full PubMed records (XML).

The elink.fcgi resource: cross-database links and provider URLs.

info: InfoResource cached property

The einfo.fcgi resource: database metadata and field lists.

The sync client PubmedSyncClient mirrors the async classes method for method, with IdsSyncResource, SummariesSyncResource, RecordsSyncResource, LinksSyncResource, and InfoSyncResource on the same attributes.

Settings

bibliofabric.pubmed.PubmedSettings

PubMed-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 the keyless defaults (3 req/s, concurrency 2). api_key raises the upstream ceiling to 10 req/s; pass PUBMED_MAX_REQUESTS_PER_SECOND=10 to use it.

api_key: SecretStr | None = Field(default=None, repr=False) class-attribute instance-attribute

NCBI API key, sent as the api_key query parameter and redacted from logs.

email: str | None = None class-attribute instance-attribute

Value of the email query parameter NCBI asks every caller to send.

tool: str | None = 'bibliofabric' class-attribute instance-attribute

Value of the tool query parameter NCBI asks every caller to send.

Models

bibliofabric.pubmed.Uid

One record identifier of an esearch.fcgi result.

uid: str instance-attribute

The PubMed uid (PMID) the search returned.

bibliofabric.pubmed.Summary

One document summary of an esummary.fcgi answer.

PubMed docsums carry the fields declared below; unknown keys are kept on the model through extra="allow". A summary upstream could not build carries only uid and error; :meth:SummariesResource.get turns that into :class:bibliofabric.exceptions.NotFoundError.

doi: str | None property

The DOI of the record, from its articleids, when present.

error: str | None = None class-attribute instance-attribute

The upstream error message when the summary could not be built.

pmcid: str | None property

The PubMed Central id of the record, when deposited.

pmcrefcount: str | int | None = None class-attribute instance-attribute

The number of free full-text references in PMC; upstream serves it as a string or an int depending on the record.

references: list[str | SummaryReference] | None = None class-attribute instance-attribute

Citation strings; some entries arrive as structured objects.

bibliofabric.pubmed.SummaryReference

One structured reference entry of an esummary record.

Most records carry plain citation strings; some entries arrive as objects, for example an erratum note with its own pmid.

bibliofabric.pubmed.PubmedArticle

One PubMed record from an efetch.fcgi answer.

doi: str | None property

The DOI of the record, from its article id list, when present.

pmcid: str | None property

The PubMed Central id of the record, when deposited.

pmid: str | None property

The PubMed id of the record.

title: str | None property

The article title of the record.

bibliofabric.pubmed.DbInfo

The metadata of one E-utilities database.

bibliofabric.pubmed.LinkSet

The links of one input uid.

dbfrom: str | None = None class-attribute instance-attribute

The database the input uid belongs to.

error: str | None = None class-attribute instance-attribute

The upstream error message when the link set could not be built.

ids: list[str] | None = None class-attribute instance-attribute

The input uid this link set describes.

linksetdbs: list[LinkSetDb] | None = None class-attribute instance-attribute

The groups of linked uids, one per dbto and link name.

bibliofabric.pubmed.IdUrlSet

The provider URLs of one input uid.

id: str | None = None class-attribute instance-attribute

The input uid this set describes.

objurls: list[LinkUrl] | None = None class-attribute instance-attribute

The provider URLs for the uid.