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.

Status
stable
Trust tier
unverified
Generated
claude-code/claude-opus-5-5, 2026-12-05
Tags
nsf-apipaginglimitsupstreamlive-verified

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

searchAllPages uses the larger pages. Only search_by_pi with includeCoPIs calls it.46 It works in these steps:

  1. It ignores the caller’s offset and rpp. It fetches offset=0, rpp=25 to learn totalCount.
  2. 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 exceeds maxRecords (default 250).
  3. It fetches the remainder with offset=<records so far> and rpp=<total - records so far>. For this request the page cap is maxRecords, not 25. With 60 matches, the requests are (offset 0, rpp 25) and then (offset 25, rpp 35).7
  4. If the API serves a smaller page than asked, it keeps following offsets. It stops on an empty page even when totalCount promises 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, hasMore is offset + returned < min(totalCount, 10000).
  • Without totalCount, hasMore is returned === rpp, that is, the page is full.
  • totalResults is totalCount, or offset + returned when 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:

  1. Schema. The tools accept offset only up to 9999.3
  2. Client. When offset < 10000, the client sets rpp to min(rpp, 10000 - offset). offset: 9990, rpp: 25 is sent as rpp: 10, returns the last 10 records, and reports hasMore: false. offset: 9975, rpp: 25 is sent unchanged.47
  3. Errors. If a FATAL notice still comes back, assertNoServiceError treats it like an ERROR notice and throws AwardAPI-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=climate reports totalResults of exactly 10000 with hasMore true.
  • offset: 9999, rpp: 1 returns one record with hasMore false.
  • offset: 9990, rpp: 25 returns the 10 remaining records, or throws an AwardAPI-004 error.

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
  1. NSF API Integration and Live API behaviour notes in CLAUDE.md ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10

  2. Server factory and instructions ↩ ↩2

  3. Tool input and output schemas ↩ ↩2

  4. NSF API client ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7

  5. Shared tool helpers (search envelope) ↩ ↩2 ↩3

  6. search_by_pi handler ↩ ↩2 ↩3

  7. Unit tests of the NSF API client ↩ ↩2 ↩3 ↩4

  8. Live tests of the NSF API client ↩ ↩2 ↩3

  9. Raw curl probes of API parameters ↩

  10. Trimmed real API responses used as test fixtures ↩

Sources

  1. NSF API Integration and Live API behaviour notes in CLAUDE.md api-behaviour
  2. NSF API client api-client
  3. Tool input and output schemas tool-schema
  4. Shared tool helpers (search envelope) shared-tools
  5. search_by_pi handler pi-tool
  6. Server factory and instructions server
  7. Live tests of the NSF API client live-api-tests
  8. Unit tests of the NSF API client client-tests
  9. Trimmed real API responses used as test fixtures fixtures
  10. Raw curl probes of API parameters probe-script