Get US federal spending by state, county or country
Returns how much the US federal government spent, by geography, for an industry, a product or service, or a topic. Data comes from USAspending.gov, the official US government source for federal spending. Narrow it with naics (industry), psc (product or service code) and keyword, or send none to see all spending. The window defaults to the most recent US federal fiscal year that ended at least 90 days ago (agencies report with a lag, so a year that just ended is only partly reported), and any window since 2007-10-01 is allowed. award_type is contracts by default, with grants and all available. geo picks the layer: state (USPS codes, with DC and territories), county (5 digit FIPS codes) or country (ISO alpha-3 codes, which is how foreign place of performance appears). scope chooses whether spending is placed where the work is done (place_of_performance, the default) or where the recipient is based (recipient_location). Amounts are US dollars of federal obligations recorded in the window. The response is data.regions[], sorted by amount, largest first, each { code, name, amount, population, per_capita } (the last two when the source publishes them), plus data.total_amount, data.geo_layer and a data.filters echo of what was applied. A combination with no spending returns 404 and is not billed.
Request
- Base URL: https://www.socialcrawl.dev/v1
- URL: https://www.socialcrawl.dev/v1/economy/government-spend
- Auth: API key in header x-api-key
Query parameters
Industry filter: one or more NAICS codes, comma-separated (up to 20). Each code must be 2, 4 or 6 digits, and a shorter code matches the whole family, so 4811 covers scheduled air transportation and 48 covers all transportation.
Product or service code filter: one or more codes, comma-separated (up to 20), 1 to 4 characters each. A shorter code matches the family, so V is all transportation, travel and relocation services and V301 is travel agent services.
Free-text match against award descriptions, 3 to 120 characters. Use it for a topic such as travel that no single industry code captures.
Start of the window, YYYY-MM-DD, no earlier than 2007-10-01. Defaults to the first day of the most recent US federal fiscal year (1 October to 30 September) that ended at least 90 days ago, because agencies report with a lag and a year that just ended is only partly reported. Send only this and the window runs to today.
End of the window, YYYY-MM-DD. Defaults to the last day of the most recent US federal fiscal year that ended at least 90 days ago (30 September). Send only this and the window starts one year earlier.
Geography layer: state (default), county or country.
place_of_performance (default) places spending where the work is done. recipient_location places it where the recipient is based.
contracts (default) is purchase orders, delivery orders, definitive contracts and blanket purchase agreement calls. grants is grants and cooperative agreements. all is every award type.
Headers
Send no-cache to bypass the response cache and force a live fetch. Billed at the normal endpoint cost; the fresh result is written back to cache for the next caller. Only the no-cache directive triggers this. See the Response Schema guide for details.
Optional UUID that makes the request safely retriable. The key is reserved atomically per account before billing. A concurrent retry receives 409 IDEMPOTENCY_IN_PROGRESS with a Retry-After of 1 second while the original is young, growing to a quarter of the time it has been running (at most 30); a crashed reservation expires after 5 minutes. A replay keeps the cached payload immutable except for billing metadata: credits_used becomes 0, idempotent_replay becomes true, and credits_remaining is refreshed to the current balance. A known current balance appears in both the body and X-Credits-Remaining header; no balance row resolves to 0. On a transient lookup failure, body credits_remaining is null and X-Credits-Remaining is omitted. Completed outcomes expire after 24 hours. If the claim store is unavailable, the request fails closed before billing. GET endpoints do not combine idempotent replay with Server-Sent Events: use Accept: application/json when sending this header. The unsupported key-plus-SSE combination is rejected before billing.
Response
Successful response
Example response
{
"success": true,
"platform": "economy",
"endpoint": "/v1/economy/government-spend",
"credits_used": 1,
"credits_remaining": 4999,
"request_id": "req-abc123",
"idempotent_replay": true,
"meta": {
"hint": {
"code": "search_multi",
"message": "You searched \"matcha\" on 3 platforms one call at a time; /v1/search/multi returns each platform's own search rows in one call at the same price per platform, and a platform with no rows is not charged.",
"method": "GET",
"path": "/v1/search/multi?query=matcha&platforms=instagram,tiktok,youtube"
}
}
}Changes
No recorded changes to this operation across all 1 revision of this API.