Skip to main content

Crate tango

Crate tango 

Source
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§

AgencyContractsOptions
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.
EntitySubresourceOptions
Options shared by every entity sub-resource list endpoint (/api/entities/{uei}/contracts/, /idvs/, /otas/, /otidvs/, /subawards/, /lcats/).
ErrorBody
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.
GetAgencyOptions
Per-agency get options.
GetEntityOptions
Options for Client::get_entity.
GetGsaElibraryContractOptions
Options for Client::get_gsa_elibrary_contract.
GetIDVOptions
Options for Client::get_idv.
GetItdashboardOptions
Options for Client::get_itdashboard.
GetOTAOptions
Options for Client::get_ota.
GetOTIDVOptions
Options for Client::get_otidv.
GetProtestOptions
Options for Client::get_protest. The detail endpoint returns a typed ProtestRecord; shape lets callers override the server’s default.
GetVehicleOptions
Options for Client::get_vehicle. Mirrors the Go SDK’s GetEntityOptions for the vehicle detail endpoint.
IdvSubresourceOptions
Options shared by every IDV sub-resource list endpoint (/api/idvs/{key}/awards/, /child-idvs/, /transactions/, /summary/awards/, /lcats/).
ListAgenciesOptions
Options for Client::list_agencies.
ListApiKeysOptions
Options for Client::list_api_keys.
ListAssistanceListingsOptions
Options for Client::list_assistance_listings / Client::iterate_assistance_listings.
ListBusinessTypesOptions
Options for Client::list_business_types / Client::iterate_business_types.
ListContractsOptions
Options for Client::list_contracts and Client::iterate_contracts.
ListDepartmentsOptions
Options for Client::list_departments / Client::iterate_departments.
ListEntitiesOptions
Options for Client::list_entities and Client::iterate_entities.
ListForecastsOptions
Options for Client::list_forecasts and Client::iterate_forecasts. Mirrors ListForecastsOptions in the Go SDK.
ListGrantsOptions
Options for Client::list_grants and Client::iterate_grants. Mirrors ListGrantsOptions in the Go SDK.
ListGsaElibraryContractsOptions
Options for Client::list_gsa_elibrary_contracts and Client::iterate_gsa_elibrary_contracts.
ListIDVsOptions
Options for Client::list_idvs and Client::iterate_idvs.
ListItdashboardOptions
Options for Client::list_itdashboard and Client::iterate_itdashboard.
ListLcatsOptions
Options for Client::list_lcats and Client::iterate_lcats.
ListMasSinsOptions
Options for Client::list_mas_sins / Client::iterate_mas_sins.
ListMetricsOptions
Options for the Client::list_metrics dispatcher.
ListNaicsOptions
Options for Client::list_naics / Client::iterate_naics.
ListNoticesOptions
Options for Client::list_notices and Client::iterate_notices. Mirrors ListNoticesOptions in the Go SDK. The server rejects every ?ordering= value on this endpoint, so the field is intentionally omitted.
ListOTAsOptions
Options for Client::list_otas and Client::iterate_otas.
ListOTIDVAwardsOptions
Options for Client::list_otidv_awards and Client::iterate_otidv_awards.
ListOTIDVsOptions
Options for Client::list_otidvs and Client::iterate_otidvs.
ListOfficesOptions
Options for Client::list_offices / Client::iterate_offices.
ListOpportunitiesOptions
Options for Client::list_opportunities and Client::iterate_opportunities. Mirrors ListOpportunitiesOptions in the Go SDK.
ListOptions
Pagination, shape, and flattening options common to every list endpoint.
ListOrganizationsOptions
Options for Client::list_organizations / Client::iterate_organizations.
ListProtestsOptions
Options for Client::list_protests and Client::iterate_protests.
ListPscOptions
Options for Client::list_psc / Client::iterate_psc.
ListSubawardsOptions
Options for Client::list_subawards and Client::iterate_subawards.
ListVehicleAwardeesOptions
Options for Client::list_vehicle_awardees and Client::iterate_vehicle_awardees. The endpoint only accepts the shared pagination + shaping fields.
ListVehicleOrdersOptions
Options for Client::list_vehicle_orders and Client::iterate_vehicle_orders. The endpoint only accepts the shared pagination + shaping fields.
ListVehiclesOptions
Options for Client::list_vehicles and Client::iterate_vehicles.
Page
A single page of results from a list endpoint.
PageStream
An async stream over every result of a paginated list endpoint.
RateLimitInfo
A snapshot of the rate-limit headers from the most recent response.
SearchOpportunityAttachmentsOptions
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.toml and the CHANGELOG.

Type Aliases§

ListAgencyAwardingContractsOptions
Alias matching the plan’s R-01 naming — same as AgencyContractsOptions.
ListAgencyFundingContractsOptions
Alias matching the plan’s R-01 naming — same as AgencyContractsOptions.
Record
A free-form list result record. Used as the T for shape-driven list endpoints whose response schema depends on the requested shape.
Result
Alias for the SDK’s standard Result type.