API reference
Generated from the source with mkdocstrings.
Client
rorifer.RoriferClient
Bases: BaseApiClient
Client for the ROR v2 API.
The API needs no credentials. The client sends Accept: application/json
on every request; the API answers no other representation.
organizations
cached
property
The organizations resource client.
dumps
cached
property
The ROR data dumps hosted on Zenodo.
heartbeat()
async
Return True when the ROR API answers its health check with OK.
The check calls GET /heartbeat on the host of the base URL,
outside the v2 prefix. An error status raises, as with every
request.
rate_class(request)
Pace requests to Zenodo in their own class.
The anonymous Zenodo search accepts 30 requests per minute, far less
than the ROR API, so the data dump helper gets the zenodo rate
class of :attr:RoriferSettings.rate_limits.
Sync client
rorifer.RoriferSyncClient
Bases: SyncBaseApiClient
Client for the ROR v2 API.
The API needs no credentials. The client sends Accept: application/json
on every request; the API answers no other representation.
organizations
cached
property
The organizations resource client.
dumps
cached
property
The ROR data dumps hosted on Zenodo.
heartbeat()
Return True when the ROR API answers its health check with OK.
The check calls GET /heartbeat on the host of the base URL,
outside the v2 prefix. An error status raises, as with every
request.
rate_class(request)
Pace requests to Zenodo in their own class.
The anonymous Zenodo search accepts 30 requests per minute, far less
than the ROR API, so the data dump helper gets the zenodo rate
class of :attr:RoriferSettings.rate_limits.
Settings
rorifer.RoriferSettings
Bases: BaseApiSettings
ROR-specific client settings.
Inherits timeout, max_retries, max_retry_wait,
max_requests_per_second, max_concurrency, rate_limits,
user_agent and mailto from :class:bibliofabric.config.BaseApiSettings
and sets ROR defaults: 6 requests per second, concurrency 5, and a
zenodo class at one request every 2 seconds for the data dump
helper, because the anonymous Zenodo search accepts 30 requests per
minute. The API needs no credentials.
Resource clients
Each resource client inherits the generic operations from bibliofabric.ResourceClient (get, search, iterate, collect, first, count) through rorifer._async.dialect.RoriferResourceClient. Only the members that ROR changes or adds are shown here.
rorifer._async.organizations.OrganizationsClient
Bases: RoriferResourceClient[Organization]
Client for the /organizations endpoint.
Pages hold 20 records and the API serves pages 1 to 500, so one query
reaches at most 10,000 records. For the whole registry, download a data
dump through :attr:RoriferClient.dumps.
search(filters=None, *, query=None, sort=None, select=None, page=None, page_size=None, cursor=None, on_error='raise', failures=None, params=None, advanced=None, all_status=False)
async
Fetch one page of organizations as a typed :class:Page.
query is a keyword search over names and external ids;
advanced is an Elasticsearch query-string over record fields
(query.advanced, for example names.value:"University of
Twente"). ROR rejects a request that carries both.
all_status includes inactive and withdrawn records; by default
only active records answer. :attr:Page.meta carries ROR's facet
counts (types, countries, continents, statuses) and
time_taken.
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
|
iterate(filters=None, *, query=None, sort=None, select=None, page_size=None, limit=None, cursor=None, on_error='raise', failures=None, on_page=None, params=None, advanced=None, all_status=False)
Iterate over all matching organizations, page by page.
Accepts the same arguments as :meth:search. Iteration stops at
limit, on an empty page, or when number_of_results records
were seen. A query with more than 10,000 matches raises
:class:~bibliofabric.exceptions.ConfigurationError when it asks
for page 501, so pass a limit of at most 10,000 for broad
queries.
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
|
collect(filters=None, *, limit=None, query=None, sort=None, select=None, page_size=None, cursor=None, on_error='raise', failures=None, on_page=None, params=None, advanced=None, all_status=False)
async
Collect the output of :meth:iterate into a list, bounded by limit.
first(filters=None, *, query=None, sort=None, select=None, page_size=None, cursor=None, on_error='raise', failures=None, params=None, advanced=None, all_status=False)
async
Return the first matching organization, or None when there is none.
ROR fixes pages at 20 records, so the call reads one page and returns
its first record. It accepts the same arguments as :meth:iterate
except limit and on_page.
count(filters=None, *, query=None, params=None, advanced=None, all_status=False)
async
Return number_of_results of the query.
ROR has no count-only route, so this fetches one full page.
match_affiliation(affiliation)
async
Match a free-text affiliation string to organizations.
Runs ROR's affiliation matcher (?affiliation=) and returns up to
10 candidates, each with a score from 0 to 1; ROR marks one
candidate chosen. The matched input is in substring.
find_by_external_id(value, *, id_type=None)
async
Return the organizations that carry value as an external id.
id_type restricts the match to one scheme (fundref, grid,
isni, wikidata); None checks every scheme. ROR matches
the stored spelling exactly, so an ISNI is searched in its grouped
and its compact form and a Wikidata id in either case. Inactive and
withdrawn records are included, because a withdrawn record can
still be the target of a crosswalk.
find_by_funder_doi(doi)
async
Return the organizations registered under a Crossref funder DOI.
doi is a Crossref Funder Registry DOI such as
10.13039/100000001; the search uses its FundRef id.
rorifer._async.dialect.RoriferResourceClient
Bases: ResourceClient[E]
Base client for ROR resources: filter serialization and id normalization.
build_filter_params(filters)
Convert filter criteria into ROR's single filter parameter.
normalize_id(value)
Return the bare lowercase ROR id.
https://ror.org/006hf6230, ror.org/006hf6230, and
006hf6230 all become 006hf6230; ROR accepts the three forms.
exists(id)
async
Return True when id exists; 404 returns False.
Uses GET because the ROR gateway answers HEAD with 403.
with_query_options(params, *, advanced, all_status)
staticmethod
Merge the query.advanced and all_status parameters into params.
rorifer._async.dumps.DumpsClient
Access to the ROR data dumps in the ror-data Zenodo community.
download(dump, dest)
async
Stream the dump zip to dest and return the path.
Creates parent directories and overwrites an existing file.
latest()
async
Return the newest dump release.
Reads the Zenodo concept record of the dumps, which redirects to the latest version.
list(*, limit=5)
async
Return the most recently updated dump releases, at most limit.
Every ROR release is one Zenodo record. The search answers one record
per release only with all_versions; without it, Zenodo collapses
a release series into its newest version. Anonymous callers get 25
records per page, so the method follows the pages until limit
records arrived or the releases run out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
Maximum number of dump records to return. |
5
|
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
|
APIError
|
Zenodo answered with a body that has no |
Filters
rorifer.OrganizationFilters
Bases: BaseModel
Filter model for the /organizations route.
A sequence value ORs its items (types=["education", "nonprofit"]) and
different keys AND. status is active, inactive, or
withdrawn. Country codes are ISO 3166-1 alpha-2 in any case; country
and continent names must match ROR's spelling exactly (The
Netherlands), so prefer the codes.
rorifer.filters.external_id_query(value, *, id_type=None)
Return the query.advanced clause that matches one external id.
ROR compares external_ids.all with the stored spelling and case, so
the clause ORs every spelling ROR may store: the value as given, an ISNI
in its grouped and its compact form, and a Wikidata id in upper case.
ROR's query parser cannot search a value that contains ", \ or
:, so those raise :class:ConfigurationError; pass the bare id.
Dialect and helpers
rorifer.dialect
ROR query dialect constants.
ROR_DIALECT tells bibliofabric how ROR names its query parameters. The
resource-client base that consumes these constants lives in
:mod:rorifer._async.dialect (its sync twin is generated from it).
ROR_API_BASE_URL = 'https://api.ror.org/v2'
module-attribute
ROR_HEARTBEAT_PATH = '/heartbeat'
module-attribute
ROR_ZENODO_API_BASE_URL = 'https://zenodo.org/api'
module-attribute
ROR_ZENODO_HOST = 'zenodo.org'
module-attribute
ROR_ZENODO_COMMUNITY = 'ror-data'
module-attribute
ROR_ZENODO_CONCEPT_RECORD_ID = 6347574
module-attribute
ZENODO_SEARCH_PAGE_SIZE = 25
module-attribute
ZENODO_SEARCH_REQUESTS_PER_SECOND = 0.5
module-attribute
ROR_PAGE_SIZE = 20
module-attribute
ROR_MAX_PAGE = 500
module-attribute
ORGANIZATION_TYPES = frozenset({'archive', 'company', 'education', 'facility', 'government', 'healthcare', 'nonprofit', 'other', 'funder'})
module-attribute
RECORD_STATUSES = frozenset({'active', 'inactive', 'withdrawn'})
module-attribute
ROR_FILTER_KEYS = frozenset({'status', 'types', 'country.country_code', 'country.country_name', 'locations.geonames_details.country_code', 'locations.geonames_details.country_name', 'locations.geonames_details.continent_code', 'locations.geonames_details.continent_name'})
module-attribute
rorifer.unwrapper.RoriferUnwrapper
Extracts results, totals, and metadata from ROR JSON.
item(body)
Return the record itself; ROR single routes are unwrapped.
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
The body carries ROR's |
APIError
|
The body is not a JSON object. |
meta(body)
Return the facet counts (types, countries, continents, statuses) and time_taken.
next_cursor(body)
Return None; ROR pages by page number only.
results(body)
Return the items of a search envelope.
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
The body carries ROR's |
APIError
|
The body has no |
total(body)
Return number_of_results, or None when absent.
rorifer.dump.iter_dump_records(zip_path)
Yield every organization record of a downloaded dump zip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zip_path
|
Path | str
|
Path to a |
required |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
The zip has no |
rorifer.dump.index_external_ids(records, id_type)
Group records by every external_ids.all value of one id_type.
Keys are compacted (whitespace removed, lowercased), so an ISNI typed as
0000000403998953 finds the record that stores
0000 0004 0399 8953. Each key maps to the records carrying it, in
dump order.
rorifer.dump.compact_external_id(value)
Return value in the key form :func:index_external_ids uses.
rorifer.crosswalk.fundref_id_from_doi(doi)
Return the FundRef id of a Crossref funder DOI.
10.13039/100000001 (also as a https://doi.org/... URL) becomes
100000001. A DOI with another prefix raises ValueError.
rorifer.crosswalk.fundref_doi_from_id(fundref_id)
Return the Crossref funder DOI of a FundRef id (100000001 to 10.13039/100000001).
Models
The models live in rorifer.models and are re-exported from the top-level package. They are plain Pydantic models with extra="allow".
rorifer.models.Organization
Bases: BaseModel
A ROR v2 organization record (schema 2.1).
id is the record URL (https://ror.org/006hf6230), status is
active, inactive, or withdrawn, and types holds any of
archive, company, education, facility, funder,
government, healthcare, nonprofit, and other.
display_name
property
The name ROR displays, else the first label, else the first name.
external_ids_of_type(id_type)
Return every external_ids.all value whose type is id_type.
rorifer.models.Name
Bases: BaseModel
An organization name.
types holds any of ror_display, label, alias and
acronym. lang is None when the name has no language
(acronyms, most aliases).
rorifer.models.ExternalId
Bases: BaseModel
One external identifier scheme of an organization.
type is fundref, grid, isni, or wikidata. all
lists every known value and preferred the one ROR displays
(None when there is a single value).
rorifer.models.Location
Bases: BaseModel
A physical location of an organization.
rorifer.models.GeonamesDetails
Bases: BaseModel
Geonames place details of a location.
rorifer.models.Relationship
Bases: BaseModel
A link to another organization.
type is parent, child, related, successor, or
predecessor; id is the ROR URL of the other record.
rorifer.models.Link
Bases: BaseModel
A web link of an organization (website, wikipedia).
rorifer.models.Admin
Bases: BaseModel
Record provenance: when ROR created and last modified the record.
rorifer.models.AdminDate
Bases: BaseModel
Creation or modification date of a record and the schema version then.
rorifer.models.AffiliationMatch
Bases: BaseModel
One candidate of an affiliation string match.
ROR marks exactly one candidate chosen and scores each from 0 to 1.
rorifer.models.RorDump
Bases: BaseModel
One versioned ROR data dump (a Zenodo record of the ror-data community).
record_id is the Zenodo record id, version the ROR data release
(for example v2.16), and files the downloadable files, normally
one zip holding a JSON and a CSV serialization of every record.
record_id = Field(default=None, alias='id')
class-attribute
instance-attribute
concept_id = Field(default=None, alias='conceptrecid')
class-attribute
instance-attribute
doi = None
class-attribute
instance-attribute
title
property
The record title (ROR Data).
publication_date
property
The ISO date the dump was published.
version
property
The ROR data release version (for example v2.16).
zip_file
property
The first .zip file of the dump, or None when there is none.
zip_url
property
The download URL of the zip file, or None when it is unknown.
rorifer.models.DumpFile
Bases: BaseModel
One file of a Zenodo dump record (key, size in bytes, checksum).
rorifer.models.DumpFileLinks
Bases: BaseModel
Links of one dump file; self_url downloads the file content.
rorifer.models.DumpMetadata
Bases: BaseModel
The Zenodo record metadata of a dump (title, version, publication date).
rorifer.models.DumpLinks
Bases: BaseModel
Links of a Zenodo dump record.