Skip to content

alicelabs-llc/sam-gov-types

Repository files navigation

sam-gov-types

TypeScript type definitions for the SAM.gov Public API

npm TypeScript License: MIT

Built by AliceLabs LLC


Why

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.

Install

npm install sam-gov-types

Usage

import 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

Covered endpoints

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)

API reference

See src/index.ts for all exported types with JSDoc comments.

License

MIT — AliceLabs LLC

About

TypeScript type definitions for the SAM.gov Public Opportunities API

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors