Skip to content

Instantly share code, notes, and snippets.

@catherinedevlin
Last active July 7, 2017 18:52
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/a65347b8526f44ce6d2ece5607f80902 to your computer and use it in GitHub Desktop.
Save catherinedevlin/a65347b8526f44ce6d2ece5607f80902 to your computer and use it in GitHub Desktop.
Endpoint description for /api/v2/budget_authority/agencies/<agency_identifier>/

Retrieve Historical Budget Authority data by agency identifier

Route: /api/v2/budget_authority/agencies/<agency_identifier>/

Method: GET

This route retrieves a record of historical budget authority, by year, summed over an agency, as identified by the agency identifier (or CGAC) and, optionally, over FR entity code (FREC).

Request example

/api/v2/budget_authority/agencies/011/?frec=1137

Request Parameters Description

  • agency_identifier - required - sum over this agency (CGAC)

  • frec - optional - FR Entity Code, optionally used to distinguish between agencies that share a CGAC

  • sort - optional - Field to sort results on, either year or total. Defaults to year

  • order - optional - Whether to sort results in asc (ascending) or desc (descending) order. Defaults to asc

Response (JSON)

{
    "page_metadata": {
        "count": 47,
        "page": 1,
        "has_next_page": false,
        "has_previous_page": false,
        "next": null,
        "current": "http://localhost:8000/api/v2/budget_authority/agencies/011/?frec=1137&limit=100&page=1&req=eaa575e8995",
        "previous": null
    },
    "req": "eaa575e8995",
    "results": [
        {
            "year": 1976,
            "total": 14559486000
        },
        {
            "year": 1977,
            "total": 10757814000
        },
        {
            "year": 1978,
            "total": 12027009000
        },
        {
            "year": 1979,
            "total": 8890948000
        },
        {
            "year": 1980,
            "total": 14701004000
        },
        {
            "year": 1981,
            "total": 16053708000
        },
        {
            "year": 1982,
            "total": 17027929000
        },
        {
            "year": 1983,
            "total": 13404455000
        },
        {
            "year": 1984,
            "total": 15305107000
        },
        {
            "year": 1985,
            "total": 19298884000
        },
        {
            "year": 1986,
            "total": 12690232000
        },
        {
            "year": 1987,
            "total": 13424504000
        },
        {
            "year": 1988,
            "total": 12757332000
        },
        {
            "year": 1989,
            "total": 13407874000
        },
        {
            "year": 1990,
            "total": 15264533000
        },
        {
            "year": 1991,
            "total": 19629646000
        },
        {
            "year": 1992,
            "total": 18081783000
        },
        {
            "year": 1993,
            "total": 16353661000
        },
        {
            "year": 1994,
            "total": 15564449000
        },
        {
            "year": 1995,
            "total": 17478000000
        },
        {
            "year": 1996,
            "total": 18287000000
        },
        {
            "year": 1997,
            "total": 17033000000
        },
        {
            "year": 1998,
            "total": 13837000000
        },
        {
            "year": 1999,
            "total": 11973000000
        },
        {
            "year": 2000,
            "total": 17395000000
        },
        {
            "year": 2001,
            "total": 12866000000
        },
        {
            "year": 2002,
            "total": 16923000000
        },
        {
            "year": 2003,
            "total": 17205000000
        },
        {
            "year": 2004,
            "total": 16030000000
        },
        {
            "year": 2005,
            "total": 17210000000
        },
        {
            "year": 2006,
            "total": 18985000000
        },
        {
            "year": 2007,
            "total": 52661000000
        },
        {
            "year": 2008,
            "total": 33426000000
        },
        {
            "year": 2009,
            "total": 42138000000
        },
        {
            "year": 2010,
            "total": 31519000000
        },
        {
            "year": 2011,
            "total": 33491000000
        },
        {
            "year": 2012,
            "total": 72790000000
        },
        {
            "year": 2013,
            "total": 21134000000
        },
        {
            "year": 2014,
            "total": 41053000000
        },
        {
            "year": 2015,
            "total": 47250000000
        },
        {
            "year": 2016,
            "total": 35971000000
        },
        {
            "year": 2017,
            "total": 40941000000
        },
        {
            "year": 2018,
            "total": 43049000000
        },
        {
            "year": 2019,
            "total": 30676000000
        },
        {
            "year": 2020,
            "total": 30678000000
        },
        {
            "year": 2021,
            "total": 30696000000
        },
        {
            "year": 2022,
            "total": 30696000000
        }
    ]
}

Errors

Possible HTTP Status Codes:

  • 500 : All other errors
{
  "message": "Sample error message"
}

Errors produed by invalid sort parameters:

{
  "message": "sort should be one of ('year', 'total'), not wxyz"
}
{
  "message": "order should be desc or asc, not wxyz"
}
@kevinli-work
Copy link

Can we add sorting logic to this (by year in either direction and by amount in either direction)?

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