JSPM

@devhsoj/unclesam

0.0.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 19
    • Score
      100M100P100Q41644F
    • License MIT

    Unofficial API for sam.gov

    Package Exports

    • @devhsoj/unclesam
    • @devhsoj/unclesam/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@devhsoj/unclesam) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    unclesam

    unclesam is an unofficial TypeScript API built for querying sam.gov. This package allows you to quickly & easily retrieve government contracts via a modern, typed API.

    How to install

    Requirements: node/npm

    cd my_project/
    npm i @devhsoj/unclesam

    Examples

    Querying active contracts matching all words

    import { ContractSearch, ContractQueryMode } from 'unclesam';
    
    (async () => {
        const search = new ContractSearch({
            query: ['software', 'network'],
            queryMode: ContractQueryMode.ALL,
            pageSize: 1000,
            active: true
        });
    
        // .list() goes through each page recursively (in this case, 1000 records at a time) and returns all contracts
        const contracts = await search.list();
    
        console.log(contracts); // [{ title: 'Example Title', ... }]
    })();

    Explicitly retrieve the ten most recently modified contract opportunities containing the word 'defense'

    import { ContractSearch, ContractQueryMode, ContractQueryIndex, ContractSearchSortOptions } from 'unclesam';
    
    (async () => {
        // Using the static class method .search() on ContractSearch, allows you to directly search contracts
        const res = await ContractSearch.search({
            page: 0,
            pageSize: 10,
            query: 'defense',
            active: true,
            queryMode: ContractQueryMode.EXACT,
            index: ContractQueryIndex.Opportunities,
            sort: ContractSearchSortOptions.dateModifiedDesc
        });
    
        // If there is an error on the sam.gov API, output the error
        if (res.error) {
            console.trace(res.error);
        } else {
            if (!res.contracts || res.contracts?.length === 0) {
                console.log('No contracts found!');
            } else {
                console.log(res.contracts);
            }
        }
    })();

    About

    This project was created to get more of an understanding of creating a library in TypeScript :)

    Plus I like reverse-engineering APIs