Skip to content

Instantly share code, notes, and snippets.

@shinson
Last active November 2, 2017 17:24
Show Gist options
  • Save shinson/3f67d9ac3d72d66e295c7f978a471986 to your computer and use it in GitHub Desktop.
Save shinson/3f67d9ac3d72d66e295c7f978a471986 to your computer and use it in GitHub Desktop.
Updates to /api/v2/search/spending_by_geography/

Route: /api/v2/search/spending_by_geography/

Method: POST

This route takes award filters, and returns spending by state code, county code, or congressional district code.

Request

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

geo_layer: Defines which geographical level should be returned in the request. Options include: "state", "county", "district"

geo_layer_filter: Defines a filter for a specific geographic area correlating to the geo_layer. It is a list of strings that are the unique identifiers for the geographic location.

  • When geo_layer is "state" then the geo_layer_filters should be the county shape_code ex: ["MN", "WA", "DC"]. The state is the state_code
  • When geo_layer is "county" then the the geo_layer_filters should be the county geo_id ex: ["51041", "51117", "51179"]. The county shape_code is a concatenation of the state_FIPS_code + the county_code
  • When geo_layer is "district" then the geo_layer filters should be the county geo_id ex: ["5109", "5109", "5109"]. The county shape_code is a concatenation of the state_FIPS_code + the congressional_code
{
	"scope": "place_of_performance",
        "geo_layer": "state",
        "geo_layer_filters":["MN", "WA", "DC"],
	"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) - State

{
    "scope": "place_of_performance",
    "geo_layer": "state",
    "results": [
        {
            "shape_code": "MN",
            "display_name": "Minnesota",
            "aggregated_amount": 0
        },
        {
            "shape_code": "DC",
            "display_name": "District of Columbia",
            "aggregated_amount": 6393118.28
        },
        {
            "shape_code": "VA",
            "display_name": "Virginia",
            "aggregated_amount": 73700
        }
    ]
}

Response (JSON) - County

{
    "scope": "place_of_performance",
    "geo_layer": "county",
    "results": [
        {
            "shape_code": "51041",
            "display_name": "Chesterfield County",
            "aggregated_amount": 73700.27
        }
    ]
}

Response (JSON) - Congressional District

{
    "scope": "place_of_performance",
    "geo_layer": "district",
    "results": [
        {
            "shape_code": "5109",
            "display_name": "VA-09",
            "aggregated_amount": 47283.82
        }
    ]
}

Response Fields

  • scope: Choices are place_of_performance or recipient_location based on user's request
  • geo_layer: Choices are state, country, or district that is based on user's request
  • shape_code: Unique identifier used for mapping that is based on the geo_layer
  • display_name: Display name for shape code for labels on map
  • aggregated_amount: Sum of federal_action_obligation from the filtered transactions

Errors

Possible HTTP Status Codes:

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

Can we change congressional district to congressional in the geo_layer response?

@shinson
Copy link
Author

shinson commented Nov 2, 2017

Updated congressional district to district in request and response

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