Skip to content

Grants, profiles, and preprints

Grants (the Grist API)

client.grants talks to the grants RESTful (Grist) API, a separate service that holds the grants of the Europe PMC funders.

response = await client.grants.search("malaria", page=1)
print(response.hit_count)  # the API reports it as a string
for record in response.record_list.record:
    print(record.grant.id, record.grant.funder.name, record.person.family_name)

async for record in client.grants.iterate("ga:Wellcome Trust", limit=10):
    print(record.grant.id, record.person.family_name)  # limit counts records

search returns the typed GrantsResponse envelope; the route pages with page and has no page-size parameter. iterate walks pages until the record list empties and yields GrantRecords one by one; limit bounds the number of records (it counted pages in earlier builds), limit=0 sends no request, and a negative limit raises ConfigurationError. Grist wants the parameters glued to the query path (get/query=malaria&format=json&page=1); the client builds that URL and never sends a ? query string, which the route answers with 406.

Profiles

response = await client.profiles.profile('AUTH:"Kucsko G"')
for source in response.profile_list.source:
    print(source.name, source.count)

profile is one request, not paged: it reports the article counts per source (MED, PMC, PPR, and others), publication type, and subset for a query. profile_type accepts all, lite, or core; synonym=True expands MeSH synonyms.

Preprints

Europe PMC indexes preprints under the PPR source. client.preprints is the search resource scoped to that source: it wraps every query in SRC:PPR AND (...), with the caller query parenthesized so its OR branches stay inside the scope. Every entry point applies the scope, including count(), search_post(), and iterate_post(). A single preprint record comes from client.articles.get("PPR:PPR324115").

page = await client.preprints.search(query="nanodiamond", page_size=25)
print(page.total, page.results[0].source)  # PPR

async for record in client.preprints.iterate(page_size=100):
    print(record.id)