@4lch4/lib-congress
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

code style: prettier Discord NPM NPM Bundle Size npm (scoped) Build Status

ForTheBadge

@4lch4/Lib-Congress

This package is a wrapper library, written in TypeScript, that enables users to interact with the US Congress API and retrieve the data it makes available.

Architecture

For notes on the architecture/structure of this package/library, please refer to the Architecture.md file.

Testing

In order to verify functionality of the library I built a suite of tests that verify each possible endpoint meets the following requirements:

  • Providing no parameters gets the root endpoint.
  • Providing each of the parameters results in the correct endpoint being called.
    • For example, providing an object like { congress: 117 } to the getAmendments method should result in hitting the /amendment/117 endpoint.
  • Executing a method returns the expected type of object.

For further details, refer to the Testing file.

Usage

To use the library you only need to import the CongressAPI class and call whichever function you wish. For example, to retrieve amendments you can do the following:

import { CongressAPI } from '@4lch4/lib-congress'

const congress = new CongressAPI({
  apiKey: 'pxPXweYA8wObIqUERnVRf2v6d84uOxjJ5MpJ8kgO',
  responseFormat: 'json' as ResponseFormat,
  baseUrl: 'https://api.congress.gov/v3',
  trimmedResponses: true,
  dataDir: 'data',
  debug: false
})

congress
  .getAmendments()
  .then(amendments => {
    console.log(`${amendments.data.length} amendments retrieved...`)
    console.log('Execution completed successfully!')
  })
  .catch(err => {
    console.error('Error received from CongressAPI#getAmendments...')
    console.error(err)
  })

Export Functions

The following is a list of all the functions/methods that are exported by the CongressAPI class:

  • getAmendments
  • getBills
  • getSummaries
  • getCongress
  • getMembers
  • getCommittees
  • getCommitteeReports
  • getCongressionalRecord
  • getHouseCommunications
  • getNominations
  • getTreaties

TODO

  • [ ] Finish implementing remaining endpoints.
    • [x] Bills
    • [ ] Amendments
    • [ ] Committee
    • [ ] Committee Report
    • [ ] Congress
    • [ ] Congressional Record
    • [ ] House Communication
    • [ ] Member
    • [ ] Nomination
    • [ ] Summaries
    • [ ] Treaty

Package Sidebar

Install

npm i @4lch4/lib-congress

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

2.14 MB

Total Files

469

Last publish

Collaborators

  • alcha
  • 4lch4-ci