open_secrets

Crates.ioopen_secrets
lib.rsopen_secrets
version0.1.4
sourcesrc
created_at2021-12-31 19:26:31.739297
updated_at2023-10-23 06:31:36.761254
descriptionA client wrapper for the Open Secrets REST API
homepagehttps://github.com/populist-vote/open-secrets
repositoryhttps://github.com/populist-vote/open-secrets
max_upload_size
id505901
size18,699
Wiley McKay Conte (wileybaba)

documentation

https://docs.rs/open-secrets

README

Open Secrets

A wrapper for the OpenSecrets REST API

Docs

https://docs.rs/legiscan/latest/open-secrets/

Quick Start

To get started, you'll need to instantiate a OpenSecretsProxy in your program. You have two options:

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

If you, for some strange reason, want your response output as something besides JSON, you can adjust the output type like so:

use open_secrets::OutputType::Doc;
proxy.with_output(Doc);

Now you're ready to make some calls to OpenSecrets.

// Lets get Nancy Pelosi's summary
let response = proxy.cand_summary("N00007360", None).await.unwrap();
let json: serde_json::Value = response.json().await.unwrap();
assert_eq!(
        json["response"]["summary"]["@attributes"]["cand_name"],
        "Pelosi, Nancy"
    );
Commit count: 11

cargo fmt