Persons
client.persons queries /v4/persons and returns Person records. It supports the shared operations (get, exists, search, iterate, collect, first, count, batch_get) plus batch_get_by_orcid and the aggregation helpers.
from bibliofabric.openaire import OpenAireClient, PersonsFilters
client = OpenAireClient()
Later blocks reuse this client. In your own scripts, open it with
async with OpenAireClient() as client: so that the HTTP session closes.
page = await client.persons.search(
PersonsFilters(last_name="Steinbeck", given_name="Christoph"), page_size=3
)
print(page.total, "matches")
for person in page.results:
print(" ", person.id, "|", person.full_name, "|", person.orcid)
1 matches
orcid_______::60f72f7e84453a86e01db34de0c25084 | Christoph Steinbeck | 0000-0001-6966-0814
Filter fields live in PersonsFilters (id, ids_original, given_name, last_name, default_search). The ids.original filter takes ORCID iDs in the hyphenated form.
Get one person
get() accepts an internal id and, for convenience, an ORCID iD in any spelling bibliofabric.ids.normalize_orcid handles (bare, dashed, or an https://orcid.org/ URL). An ORCID resolves through the ids.original filter and raises NotFoundError when no person record carries it:
person = await client.persons.get("0000-0001-6966-0814")
print(person.id, "|", person.full_name, "|", person.orcid)
orcid_______::60f72f7e84453a86e01db34de0c25084 | Christoph Steinbeck | 0000-0001-6966-0814
Fetch many people by ORCID
batch_get_by_orcid() sends one request per 50 iDs as an ids.original OR expression and returns a dict keyed by the hyphenated ORCID. iDs without a person record are absent:
people = await client.persons.batch_get_by_orcid(
["0000-0001-6966-0814", "0000-0002-1825-0097"]
)
for orcid, person in people.items():
print(orcid, "->", person.full_name)
0000-0002-1825-0097 -> Josiah Carberry
0000-0001-6966-0814 -> Christoph Steinbeck
The dict keys follow the order you pass, not the search order.
Counts
n = await client.persons.count()
print("persons:", n)
persons: 16484702