The SAM.gov Opportunities API returns deeply nested JSON with inconsistent field names (responseDeadLine vs postedDate), optional fields everywhere, and zero TypeScript support. This package gives you full type safety for every endpoint.
npm install sam-gov-typesimport type {
SamOpportunity,
SamSearchParams,
SamSearchResponse,
OrganizationHierarchy,
PointOfContact,
PlaceOfPerformance,
Award,
} from 'sam-gov-types';
// Type-safe API call
async function searchSam(params: SamSearchParams): Promise<SamSearchResponse> {
const qs = new URLSearchParams(params as Record<string, string>);
const res = await fetch(`https://api.sam.gov/opportunities/v2/search?${qs}`);
return res.json();
}
// Full autocomplete on opportunity fields
const opp: SamOpportunity = await getOpportunity('some-id');
console.log(opp.title); // string
console.log(opp.organizationHierarchy.l1Name); // string — agency
console.log(opp.pointOfContact[0].email); // string
console.log(opp.placeOfPerformance?.city?.name); // string | undefined| Endpoint | Types |
|---|---|
GET /opportunities/v2/search |
SamSearchParams, SamSearchResponse |
| Opportunity object | SamOpportunity |
| Organization | OrganizationHierarchy |
| Contact | PointOfContact |
| Location | PlaceOfPerformance |
| Award | Award |
| Links | SamLink |
| Notice types | SamNoticeType (union) |
| Set-aside types | SamSetAside (union) |
See src/index.ts for all exported types with JSDoc comments.
MIT — AliceLabs LLC