-
Notifications
You must be signed in to change notification settings - Fork 113
API Usage Power Query Example
Wil Collins edited this page Sep 1, 2022
·
2 revisions
This code snippet demonstrates how to make a POST request to the spending_by_geography endpoint at https://api.usaspending.gov/api/v2/search/spending_by_geography/ using Excel Power Query. This snippet was designed as an interactive exercise for a training on the USAspending API.
let
url = "https://api.usaspending.gov/api/v2/search/spending_by_geography/",
body = "{
""scope"": ""recipient_location"",
""geo_layer"": ""district"",
""filters"": {
""time_period"": [
{
""start_date"": ""2020-10-01"",
""end_date"": ""2021-09-30""
}
],
""recipient_locations"": [
{
""state"": ""FL"",
""country"": ""USA"",
""district"": ""08""
}
]
}
}",
Source = Json.Document(Web.Contents(url,[Content=Text.ToBinary(body),Headers=[#"Content-Type"="application/json"]]))
in
Source
This code wnippet demonstrates how to make a POST request to the spending_by_geography endpoint at https://api.usaspending.gov/api/vs/disaster/spending_by_geography using Excel Power Query. This snippet was designed as an interactive exercise for a training on the USAspending API.
let
url = "https://api.usaspending.gov/api/v2/disaster/spending_by_geography/",
body = "{
""spending_type"": ""obligation"",
""geo_layer"": ""district"",
""geo_layer_filters"": [""1208""],
""filter"": {""def_codes"": [""L"", ""M"", ""N"", ""O"", ""P"", ""U"", ""V""]}
}",
Source = Json.Document(Web.Contents(url,[Content=Text.ToBinary(body),Headers=[#"Content-Type"="application/json"]])),
results = Source[results],
results1 = results{0},
#"Converted to Table" = Record.ToTable(results1)
in
#"Converted to Table"
- Home
- The DATA Act
-
Data
- Account Data (A/B/C)
-
Award Data (D1/D2)
- Contract Data (D1)
- Assistance Data (D2)
- Recipient Data (E)
- Subaward Data (F)
- File C to D Linkage
- Agency Data (Federal Hierarchy)
- Location Data
- Management Commands
- Release Notes
- Resources