API reference
Generated from the source with mkdocstrings.
Client
bibliofabric.nihreporter.NihReporterClient
Client for the NIH RePORTER API v2.
The API serves public domain data of the United States government and needs no credentials. The client paces itself at one request per second by default, the rate the NIH RePORTER API site recommends.
projects: ProjectsResource
cached
property
The projects search resource.
publications: PublicationsResource
cached
property
The publications search resource.
The sync twin NihReporterSyncClient mirrors the client method for method
and exports from the same module: from bibliofabric.nihreporter import
NihReporterSyncClient.
Settings
bibliofabric.nihreporter.NihReporterSettings
NIH RePORTER 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 NIH
defaults (1 request per second, concurrency 1) for the one-request-per-
second policy the NIH RePORTER API site documents. The API is public
domain data of the United States government; the client sends no
credentials.
Resources
Each resource inherits the generic operations from bibliofabric.Resource
(search, iterate, collect, first, count, batch_get). get and
exists are disabled on both resources because the API has no
single-record route.
bibliofabric.nihreporter.ProjectsResource
Client for the /v2/projects/search route.
get() and exists() raise :class:ConfigurationError: the API
has no single-record route. batch_get() fetches many application
ids through the appl_ids criterion; one query serves at most 500
records, and offset paging reaches at most record 14,999 of a query.
bibliofabric.nihreporter.PublicationsResource
Client for the /v2/publications/search route.
batch_get() fetches by field="pmid" or "core_project_num",
each mapped to its criteria key. Both criteria match several records per
id (one publication appears once per linked project), and the route
sorts by coreproject desc, so a chunk of several ids misses records
outside the first page; the resource therefore batches one id per
request and returns one record per id. Offset paging reaches at most
record 9,999 of a query, and the route has no free-text criterion.
batch_get(field="appl_id") is not offered: the appl_ids criterion
matches the publications of the application's whole project family, not
the application itself, so a batch lookup for one application id cannot
find its records reliably (see docs/nihreporter/upstream-quirks.md).
Filters
Criteria models for the filters= argument of both resources. Array
criteria read as OR inside one key and as AND across keys.
bibliofabric.nihreporter.ProjectFilters
Filter model for the /v2/projects/search route.
Array criteria read as OR inside one key (any of the values) and as
AND across keys. fiscal_years=[] is the documented way to search
all fiscal years. org_names matches with wildcards; pass
org_names_exact_match for exact names. project_nums accepts
* wildcards. award_types takes 4C for competing type 4 and
4N for noncompeting type 4.
bibliofabric.nihreporter.PublicationFilters
Filter model for the /v2/publications/search route.
pmids takes PubMed ids, appl_ids application ids, and
core_project_nums core project numbers; project numbers accept
* wildcards. The route has no free-text criterion.
bibliofabric.nihreporter.NameCriteria
One person-name criterion of pi_names and po_names.
any_name, first_name, and last_name match with wildcards, so
partial names are accepted; middle_name matches exactly.
bibliofabric.nihreporter.AdvancedTextSearch
The advanced_text_search criterion.
operator is and, or, or advanced. search_field takes
projecttitle, abstracttext, terms, or all; several fields
are comma separated (projecttitle,terms). search_text is the
text to find; quote phrases for exact matches.
bibliofabric.nihreporter.DateRange
A from/to date range (project_start_date, date_added, ...).
Both values take YYYY-MM-DD. Leave a side None (it is omitted)
to make the range open on that side.
bibliofabric.nihreporter.AmountRange
An award amount range for award_amount_range.
bibliofabric.nihreporter.ProjectNumSplit
A split project number for project_num_split.
Every part is a string and every part is optional; the parts together assemble one grant number (application type, activity code, institute code, serial number, support year, and suffix).
bibliofabric.nihreporter.SpendingCategoriesCriteria
NIH spending categories for spending_categories.
values takes the numeric RCRC category identifiers. With
match_all=True the project must carry every category, with
match_all=False at least one.
bibliofabric.nihreporter.StudySectionCriteria
A study section for full_study_sections.
The API reads this criterion as objects, not as bare codes, and rejects
a bare string with a 400. srg_code is the common key (SBIA).
Records
bibliofabric.nihreporter.Project
One NIH RePORTER project record.
Dates arrive as YYYY-MM-DDTHH:MM:SS strings and validate into
datetime. arra_funded arrives as Y/N and validates into
bool. terms and pref_terms are <...> or
semicolon-joined term strings; spending_categories_desc repeats the
descriptions of the spending_categories identifiers.
contact_pi: PrincipalInvestigator | None
property
Return the contact principal investigator, if the record names one.
bibliofabric.nihreporter.Publication
One NIH RePORTER publication record.
The route serves three fields: the core project number, the PubMed id, and the latest application id linked to the publication.
Nested record models
bibliofabric.nihreporter.Organization
The funded organization of a project.
org_duns and org_ueis are the historical DUNS and UEI lists;
primary_duns and primary_uei the current values.
bibliofabric.nihreporter.OrganizationType
The organization type of a project (school of medicine, and so on).
bibliofabric.nihreporter.PrincipalInvestigator
One principal investigator of a project.
bibliofabric.nihreporter.ProgramOfficer
One program officer of a project.
bibliofabric.nihreporter.AgencyIc
One NIH institute or center, as admin agency or funding source.
bibliofabric.nihreporter.AgencyIcAdmin
The admin institute or center of a project.
bibliofabric.nihreporter.AgencyIcFunding
One institute or center that funds the project in one fiscal year.
bibliofabric.nihreporter.FullStudySection
The study section that reviewed the application.
bibliofabric.nihreporter.GeoLocation
The geographic coordinates of the funded organization.
Dialect constants
NIHREPORTER_DIALECT and PROJECTS_DIALECT declare the paging names of the
two routes (limit, offset, the 500 page-size cap, and the 9,999 and
14,999 offset caps). NIHREPORTER_API_BASE_URL is
https://api.reporter.nih.gov/v2. They are exported for inspection, not for
composition.