Skip to content

Instantly share code, notes, and snippets.

@russellbodine
Last active August 31, 2017 16:14
Show Gist options
  • Select an option

  • Save russellbodine/2b3e00d8ec1223cfeb91e73e9b7cc1fd to your computer and use it in GitHub Desktop.

Select an option

Save russellbodine/2b3e00d8ec1223cfeb91e73e9b7cc1fd to your computer and use it in GitHub Desktop.

Spending By Geography

Route: /api/v2/search/spending_by_geography/

Method: POST

This route takes award filters, and returns spending by state code.

Request

scope: Scope defines what location is used for filtering the aggregated_amount.

filter: how the awards are filtered. The filter object is defined here.

https://gist.github.com/nmonga91/ba0e172b6d3f2aaf50f0ef1bb5d708bc#recipient-location

{
	"scope": "place_of_performance",
	"filters": {
	    "award_type_codes": ["A", "B", "03"],
	    "award_ids": [1, 2, 3],
	    "award_amounts": [
		      {
			"lower_bound": 1000000.00,
			"upper_bound": 25000000.00
		      },
		      {
			"upper_bound": 1000000.00
		      },
		      {
			"lower_bound": 500000000.00
		      }
    	     ]
	}
}

Response (JSON)

{
    "scope": "place_of_performance",
    "results": [
        {
            "state_code": "MN",
            "aggregated_amount": 0
        },
        {
            "state_code": "WA",
            "aggregated_amount": -0.02
        },
        {
            "state_code": "LA",
            "aggregated_amount": 0
        },
        {
            "state_code": "MD",
            "aggregated_amount": 675909.94
        },
        {
            "state_code": "DC",
            "aggregated_amount": 6393118.28
        },
        {
            "state_code": "VA",
            "aggregated_amount": 73700
        }
    ]
}

Errors

Possible HTTP Status Codes:

  • 400 : Missing parameters or limit is not a valid, positive integer
  • 500 : All other errors
{
  "detail": "Sample error message"
}

Other Search Filters

https://github.com/fedspendingtransparency/usaspending-website/wiki/Award-Search-Visualizations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment