NSF API response format

Reference

The shape of NSF Award API responses as observed live: the response envelope, string-typed record values and field quirks, in-band serviceNotification errors, missing records, and how the client normalizes each one.

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

All three NSF Award API endpoints that the server calls (search, award by id and project outcomes) return the same JSON envelope. The award records in it are loosely typed. Every value is a string, absent values are often "", one field name is misspelled, and people are packed into "Name email" strings.1

The client owns these quirks. It parses the body, throws on in-band errors, and runs every record through normalizeAward. Tools, resources and tests therefore only see clean records.2 This page describes the raw format and the conversion of each quirk. For the normalized record that tools return, see Award record. For the normalization code, see Normalization.

Envelope

{
  "response": {
    "award": [],
    "metadata": { "offset": 0, "rpp": 25, "totalCount": 0 },
    "serviceNotification": []
  }
}
Path Type (raw) Notes
response.award array of records The client also accepts a single record object and treats it as a one-item list. XML bodies parse that way.3 A missing or empty award gives no records.
response.metadata.offset number The offset of the page
response.metadata.rpp number The page size
response.metadata.totalCount number Total matches, capped at 10000. See Paging and limits.
response.serviceNotification array of { notificationCode, notificationMessage, notificationType } Present when the API rejects or fails a request. See Service notifications.

Sources: the type definitions4 and the fixtures.5

Parsing

parseResponse accepts three kinds of body:23

Body Result
Already-parsed object (axios parsed the JSON) Used as is
JSON string JSON.parse
Any other string (not valid JSON) Parsed as XML with xml2js (explicitArray: false, ignoreAttrs: true), which gives the same envelope shape with every value as a string. That is why the client converts totalCount with Number(...).

The client throws Failed to parse NSF API response when a body is neither JSON nor XML. It throws the same error for an empty body or a bare null. A body that is not a string or an object gives Unexpected NSF API response format.

Every real reply, including a search with no matches, has a top-level response object. After parsing and the service-notification check, assertNSFResponse throws Unexpected NSF API response (no "response" object, content-type <type>) when it is missing or is not an object, as with an HTML error page, {} or a proxy’s JSON error. Such a body therefore fails instead of reading as “no results” or “award not found”. The content-type part is left out when the reply has none.23

Record values

Every scalar value in a record is a string.1 The raw shapes, with examples from the fixtures,5 are:

Field(s) Raw form Example
estimatedTotalAmt, fundsObligatedAmt String of whole dollars "1498027"
activeAwd, histAwd "true" / "false" "false"
publicAccessMandate "1" / "0" "0"
primaryProgram Array of strings. The type definition also allows a single string. ["01001112DB NSF RESEARCH & RELATED ACTIVIT"]
pi, coPDPI Array of "First M Last email" strings. A person who left the award has (Former) after the name. "First M Last user@example.edu", "First Last (Former) user@example.edu"
piMiddeInitial Misspelled field name (sic) "W"
startDate, expDate, date, initAmendmentDate, latestAmendmentDate mm/dd/yyyy. date is the award action date, which dateStart/dateEnd filter on. "09/01/2011"
fundsObligated Array of per-year strings ["FY 2011 = $1,498,027.00"]
cfdaNumber, progEleCode, progRefCode Comma-separated lists in one string "47.049, 47.050, 47.076"
fundProgramName, program One string, possibly several programs separated by commas "DYN COUPLED NATURAL-HUMAN"
awardeeZipCode, perfZipCode 5 or 9 digits "85721", "708030001"
awardeeDistrictCode, perfDistrictCode State code plus district number "AZ07"
parentUeiNumber, poEmail, poPhone, … Often "" when absent ""
abstractText Plain text, sometimes with \r\n  
projectOutComesReport HTML (capital C). Only present when the PI filed a report. "<div class=\"porColContainerWBG\">..."
jrnl Array of article objects with artTitl, artPageNum, auth, dgtlObjId, jrnlTitl, jrnlVol, jrnlYr, parPblcId  
publicationResearch, publicationConference Arrays of ~-separated citation strings  

The search, detail and outcomes endpoints all return full records. The API ignores printFields.1 Older awards leave out some fields, so every field except id is optional in the types.4

Field groups

RawNSFAward in src/types/nsf-api.types.ts names the fields that the project relies on:4

Group Fields
Identity id, title, agency, transType, cfdaNumber
Awardee awardee, awardeeName, awardeeAddress, awardeeCity, awardeeStateCode, awardeeCountryCode, awardeeZipCode, awardeeDistrict, awardeeDistrictCode, awardeePhone, ueiNumber, parentUeiNumber
People pi, coPDPI, pdPIName, piFirstName, piMiddeInitial, piLastName, piEmail, piId, poName, poEmail, poPhone
Dates startDate, expDate, date, initAmendmentDate, latestAmendmentDate
Money estimatedTotalAmt, fundsObligatedAmt, fundsObligated
Organization and program fundProgramName, program, progEleCode, progRefCode, primaryProgram, dirAbbr, divAbbr, orgLongName, orgLongName2, orgUrl, orgCodeDir, orgCodeDiv, managingPec, fundAgencyCode, awardAgencyCode
Place of performance perfLocation, perfAddress, perfCity, perfStateCode, perfCountryCode, perfZipCode, perfDistrict, perfDistrictCode
Status activeAwd, histAwd, publicAccessMandate
Long text abstractText, projectOutComesReport, publicationResearch, publicationConference, jrnl

awardee is the upper-case organization name ("UNIVERSITY OF ARIZONA"), and awardeeName is the same name in mixed case ("University of Arizona").5 Fields that the API adds later pass through normalization unchanged.4

Normalization

normalizeAward converts every record before anything else sees it:6

Raw Normalized
estimatedTotalAmt, fundsObligatedAmt strings Numbers. $, , and whitespace are stripped first. A blank or non-numeric value leaves the field out.
activeAwd, histAwd, publicAccessMandate Booleans. "true" and "1" become true; "false" and "0" become false. Any other value leaves the field out.
primaryProgram Always an array of strings
pi, coPDPI Arrays of { name, email?, former }. The last word is the email when it contains @. (Former) (any case) is removed from the name and sets former: true. Blank entries are dropped.
piMiddeInitial Renamed to piMiddleInitial
Any field whose value is "" Removed
id Forced to a string
(new) hasOutcomesReport: true when projectOutComesReport is a non-blank string

Dates stay mm/dd/yyyy, and fundsObligated stays a list of strings.7 Unit tests build their data from the real, trimmed responses in tests/fixtures/ run through normalizeAward. Hand-written numeric amounts would hide string-handling bugs, because the live API sends strings.1

The live suite checks the normalized record of award 1114898. The amounts are numbers, activeAwd is a boolean, piMiddeInitial is gone and piMiddleInitial is "W", every Co-PI has a string name without @ and a boolean former, and no value is "".8

Service notifications

The API reports a rejected request as HTTP 200 with response.serviceNotification, not with an error status.1 Two codes have been observed:

Code Type Cause
AwardAPI-002 ERROR An unknown or invalid parameter. The message names it: Invalid parameter(s) sent in the request. Invalid Parameter(s) {awardeeOrganization}.5
AwardAPI-004 FATAL A page that reaches past record 10,000 (offset + rpp > 10000). The response has no records. See Paging and limits.

assertNoServiceError runs on every response. It collects the notices whose notificationType is ERROR or FATAL (case-insensitive), and throws one error whose message is each <notificationCode>: <notificationMessage>, joined with ; . Notices of other types, such as INFO, are ignored.23 The thrown message reaches the caller as an isError tool result. See Errors.

Missing records

A missing award id returns HTTP 200 with an empty award list, not a 404:1

{
  "response": {
    "award": [],
    "metadata": {
      "offset": 0,
      "rpp": 25,
      "totalCount": 0
    }
  }
}

This is the fixture award-missing.json.5 getAward and getProjectOutcomes return null for it, and the tools turn null into a not-found error. An HTTP 404 is not treated this way: since the API never answers a missing award with 404, the client throws NSF API <operation> failed (HTTP 404) without a retry.23 See GET /awards/{id}.json.

Examples

An XML search page parses to the same envelope, with a single award object. This is the fixture search-page.xml, abridged:53

<response>
  <award>
    <id>1114898</id>
    <awardeeName>University of Arizona</awardeeName>
    <estimatedTotalAmt>1498027</estimatedTotalAmt>
    <activeAwd>false</activeAwd>
    <startDate>09/01/2011</startDate>
  </award>
  <metadata><offset>0</offset><rpp>25</rpp><totalCount>1</totalCount></metadata>
</response>

A raw record and its normalized form, abridged, with a placeholder person:

{
  "estimatedTotalAmt": "1498027",
  "activeAwd": "false",
  "publicAccessMandate": "0",
  "coPDPI": ["First M Last (Former) user@example.edu"],
  "piMiddeInitial": "W",
  "poEmail": ""
}
{
  "estimatedTotalAmt": 1498027,
  "activeAwd": false,
  "publicAccessMandate": false,
  "coPDPI": [{ "name": "First M Last", "email": "user@example.edu", "former": true }],
  "piMiddleInitial": "W",
  "hasOutcomesReport": false
}
  1. NSF API Integration and Live API behaviour notes in CLAUDE.md ↩ ↩2 ↩3 ↩4 ↩5 ↩6

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

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

  4. NSF API type definitions ↩ ↩2 ↩3 ↩4

  5. Trimmed real API responses used as test fixtures ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  6. Record normalization ↩

  7. User guide ↩

  8. Live tests of the NSF API client ↩

Sources

  1. NSF API Integration and Live API behaviour notes in CLAUDE.md api-behaviour
  2. NSF API client api-client
  3. NSF API type definitions api-types
  4. Record normalization normalize
  5. Live tests of the NSF API client live-api-tests
  6. Unit tests of the NSF API client client-tests
  7. Trimmed real API responses used as test fixtures fixtures
  8. User guide usage-guide