#api-bindings #api #congress-gov

congressdotgov_rs

congress.gov API bindings

4 releases

new 0.2.2 Jan 10, 2025
0.2.1 Jan 9, 2025
0.2.0 Jan 9, 2025
0.1.0 Jan 4, 2025

#341 in Web programming

Download history 273/week @ 2025-01-04

273 downloads per month

MIT/Apache

250KB
7.5K SLoC

congressdotgov_rs

Rust bindings to the congress.gov REST API. Inspired by Designing Rust bindings for REST APIs.

These are unofficial bindings and are not affiliated with congress.gov

Example

use serde::Deserialize;                                                                    
use congressdotgov_rs::Cdg;                                                                
use congressdotgov_rs::api::Query;                                                         
use congressdotgov_rs::api::bill;                                                          
use congressdotgov_rs::Auth;                                                               
use tokio_test::block_on;                                                                  
                                                                                           
// The return type of a `Bill`. Note that a Bill may contain more information, but you can 
// define your structure to only deserialize what is needed as the return value is a       
// serde_json::Value.                                                                      
#[derive(Debug, Deserialize)]                                                              
struct Bill {                                                                              
    title: String,                                                                         
}                                                                                          
                                                                                           
// Create the client.                                                                      
let auth = Auth::Token("API_KEY".into());                                                  
let client = Cdg::new(auth).unwrap();                                                      
                                                                                           
// Create a simple endpoint. This one gets recent Bills from the 118th Congress.           
let endpoint = bill::Congress::builder().congress(118_u8).build().unwrap();                
                                                                                           
// Call the endpoint. The return type decides how to represent the value.                  
# tokio_test::block_on(async {                                                             
  let bills: Vec<Bill> = endpoint.query(&client).await.unwrap();                             
# })

Coverage

All resources, endpoints, and their respective query parameters are covered by these bindings. Many parameters are defined by Rust types, and the library strives to be idiomatic.

These resources are:

  • bill
  • amendments
  • summaries
  • congress
  • member
  • committee
  • committee-report
  • committee-print
  • committee-meeting
  • hearing
  • congressional-record
  • daily-congressional-record
  • bound-congressional-record
  • house-communication
  • house-requirement
  • senate-communication
  • nomination
  • treaty

Motivation

These bindings were created to make it easier to query the congress.gov API from Rust web servers for use in NLP and related tasks. I hope others may also find them useful.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in congressdotgov_rs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~6–17MB
~226K SLoC