API reference
Generated from the source with mkdocstrings.
Client
bibliofabric.europepmc.EuropePmcClient
Bases: BaseApiClient
Client for the Europe PMC REST web services.
The API needs no credentials. The client sends Accept: application/json
on every request; the annotations API and the grants (Grist) API live on
separate base URLs of the same host and are reachable through their
resource clients.
search
cached
property
The /search resource client.
articles
cached
property
The per-article resource clients (record, XML, links, citations).
annotations
cached
property
The annotations API client.
grants
cached
property
The grants (Grist) API client.
profiles
cached
property
The /profile and /fields client.
preprints
cached
property
The preprint-scoped search client.
Sync client
bibliofabric.europepmc.EuropePmcSyncClient
Bases: SyncBaseApiClient
Client for the Europe PMC REST web services.
The API needs no credentials. The client sends Accept: application/json
on every request; the annotations API and the grants (Grist) API live on
separate base URLs of the same host and are reachable through their
resource clients.
search
cached
property
The /search resource client.
articles
cached
property
The per-article resource clients (record, XML, links, citations).
annotations
cached
property
The annotations API client.
grants
cached
property
The grants (Grist) API client.
profiles
cached
property
The /profile and /fields client.
preprints
cached
property
The preprint-scoped search client.
Settings
bibliofabric.europepmc.EuropePmcSettings
Bases: BaseApiSettings
Europe PMC-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
Europe PMC defaults (3 req/s, concurrency 2). The API needs no
credentials.
Resource clients
bibliofabric.europepmc.SearchClient
Bases: EuropepmcResourceClient[SearchResult]
Client for the /search endpoint.
Europe PMC pages searches with cursorMark tokens (the framework
walks them); nextCursorMark repeats unchanged once the result list is
exhausted. Records come back in resultType=lite shape unless the
caller asks for result_type="core"; the model accepts both.
fields()
async
Return the searchable index terms of the /fields endpoint.
iterate(filters=None, *, query=None, sort=None, select=None, result_type='core', synonym=False, page_size=None, limit=None, cursor=None, on_error='raise', failures=None, on_page=None, params=None)
Iterate over all matching records, cursor page by cursor page.
The framework stops when nextCursorMark repeats, which the API
does once the result list is exhausted.
iterate_post(filters=None, *, query=None, sort=None, select=None, result_type='core', synonym=False, page_size=None, limit=None, cursor=None, on_error='raise', failures=None, on_page=None, params=None)
Iterate over all matching records over POST /searchPOST.
The route pages with cursorMark tokens exactly like the GET
search; iteration stops when nextCursorMark repeats. limit
bounds the number of records; on_page(page_number, next_cursor)
checkpoints progress after every fetched page. limit=0 sends no
request.
search(filters=None, *, query=None, sort=None, select=None, result_type='core', synonym=False, page_size=None, page=None, cursor=None, on_error='raise', failures=None, params=None)
async
Fetch one page of search results as a typed :class:Page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | None
|
Europe PMC query string (for example
|
None
|
result_type
|
ResultType
|
|
'core'
|
synonym
|
bool
|
Expand query terms with MeSH synonyms. |
False
|
sort
|
str | Sequence[str] | None
|
Sort expression such as |
None
|
Returns:
| Type | Description |
|---|---|
Page[SearchResult]
|
One page with |
Page[SearchResult]
|
set to |
search_post(filters=None, *, query=None, sort=None, select=None, result_type='core', synonym=False, page_size=None, page=None, cursor=None, on_error='raise', failures=None, params=None)
async
Fetch one page of search results over POST /searchPOST.
The route is the same search as :meth:search with the parameters
sent as an application/x-www-form-urlencoded body; the envelope
and the cursorMark paging are identical. It is a read-only POST,
so the request is retried.
bibliofabric.europepmc.ArticlesClient
Bases: EuropepmcResourceClient[SearchResult]
Client for the article routes: /article/{source}/{id} and friends.
get("MED:23903748") returns the resultType=core record. The
sibling routes (references, citations, database links, XML full text,
and more) hang off the same resource as named methods; the list routes
reuse the framework paging support. The /article path itself serves
no query route, so the framework search entry points are disabled.
book_xml(id)
async
Return the book XML of an open access bookshelf entry.
id is the Europe PMC NBK accession (for example NBK32884),
the book's metadata PMID, or a combined id such as
PMC:PMC4221854. For a valid id without open access XML the
API answers HTTP 200 with a wrapper document; the client raises
:class:NotFoundError for that answer.
citations(id, *, page=None, page_size=None)
async
Fetch one page of the citation list (citing articles) of an article.
data_links(id, *, category=None, obtained_by=None)
async
Return the data links of an article (not paged, one envelope).
category selects a data link category (for example ALT for
Altmetric); obtained_by filters on the link source.
database_links(id, *, page=None, page_size=None)
async
Fetch one page of the curated database cross-references of an article.
evaluations(id)
async
Return the community evaluations (peer reviews) of an article.
exists(id)
async
Return True when the article exists; 404 returns False.
Uses GET because the Europe PMC gateway answers HEAD with 405.
full_text_xml(id)
async
Return the JATS full text of an open access article as text.
id is a bare Europe PMC id such as PMC13810549 (a PMCID),
or a combined id such as MED:23903748 / MED/23903748. The
route answers 404 for articles without open access full text.
get(id, *, params=None, **kwargs)
async
Fetch one article record as resultType=core.
item_path(id)
Return article/{source}/{id} for a combined article id.
labs_links(id, *, page=None, page_size=None)
async
Return the per-provider link counts of an article.
Paging applies to the provider list.
references(id, *, page=None, page_size=None)
async
Fetch one page of the reference list of an article.
Paging uses page and pageSize; total is the reference
count of the article.
status_updates(ids, *, source=None)
async
Return the status updates of articles (the status monitor).
This is the POST /status-update-search route: it reports the
publication status changes Europe PMC recorded for the queried
articles (for example preprints that received a published version).
It is a read-only POST, so the request is retried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
str | list[str]
|
One article id or a list of them. Combined ids use the
|
required |
source
|
str | None
|
Source code for bare external ids ( |
None
|
supplementary_files(id, *, include_inline_image=False)
async
Return the supplementary files bundle of an article (a ZIP archive).
id is a bare Europe PMC id such as PMC13810549 or a combined
id such as MED:23903748. Pass
include_inline_image=True to also include the inline images of
the article.
bibliofabric.europepmc.AnnotationsClient
Client for the annotations_api endpoints.
The annotations API lives on the same host as the REST web services but
under its own base URL (https://www.ebi.ac.uk/europepmc/annotations_api);
requests reuse the HTTP pool, rate limiter, and retry policy of the
owning client.
__init__(client)
Build the annotations client over an owning :class:EuropePmcClient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
BaseApiClient
|
The owning client; requests reuse its HTTP pool, rate limiter, and retry policy. |
required |
by_article_ids(article_ids, *, type=None, sub_type=None, section=None, provider=None)
async
Return the annotations of one or more articles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article_ids
|
str | list[str]
|
One article id ( |
required |
type
|
str | None
|
Annotation type filter (for example |
None
|
section
|
str | None
|
Article section filter (for example |
None
|
Returns:
| Type | Description |
|---|---|
list[ArticleAnnotations]
|
One record per article, each carrying its annotation list. |
by_entity(entity, *, filter=None, cursor=None, page_size=None)
async
Return the articles annotated with entity (cursor paged).
cursor takes next_cursor_mark of the previous page; None
starts at the first page. The API reports exhaustion by repeating a
cursor of -1.0, which maps to next_cursor_mark=None.
by_provider(provider, *, filter=None, cursor=None, page_size=None)
async
Return the annotations of one provider (cursor paged).
provider is a provider name such as "Europe PMC",
"OpenTargets", or "HES-SO_SIB"; invalid names answer 400.
by_relationship(first_entity, second_entity, *, filter=None, cursor=None, page_size=None)
async
Return articles whose annotations relate two entities (cursor paged).
by_section(*, type=None, sub_type=None, section=None, filter=None, cursor=None, page_size=None)
async
Return annotations filtered by type, subtype, and article section.
This route is large: without filters it covers the whole annotation
store. Always pass at least type, sub_type, or section.
bibliofabric.europepmc.GrantsClient
Client for the grants RESTful (Grist) API.
The Grist database holds the grants of the Europe PMC funders. Its query
endpoint lives at https://www.ebi.ac.uk/europepmc/GristAPI/rest/get
and carries the query in the path (query=malaria). Paging uses the
page parameter; the route has no pageSize (a pageSize query
parameter is concatenated into the query string, which breaks the query).
__init__(client)
Build the grants client over an owning :class:EuropePmcClient.
iterate(query, *, limit=None)
Yield grant records page by page until the record list empties.
The Grist route has no cursor, so the client walks page=1, 2, ...
and stops on the first page without records. limit bounds the
number of records (like the other iterators of this package);
limit=0 sends no request.
search(query, *, page=1, params=None)
async
Search the grants database and return the typed envelope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Grist query string (free text or a field query such as
|
required |
page
|
int
|
1-based page number; each page carries a fixed record set. |
1
|
params
|
Mapping[str, Any] | None
|
Extra Grist parameters, glued into the query path the
way the route needs them (never sent as a |
None
|
Returns:
| Type | Description |
|---|---|
GrantsResponse
|
The typed envelope with |
GrantsResponse
|
a string), the request echo, and the grant records. |
bibliofabric.europepmc.ProfilesClient
Client for the /profile and /fields endpoints.
The profile route reports how many articles match one author or grant query per source and publication type; it is a single request, not paged.
__init__(client)
Build the profiles client over an owning :class:EuropePmcClient.
fields()
async
Return the searchable index terms of the REST search.
profile(query, *, profile_type='all', synonym=False)
async
Return the article counts of one profile query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Europe PMC query string, usually an author query such as
|
required |
profile_type
|
str
|
|
'all'
|
synonym
|
bool
|
Expand query terms with MeSH synonyms. |
False
|
bibliofabric.europepmc.PreprintsClient
Bases: SearchClient
Client for preprint records in Europe PMC.
Europe PMC indexes preprints under the PPR source; they surface
through the same /search route. The client adds SRC:PPR to every
query so callers search the preprint subset only, on every entry point
(search, iterate, count, search_post, iterate_post).
count(filters=None, *, query=None, params=None)
async
Count the preprint records matching the query.
iterate(filters=None, *, query=None, sort=None, select=None, result_type='core', synonym=False, page_size=None, limit=None, cursor=None, on_error='raise', failures=None, on_page=None, params=None)
Iterate over all matching preprints, cursor page by cursor page.
search(filters=None, *, query=None, sort=None, select=None, result_type='core', synonym=False, page_size=None, page=None, cursor=None, on_error='raise', failures=None, params=None)
async
Fetch one page of preprint search results.
search_post(filters=None, *, query=None, sort=None, select=None, result_type='core', synonym=False, page_size=None, page=None, cursor=None, on_error='raise', failures=None, params=None)
async
Fetch one page of preprint search results over POST /searchPOST.
Models
bibliofabric.europepmc.SearchResult
Bases: BaseModel
One Europe PMC search result record.
A resultType=lite record carries the scalar fields; resultType=core
fills in the nested structures. Unknown fields are kept (extra="allow").
bibliofabric.europepmc.Citation
Bases: BaseModel
One reference or citation of an article.
The /references and /citations routes return the same record
shape; unknown fields are kept.
bibliofabric.europepmc.XmlDocument
Bases: BaseModel
A typed wrapper around one XML document answer.
xml carries the document text (JATS article XML for fullTextXML,
book XML for bookXML). The route-level extras appear when the API
answers a small wrapper document instead of the real text (for example a
non-open-access book id).
bibliofabric.europepmc.Annotation
Bases: BaseModel
One annotation of an article: a text span plus its ontology tags.
bibliofabric.europepmc.AnnotationPage
Bases: BaseModel
One page of a cursor-paged annotations query.
by_entity, by_provider, by_relationship and by_section
answer this shape; next_cursor_mark is the cursor to pass back. The
API signals exhaustion with -1.0, which the client maps to None.
bibliofabric.europepmc.GrantRecord
Bases: BaseModel
One record of the Grist answer (RecordList.Record).
bibliofabric.europepmc.GrantsResponse
Bases: BaseModel
The raw envelope of a Grist /get answer.
bibliofabric.europepmc.ProfileResponse
Bases: BaseModel
The answer of the /profile endpoint for one author or grant query.
bibliofabric.europepmc.DataLinksResponse
Bases: BaseModel
The raw envelope of a /{source}/{id}/datalinks response.
Helpers
bibliofabric.europepmc.split_article_id(id)
Split "MED:23903748" or "MED/23903748" into source and id.
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
when the id carries no source part. Europe PMC answers a source-less id only through the search route. |