Metrics¶
Metrics endpoints return time-series obligation and award counts for a specific entity, NAICS code, or PSC code. They share the same URL pattern and query parameters, so this page describes behavior once, then lists the available endpoints.
How metrics work¶
Each metrics endpoint is:
GET /api/{resource}/{id}/metrics/<months>/<period_grouping>/
- Path parameters (required):
{id}— The resource identifier (entity UEI, NAICS code, or PSC code).months— Lookback window in months (positive integer). Example:24for the last 24 months.-
period_grouping— How to bucket time:year,quarter, ormonth. -
Query parameters (optional):
group_by— Comma-separated list of dimensions to break out:agency,department. When used, each result row includes the grouped dimension(s). Rolling averages are not supported when grouping; if both are used, rolling is skipped and awarningis returned.fiscal_year— Iftrueor1, buckets use federal fiscal year (Oct–Sep). Default is calendar year.rolling— Iftrueor1, adds a rolling average to each result (when not usinggroup_by).
Response shape (same for all three):
count— Number of result rows.description— Human-readable description of the time range and grouping.warning— Present only when e.g. rolling was requested withgroup_by(rolling skipped).- The resource object —
recipient(entity),naics_code, orpsc_code(the one you queried). results— Array of objects. Each has:year(and optionallymonth,quarterdepending onperiod_grouping),awards,subawards(obligation/count values),rolling_avg(ifrolling=trueand nogroup_by),department,agency(ifgroup_byincludes them).
Invalid period_grouping, non-positive months, or invalid group_by values return HTTP 400 with an error message.
Available endpoints¶
| Resource | Endpoint | Identifier |
|---|---|---|
| Entity | GET /api/entities/{uei}/metrics/<months>/<period_grouping>/ | Entity UEI. See Entities. |
| NAICS | GET /api/naics/{code}/metrics/<months>/<period_grouping>/ | NAICS code. See NAICS. |
| PSC | GET /api/psc/{code}/metrics/<months>/<period_grouping>/ | PSC code. See PSC. |
All three support the same optional query parameters: group_by, fiscal_year, rolling.
Example¶
Entity obligations for the last 12 months, by month, with rolling average:
NAICS code 541512 for the last 24 months by quarter, grouped by department:
SDK¶
The official SDKs don’t yet expose first-class methods for metrics. Use the HTTP helper with the paths above:
import { TangoClient } from "@makegov/tango-node";
const client = new TangoClient({ apiKey: process.env.TANGO_API_KEY });
const http = (client as any).http;
const data = await http.get("/api/entities/ABC123DEF456/metrics/12/month/", {
rolling: "true",
});
console.log("count:", data.count, "results:", data.results?.length ?? 0);