NSF API paging and limits
Reference
How the NSF Award API pages search results: the 0-based offset, the rpp page size, the totalCount cap of 10,000, the AwardAPI-004 failure past that cap, result ordering, and how the client and tools work within these limits.
GET /awards.json pages with two query parameters. offset is a 0-based record offset, and rpp is the number of records per page. Each response reports the total number of matches in response.metadata.totalCount, but the count stops at 10,000. The API also serves no record past number 10,000. A request that reaches past it fails in-band with AwardAPI-004.1
The server keeps tool pages small (25 records at most). It shortens a page that would cross the cap, and it marks capped results so that a caller knows to narrow the search. Ordering is newest startDate first, but ties are not stable between calls, so a page boundary can repeat or skip a record.12 For the tool-side envelope (hasMore, nextOffset, capped, the paging hint), see Search results.
Schema
| Item | Upstream behaviour | Server behaviour |
|---|---|---|
offset |
0-based record offset | Tool input offset: integer 0-9999, default 03 |
rpp |
Records per page. The API serves pages larger than 25: rpp=250 returned 250 records (verified 2026-12-04).1 |
Tool input limit: integer 1-25, default 25, sent as rpp. The client clamps rpp to 1-25 for searchAwards, which serves every paged tool search; only the merged search_by_pi includeCoPIs fetch asks for more (see Fetching a whole search).4 |
metadata.totalCount |
Total matches, capped at 10000 | Becomes totalResults. capped is true when totalResults >= 10000.5 |
| Records past 10,000 | Never served. offset + rpp > 10000 gives HTTP 200, no records, and a FATAL notice AwardAPI-004.1 |
The client shortens rpp so the page ends at record 10,000, and throws on any FATAL notice. |
| Order | startDate descending. Order among equal start dates is not stable between calls.1 |
search_by_pi with includeCoPIs sorts its merged list itself, by startDate descending, then by id descending.6 |
Page size
Tools page 25 records at a time to keep results small. The API itself serves larger pages.1 The client’s prepareParams sets rpp to min(max(1, trunc(rpp)), maxPageSize). maxPageSize is 25 (NSF_MAX_PAGE_SIZE) for searchAwards, which every paged tool search uses; searchAllPages raises it to maxRecords for every request after the first.4 The unit tests pin this clamping:7
rpp asked |
rpp sent |
|---|---|
0 |
1 |
-5 |
1 |
7.9 |
7 |
10 |
10 |
25 |
25 |
30 |
25 |
The live suite asks for rpp: 100 through searchAwards and gets exactly 25 records with hasMore true. The raw API would have served 100.8
Fetching a whole search
searchAllPages uses the larger pages. Only search_by_pi with includeCoPIs calls it.46 It works in these steps:
- It ignores the caller’s
offsetandrpp. It fetchesoffset=0,rpp=25to learntotalCount. - It throws
Search matches <n> awards, more than the 250 that can be merged; narrow it (e.g. add firstName, institution, stateCode or a date range)when the total exceedsmaxRecords(default 250). - It fetches the remainder with
offset=<records so far>andrpp=<total - records so far>. For this request the page cap ismaxRecords, not 25. With 60 matches, the requests are(offset 0, rpp 25)and then(offset 25, rpp 35).7 - If the API serves a smaller page than asked, it keeps following offsets. It stops on an empty page even when
totalCountpromises more.
Each full result set (the PI side and the Co-PI side) is cached for NSF_API_CACHE_TTL_MS (default 300000 ms, 5 minutes). The cache key is the filters plus maxRecords, without offset and rpp. Concurrent callers share one fetch, and failures are not cached.4 See NSF API client and search_by_pi.
Total count and hasMore
searchAwards computes hasMore from the page:4
- With
totalCount,hasMoreisoffset + returned < min(totalCount, 10000). - Without
totalCount,hasMoreisreturned === rpp, that is, the page is full. totalResultsistotalCount, oroffset + returnedwhen the count is missing.
buildSearchOutput then also requires that the page has at least one record and that offset + returned < 10000. It sets nextOffset to offset + returned only when hasMore is true.5
The 10,000 cap
The API caps totalCount at 10000 and serves nothing past record 10,000. A request with offset + rpp > 10000 returns HTTP 200 with no records and a notificationType: "FATAL" notice with code AwardAPI-004.1 The message text that the unit tests use for this notice is There was an error processing your request.; no fixture captures it from the live API.7
The server handles the cap at three points:
- Schema. The tools accept
offsetonly up to 9999.3 - Client. When
offset < 10000, the client setsrpptomin(rpp, 10000 - offset).offset: 9990, rpp: 25is sent asrpp: 10, returns the last 10 records, and reportshasMore: false.offset: 9975, rpp: 25is sent unchanged.47 - Errors. If a
FATALnotice still comes back,assertNoServiceErrortreats it like anERRORnotice and throwsAwardAPI-004: <message>. The empty page is never mistaken for “no more results”.4 See Response format.
The weekly live suite checks the cap:8
keyword=climatereportstotalResultsof exactly 10000 withhasMoretrue.offset: 9999, rpp: 1returns one record withhasMorefalse.offset: 9990, rpp: 25returns the 10 remaining records, or throws anAwardAPI-004error.
When the count is capped, the tools set capped: true, and the paging hint (the result’s hint field, repeated as content[1]) shows the total as 10000+ and adds: “The NSF API caps counts and paging at 10,000; narrow the search to reach the rest.”5
Ordering
Results are ordered by startDate, newest first.1 The order among awards with the same start date is not stable between calls. A record that is tied with the last record of one page can therefore show up again on the next page, and another tied record can be skipped.1 The live suite fetches keyword=wildfire at offsets 0 and 25 and checks three things:8
- The newest start date on page 2 is no later than the oldest start date on page 1.
- Only records tied on the boundary date repeat. Three repeats were seen live.
- Fewer than 10 records repeat.
The API has no sort parameter: sortBy and sortDir are rejected with AwardAPI-002.1 The server instructions warn the model: “The order of awards with equal start dates can change between calls, so a page boundary may repeat or skip one.”2
search_by_pi with includeCoPIs merges two searches and sorts the result itself. It sorts by startDate descending, then by id descending, so a merged result pages the same way every time.6
Examples
Consecutive pages, as the probe script sends them (rpp=2 at offsets 1 and 26):9
B=https://www.research.gov/awardapi-service/v1
curl -s "$B/awards.json?keyword=wildfire&rpp=2&offset=1"
curl -s "$B/awards.json?keyword=wildfire&rpp=2&offset=26"
The metadata of the fixture search-wildfire-page.json (keyword=wildfire, rpp=3), with 981 matches when it was captured:10
{
"offset": 0,
"rpp": 3,
"totalCount": 981
}
A tool call near the cap, and what the client sends:
search_nsf_awards { "keyword": "climate", "offset": 9990, "limit": 25 }
-> GET /awards.json?keyword=climate&offset=9990&rpp=10
-> 10 records, hasMore: false, capped: true