1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//! # Tango — Rust SDK for the Tango federal-contracting API
//!
//! The Tango API gives programmatic access to federal-contracting data —
//! contracts, IDVs, entities, opportunities, grants, vehicles, protests, and
//! more — with dynamic response shaping so callers fetch only the fields they
//! need.
//!
//! This crate is the official, async-first Rust SDK. It mirrors the surface of
//! the [Node](https://github.com/makegov/tango-node),
//! [Python](https://github.com/makegov/tango-python), and
//! [Go](https://github.com/makegov/tango-go) SDKs while leaning into Rust
//! idioms (async streams, typed errors, compile-time-checked builders).
//!
//! ## Quick start
//!
//! ```no_run
//! use tango::Client;
//!
//! # async fn run() -> tango::Result<()> {
//! let client = Client::builder().api_key("your-api-key").build()?;
//!
//! let page = client
//! .list_contracts(
//! tango::ListContractsOptions::builder()
//! .awarding_agency("9700")
//! .shape(tango::SHAPE_CONTRACTS_MINIMAL)
//! .limit(25u32)
//! .build(),
//! )
//! .await?;
//!
//! for record in page.results {
//! println!("{:?}", record.get("piid"));
//! }
//! # Ok(()) }
//! ```
//!
//! Or walk every page with the async stream API:
//!
//! ```no_run
//! # use tango::Client;
//! use futures::TryStreamExt;
//! # async fn run() -> tango::Result<()> {
//! # let client = Client::builder().api_key("x").build()?;
//! let mut stream = client.iterate_contracts(
//! tango::ListContractsOptions::builder()
//! .awarding_agency("9700")
//! .build(),
//! );
//! while let Some(record) = stream.try_next().await? {
//! // process one contract at a time
//! let _ = record;
//! }
//! # Ok(()) }
//! ```
//!
//! ## Authentication
//!
//! Pass an API key via `Client::builder().api_key(...)`, or set
//! `TANGO_API_KEY` in the environment and call [`Client::from_env`].
//!
//! ## Error handling
//!
//! Every fallible call returns [`Result<T, Error>`]. Match on the variant to
//! dispatch on the failure mode:
//!
//! ```no_run
//! # use tango::{Client, Error};
//! # async fn run() -> tango::Result<()> {
//! # let client = Client::builder().api_key("x").build()?;
//! match client.get_agency("9700", None).await {
//! Ok(agency) => println!("{}", agency.name.unwrap_or_default()),
//! Err(Error::NotFound { .. }) => println!("not found"),
//! Err(Error::RateLimit { retry_after, .. }) => println!("retry in {retry_after}s"),
//! Err(e) => return Err(e),
//! }
//! # Ok(()) }
//! ```
//!
//! ## Response shaping
//!
//! List endpoints accept a `shape` parameter that picks which fields the API
//! returns. The SDK exposes ready-made presets — e.g.
//! [`SHAPE_CONTRACTS_MINIMAL`] — and you can also pass a custom field list.
//! See the [`shapes`] module.
//!
//! ## Webhook signing
//!
//! Webhook delivery verification is in the separate [`makegov-tango-webhooks`]
//! crate so a verifier service doesn't have to pull in the full SDK. See
//! `<https://docs.rs/makegov-tango-webhooks>` for HMAC-SHA256 signing and
//! verification.
//!
//! [`makegov-tango-webhooks`]: https://docs.rs/makegov-tango-webhooks
// Internal helpers used by Phase 2 resource modules. Suppressed for now so
// foundation work compiles cleanly before Wave-2 agents fill in the surface.
// ---------- Public surface ----------
pub use ;
pub use ;
pub use ListOptions;
pub use ;
pub use ;
pub use RateLimitInfo;
pub use VERSION;
// Re-export the resource option types so callers can `use tango::Foo;`
// without diving into module paths.
pub use *;
/// A free-form list result record. Used as the `T` for shape-driven list
/// endpoints whose response schema depends on the requested `shape`.
///
/// `Record` is just a [`serde_json::Map`]. Use `record.get("field_name")` to
/// pull a field, or `serde_json::from_value(Value::Object(record))` to
/// deserialize into your own typed struct.
pub type Record = Map;