Upstream quirks
Facts of the NIH RePORTER API v2 that shape how the client works.
Paging and depth caps
- Both routes page with
offsetandlimitonly. There are no cursors and no page numbers. limitaccepts 1 to 500; a larger value is rejected with a 400 whose body is{"message": "..."}. The API default page size is 50.- The offset cap differs per route: 9,999 on publications and 14,999 on
projects. The API rejects a larger offset with a 400
(
Requested limit exceeded. Maximum offset is 9,999.). The client raisesConfigurationErrorbefore sending such a request. - The documented intent is also that an offset must not exceed the total of
the query. A query with a small total answers offset 0 with the matching
records and is not a reliable way to detect exhaustion;
iterate()stops on the first empty page. - Deep-offset project queries are slow.
offset=14999on the projects route repeatedly timed out client-side at 90 seconds while the same route with a filter answered in under a second. Prefer narrow filters over deep paging.
POST bodies
- Both routes are POST searches. Filter keys travel inside
criteria, whileoffset,limit,include_fields,exclude_fields,sort_field, andsort_orderstay at the top level. The wire format is snake_case, which the API documentation uses throughout; the OpenAPI document athttps://api.reporter.nih.gov/swagger/v2/swagger.jsoninstead names the same fields camelCase and is outdated on this point. - Unknown criteria keys are silently ignored:
{"criteria": {"bogus_field": 1}}answers 200 with the unfiltered total. A misspelled filter changes nothing instead of failing, so prefer the typedProjectFiltersandPublicationFilters. - Some typed criteria still 400 on bad values: a bare string in
full_study_sections(the API wants objects such as{"srg_code": "SBIA"}) or an unknownfunding_mechanismcode. - On the publications route, the
appl_idscriterion matches the publications of the application's whole project family. Querying one application id answered with 580 records across more than 50 core project numbers, soappl_idcannot key a batch lookup;batch_get()on publications acceptspmidandcore_project_numonly. Both criteria match several records per id, and records sort bycoreproject desc, so the resource sends one id per request;batch_get()still returns one record per id. - Unknown fields raise
ConfigurationErrorinbatch_get(field=...). The API silently ignores unknown criteria keys, so sending an unmapped field would answer with unfiltered records. - The
publications_searchcriterion that the OpenAPI document lists on the projects criteria is ignored by the live API under both spellings.
Field selection and sorting
include_fieldsandexclude_fieldstake the CamelCase property names of the routes (ApplId,ProjectNum,OrgName), while records come back with snake_case keys (appl_id,project_num,org_name).sort_fieldandsort_ordertravel as two top-level keys;sort_orderisascordescand defaults toasc.- The publications route answers with
sort_field: coreprojectandsort_order: descwhen the request names no sort; the projects route answers withsort_field: null.
Response shapes
- Every search answer is
{"meta": {...}, "results": [...]}.meta.totalis the full count of the query.meta.search_idandmeta.properties.URLappear on project answers and reference the same search in the RePORTER web application; a top-levelsearch_idpayload key replays it. - Publication records carry exactly three fields with camelCase wire keys:
coreproject,pmid, andapplid. One PMID can appear in several records, once per linked project. - Project records use snake_case keys and carry dates as
YYYY-MM-DDTHH:MM:SSstrings; the models validate them intodatetime.arra_fundedandmultiyear_award_flagarrive as"Y"/"N"strings and validate intobool. covid_responseis a string in the route documentation but arrives as a list (["Reg-CV"]) on records that have it.- Error bodies are
{"message": "..."}objects; some validation failures answer with an HTML-escaped JSON array string inside that message.