@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 thegetAmendments
method should result in hitting the/amendment/117
endpoint.
- For example, providing an object like
- 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