Skip to content

Instantly share code, notes, and snippets.

@russellbodine
Last active January 2, 2018 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save russellbodine/c8d44deee75fe43d3aed7f6c9be7fc99 to your computer and use it in GitHub Desktop.
Save russellbodine/c8d44deee75fe43d3aed7f6c9be7fc99 to your computer and use it in GitHub Desktop.

Federal Account Spending By Category

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

Method: POST

This route takes a federal_account DB ID and returns the data reqired to visualized the Spending By Category graphic.

Request

{
	"category": "program_activity"
	"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": 
        [
	"Program Activity 1": 110,
	"Program Activity 2": 10, 
	"Program Activity 3": 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