Skip to content

API reference

Generated from the source with mkdocstrings.

Client

europaea.EuropaeaClient

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

europaea.EuropaeaSyncClient

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

europaea.EuropaeaSettings

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

europaea.SearchClient

Bases: EuropepmcResourceClient[SearchResult]

Client for the /search endpoint.

The route pages with cursorMark tokens (ResourceClient.iterate 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, 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.

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 "DOI:10.1038/nature12373" or "cancer AND OPEN_ACCESS:Y").

None
result_type ResultType

"lite" (metadata scalars) or "core" (adds abstracts, MeSH headings, grants, full text URLs, and more).

'core'
synonym bool

Expand query terms with MeSH synonyms.

False
sort str | Sequence[str] | None

Sort expression such as "CITED desc" or "P_PDATE_D asc".

None

Returns:

Type Description
Page[SearchResult]

One page with total set to hitCount and next_cursor

Page[SearchResult]

set to nextCursorMark.

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.

europaea.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.

book_xml(id) async

Return the book XML of an open access bookshelf entry.

id is the Europe PMC NBK accession (for example NBK32884) or the book's metadata PMID. For a valid id without open access XML the API answers HTTP 200 with a wrapper document that carries a message; the wrapper fields land on :attr:XmlDocument.message and :attr:XmlDocument.is_open_access.

citations(id, *, page=None, page_size=None) async

Fetch one page of the citation list (citing articles) of an article.

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.

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), a PMID, or an NBK accession. 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.

Return the per-provider link counts of an article.

Paging applies to the provider list; providerIds accepts a list of provider identifiers when callers need a subset.

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 SOURCE:ID form ("MED:23903748"); bare ids such as "PPR324115" take source as their source code.

required
source str | None

Source code for bare external ids (PPR, PMC, MED); required when ids carries a bare id.

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. Pass include_inline_image=True to also include the inline images of the article.

europaea.AnnotationsClient

Client for the annotations_api endpoints.

The annotations API is a separate service from the REST web services (base URL https://www.ebi.ac.uk/europepmc/annotations_api). It has five query routes; all answer JSON.

__init__(client)

Build the annotations client over an owning :class:EuropaeaClient.

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 ("MED:23903748") or a list of them, comma-joined into the articleIds parameter.

required
type str | None

Annotation type filter (for example "Chemicals").

None
section str | None

Article section filter (for example "Methods").

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 section or type.

europaea.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:EuropaeaClient.

iterate(query, *, limit=None) async

Collect grant records page by page until the record list empties.

This is a plain helper (the Grist route has no cursor), bounded by limit pages when given.

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 "ga:Wellcome Trust" for a grant agency).

required
page int

1-based page number; each page carries a fixed record set.

1

Returns:

Type Description
GrantsResponse

The typed envelope with hit_count (as the API reports it,

GrantsResponse

a string), the request echo, and the grant records.

europaea.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:EuropaeaClient.

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 "AUTH:%22Mok S%22" or a grant query.

required
profile_type str

"all", "lite", or "core".

'all'
synonym bool

Expand query terms with MeSH synonyms.

False

europaea.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.

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.

Models

europaea.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").

europaea.Citation

Bases: BaseModel

One reference or citation of an article.

The /references and /citations routes return the same record shape; unknown fields are kept.

europaea.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).

europaea.Annotation

Bases: BaseModel

One annotation of an article: a text span plus its ontology tags.

europaea.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.

europaea.GrantRecord

Bases: BaseModel

One record of the Grist answer (RecordList.Record).

europaea.GrantsResponse

Bases: BaseModel

The raw envelope of a Grist /get answer.

europaea.ProfileResponse

Bases: BaseModel

The answer of the /profile endpoint for one author or grant query.

europaea.DataLinksResponse

Bases: BaseModel

The raw envelope of a /{source}/{id}/datalinks response.

Helpers

europaea.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.