5 个版本

0.1.4 2023年9月26日
0.1.3 2022年4月15日
0.1.2 2022年1月12日
0.1.1 2022年1月3日
0.1.0 2021年12月23日

#21 in #strongly-typed

MIT/Apache

43KB
1K SLoC

Legiscan

Legiscan REST API 的强类型客户端

文档

https://docs.rs/legiscan/latest/legiscan/

快速开始

要开始,您需要在程序中实例化一个 LegiscanProxy。您有两种选择

use legiscan::LegiscanProxy
// If you have a `LEGISCAN_API_KEY` set in your .env or environment
let proxy = LegiscanProxy::new().unwrap();
// If you want to pass in the API key from elsewhere
let proxy = LegiscanProxy::new_from_key(your_api_key);

一旦您实例化了代理,就可以轻松查询 Legiscan 的 API。所有响应都使用 serde 和 serde_json 强类型,因此您将轻松访问 Legiscan 响应中所有嵌套字段。以下是一个快速示例

let bill_id = 1167968 // From the Legiscan docs
let bill = proxy.get_bill(bill_id).await.unwrap();
println!("{}", bill.state) // "MD"
println!("{}", bill.bill_number) // "SB181"

依赖项

~6–21MB
~330K SLoC