Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catherinedevlin/aa510ed9020431d2cbb9cc4045fa5835 to your computer and use it in GitHub Desktop.
Save catherinedevlin/aa510ed9020431d2cbb9cc4045fa5835 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_class": [
	    {
	      "major_object_class": 10,  # Personnel compensation and benefits
	      "object_class": [111, 113, ...]  # Full-time permanent, Other than full-time permanent, ...
	    },
	    {
	      "major_object_class": 90  # Other

	    }
	    ],
	    "program_activiy": [1, 2, 3],
	    "time_period": [
		{
			"start_date": "2001-01-01",
			"end_date": "2001-01-31"
		}
	    ]
	}
}

Response (JSON)

{
    "results": 
        {
	"Office of the Secretary": 110,
	"Office of Advocacy and Outreach": 10, 
	"Departmental Administration": 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