Expand description
§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, Python, and Go SDKs while leaning into Rust idioms (async streams, typed errors, compile-time-checked builders).
§Quick start
use tango::Client;
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"));
}Or walk every page with the async stream API:
use futures::TryStreamExt;
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;
}§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:
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),
}§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.
Re-exports§
pub use shapes::DEFAULT_BASE_URL;pub use shapes::SHAPE_CONTRACTS_MINIMAL;pub use shapes::SHAPE_ENTITIES_COMPREHENSIVE;pub use shapes::SHAPE_ENTITIES_MINIMAL;pub use shapes::SHAPE_FORECASTS_MINIMAL;pub use shapes::SHAPE_GRANTS_MINIMAL;pub use shapes::SHAPE_GSA_ELIBRARY_CONTRACTS_MINIMAL;pub use shapes::SHAPE_IDVS_COMPREHENSIVE;pub use shapes::SHAPE_IDVS_MINIMAL;pub use shapes::SHAPE_ITDASHBOARD_INVESTMENTS_COMPREHENSIVE;pub use shapes::SHAPE_ITDASHBOARD_INVESTMENTS_MINIMAL;pub use shapes::SHAPE_NOTICES_MINIMAL;pub use shapes::SHAPE_OPPORTUNITIES_MINIMAL;pub use shapes::SHAPE_ORGANIZATIONS_MINIMAL;pub use shapes::SHAPE_OTAS_MINIMAL;pub use shapes::SHAPE_OTIDVS_MINIMAL;pub use shapes::SHAPE_PROTESTS_MINIMAL;pub use shapes::SHAPE_SUBAWARDS_MINIMAL;pub use shapes::SHAPE_VEHICLES_COMPREHENSIVE;pub use shapes::SHAPE_VEHICLES_MINIMAL;pub use shapes::SHAPE_VEHICLE_AWARDEES_MINIMAL;pub use shapes::SHAPE_VEHICLE_ORDERS_MINIMAL;
Modules§
- models
- Typed response and input models for fixed-schema Tango endpoints.
- shapes
- Shape presets for the Tango API’s dynamic response-shaping feature.
Structs§
- Agency
Contracts Options - Options for the agency contract sub-resources
(
list_agency_awarding_contracts/list_agency_funding_contracts). - Client
- The Tango API client. Cheap to clone — all state is behind an
Arc. - Entity
Subresource Options - Options shared by every entity sub-resource list endpoint
(
/api/entities/{uei}/contracts/,/idvs/,/otas/,/otidvs/,/subawards/,/lcats/). - Error
Body - A parsed Tango API error body. Carried on the API-error variants so callers can introspect the server’s structured error response without re-parsing.
- GetAgency
Options - Per-agency get options.
- GetEntity
Options - Options for
Client::get_entity. - GetGsa
Elibrary Contract Options - Options for
Client::get_gsa_elibrary_contract. - GetIDV
Options - Options for
Client::get_idv. - GetItdashboard
Options - Options for
Client::get_itdashboard. - GetOTA
Options - Options for
Client::get_ota. - GetOTIDV
Options - Options for
Client::get_otidv. - GetProtest
Options - Options for
Client::get_protest. The detail endpoint returns a typedProtestRecord;shapelets callers override the server’s default. - GetVehicle
Options - Options for
Client::get_vehicle. Mirrors the Go SDK’sGetEntityOptionsfor the vehicle detail endpoint. - IdvSubresource
Options - Options shared by every IDV sub-resource list endpoint
(
/api/idvs/{key}/awards/,/child-idvs/,/transactions/,/summary/awards/,/lcats/). - List
Agencies Options - Options for
Client::list_agencies. - List
ApiKeys Options - Options for
Client::list_api_keys. - List
Assistance Listings Options - Options for
Client::list_assistance_listings/Client::iterate_assistance_listings. - List
Business Types Options - Options for
Client::list_business_types/Client::iterate_business_types. - List
Contracts Options - Options for
Client::list_contractsandClient::iterate_contracts. - List
Departments Options - Options for
Client::list_departments/Client::iterate_departments. - List
Entities Options - Options for
Client::list_entitiesandClient::iterate_entities. - List
Forecasts Options - Options for
Client::list_forecastsandClient::iterate_forecasts. MirrorsListForecastsOptionsin the Go SDK. - List
Grants Options - Options for
Client::list_grantsandClient::iterate_grants. MirrorsListGrantsOptionsin the Go SDK. - List
GsaElibrary Contracts Options - Options for
Client::list_gsa_elibrary_contractsandClient::iterate_gsa_elibrary_contracts. - ListID
VsOptions - Options for
Client::list_idvsandClient::iterate_idvs. - List
Itdashboard Options - Options for
Client::list_itdashboardandClient::iterate_itdashboard. - List
Lcats Options - Options for
Client::list_lcatsandClient::iterate_lcats. - List
MasSins Options - Options for
Client::list_mas_sins/Client::iterate_mas_sins. - List
Metrics Options - Options for the
Client::list_metricsdispatcher. - List
Naics Options - Options for
Client::list_naics/Client::iterate_naics. - List
Notices Options - Options for
Client::list_noticesandClient::iterate_notices. MirrorsListNoticesOptionsin the Go SDK. The server rejects every?ordering=value on this endpoint, so the field is intentionally omitted. - ListOT
AsOptions - Options for
Client::list_otasandClient::iterate_otas. - ListOTIDV
Awards Options - Options for
Client::list_otidv_awardsandClient::iterate_otidv_awards. - ListOTID
VsOptions - Options for
Client::list_otidvsandClient::iterate_otidvs. - List
Offices Options - Options for
Client::list_offices/Client::iterate_offices. - List
Opportunities Options - Options for
Client::list_opportunitiesandClient::iterate_opportunities. MirrorsListOpportunitiesOptionsin the Go SDK. - List
Options - Pagination, shape, and flattening options common to every list endpoint.
- List
Organizations Options - Options for
Client::list_organizations/Client::iterate_organizations. - List
Protests Options - Options for
Client::list_protestsandClient::iterate_protests. - List
PscOptions - Options for
Client::list_psc/Client::iterate_psc. - List
Subawards Options - Options for
Client::list_subawardsandClient::iterate_subawards. - List
Vehicle Awardees Options - Options for
Client::list_vehicle_awardeesandClient::iterate_vehicle_awardees. The endpoint only accepts the shared pagination + shaping fields. - List
Vehicle Orders Options - Options for
Client::list_vehicle_ordersandClient::iterate_vehicle_orders. The endpoint only accepts the shared pagination + shaping fields. - List
Vehicles Options - Options for
Client::list_vehiclesandClient::iterate_vehicles. - Page
- A single page of results from a list endpoint.
- Page
Stream - An async stream over every result of a paginated list endpoint.
- Rate
Limit Info - A snapshot of the rate-limit headers from the most recent response.
- Search
Opportunity Attachments Options - Options for
Client::search_opportunity_attachments— semantic search over the extracted text of opportunity attachments (SOWs, PWSs, J&As).
Enums§
- Error
- The error type returned by all fallible SDK calls.
Constants§
- DEFAULT_
RETRIES - Default retry count when none is set.
- DEFAULT_
RETRY_ BACKOFF - Default initial retry backoff (doubles each attempt up to 10s) when none is set.
- DEFAULT_
TIMEOUT - Default per-request timeout when none is set.
- METRICS_
OWNER_ ENTITY - Owner-type discriminant for
ListMetricsOptions::owner_type. - METRICS_
OWNER_ NAICS - Owner-type discriminant for
ListMetricsOptions::owner_type. - METRICS_
OWNER_ PSC - Owner-type discriminant for
ListMetricsOptions::owner_type. - VERSION
- The current SDK version. Kept in sync with
Cargo.tomland theCHANGELOG.
Type Aliases§
- List
Agency Awarding Contracts Options - Alias matching the plan’s
R-01naming — same asAgencyContractsOptions. - List
Agency Funding Contracts Options - Alias matching the plan’s
R-01naming — same asAgencyContractsOptions. - Record
- A free-form list result record. Used as the
Tfor shape-driven list endpoints whose response schema depends on the requestedshape. - Result
- Alias for the SDK’s standard
Resulttype.