Skip to content

Instantly share code, notes, and snippets.

@russellbodine
Last active December 27, 2017 21:00
Show Gist options
  • Save russellbodine/32fa2992265c1e79c9975f419fd97492 to your computer and use it in GitHub Desktop.
Save russellbodine/32fa2992265c1e79c9975f419fd97492 to your computer and use it in GitHub Desktop.

Federal Account Spending By Award Count

Route: /api/v2/federal_accounts/<PK>/spending_by_award_count/

Method: GET

This route takes a federal_account DB ID and returns the data reqired to visualized the Award Count values.

Request

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

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

Request

{
	"time_period": "year"
	"filters": {
	    "object_classes": [
	    {
	      "major_object_class_name": "Personnel compensation and benefits",
	      "object_class_names": ["Full-time permanent", "Other than full-time permanent", ...]
	    },
	    {
	      "major_object_class_name": "Other"
	    }
	    ],
	    "program_activites": [1, 2, 3],
	    "time_period": [
		{
			"start_date": "2001-01-01",
			"end_date": "2001-01-31"
		}
	    ]
	}
}

Response (JSON)

{
    "results": 
        {"contracts": 0, "grants": 0, "direct_payments": 0, "loans": 0, "other": 0}
    

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