Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Download Tool to Generate POST Request & Get Results

hellyars
13 - Pulsar

 

 

Download Tool Question....

 

I am trying to test a connection to USASpending to retrieve award data -- link to award search page here.

 

I watched the tutorial video on YouTube here

 

I am trying to do a POST request to this API endpoint.

 

 

https://api.usaspending.gov/api/v2/search/spending_by_award/

 

 

Documentation for this endpoint is here.

 

My SEARCH CRITERIA is pretty straightforward:

 

  • KEYWORD = 'ZHEGXL9HYV43'     This is a unique entity identifier but as it refers to a parent company I found it produces the desired result when using KEYWORD and NOT recipient.
  • TIME PERIOD = Fiscal Years FY2024 thru 2014  but it could be any range in theory.
  • I only care about contracts.  The result should be 2,161

 

 

From Firefox, I from Network/Request the following request.  Note: It should be in line with API documentation (as it was generated by the USASpending search page).

 

{"filters":{"keywords":["ZHEGXL9HYV43"],"time_period":[{"start_date":"2023-10-01","end_date":"2024-09-30"},{"start_date":"2013-10-01","end_date":"2014-09-30"},{"start_date":"2014-10-01","end_date":"2015-09-30"},{"start_date":"2015-10-01","end_date":"2016-09-30"},{"start_date":"2016-10-01","end_date":"2017-09-30"},{"start_date":"2017-10-01","end_date":"2018-09-30"},{"start_date":"2018-10-01","end_date":"2019-09-30"},{"start_date":"2019-10-01","end_date":"2020-09-30"},{"start_date":"2020-10-01","end_date":"2021-09-30"},{"start_date":"2021-10-01","end_date":"2022-09-30"},{"start_date":"2022-10-01","end_date":"2023-09-30"}],"award_type_codes":["A","B","C","D"]},"fields":["Award ID","Recipient Name","Start Date","End Date","Award Amount","Total Outlays","Description","def_codes","COVID-19 Obligations","COVID-19 Outlays","Infrastructure Obligations","Infrastructure Outlays","Awarding Agency","Awarding Sub Agency","Contract Award Type","recipient_id","prime_award_recipient_id"],"page":1,"limit":60,"sort":"Award Amount","order":"desc","subawards":false}

 

 

??? QUESTIONS ????

 

Basic

  1. How do I replicate this using the Download Tool?
  2. Does the API allow you to download only the results table  (which I believe the payload requests) OR

Advanced:

  1. Does the API allow you to download the full results at the AWARD level of detail  OR
  2. Does the API allow you to download TRANSACTION level of detail with all 290+ fields OR will it only allow you to download as a .csv or zipped collection of .csv

 

I tried to replicate the results using an Input Tool with the URL to the endpoint connected to a Download Tool.  I did not get the desired results.

 

The Download Tool was configured as follows:

 

BASIC  took the URL from the Input Tool's URL field.  The URL was the same as above.

HEADERS -  nothing -  This is probably where I messed up.

PAYLOAD

  • HTTP Action set to POST
  • Use Following for Query String/Body checked and request from Firefox Inspector used here.
  • I also tried using the request payload in a field from my Input Tool.

 

 

 

 

Screenshot 2024-04-16 142625.png

 

Screenshot 2024-04-16 144341.png

4 REPLIES 4
hellyars
13 - Pulsar

Let my refine my question. 

The BASIC question should suffice. 
The Advanced questions appear to be addressed by the Bulk Award Download API, which downloads too much.

apathetichell
18 - Pollux

This might help with some of the basics. you'll probably need to use a nested api to get what you fully want.

hellyars
13 - Pulsar

@apathetichell

 

Sorry for not responding sooner.

This is exactly what I needed to know.

THANK YOU.

 

Header  = Content-Type = application/son

Payload = Take Query String/Body from Field = JSON Payload (or whatever the filed is named)

 

And the sample JSON Payload is:

 

I changed limit from 10 to 84 just to see if I could get all the results for 2024.  It worked.

From there, filters and fields should just comply with API instructions for this or any of the endpoint. 

 

  {
      "subawards": false,
      "limit": 84,
      "page": 1,
      "filters": {
          "keywords": ["ZHEGXL9HYV43"],
            "award_type_codes": ["A", "B", "C"],
          "time_period": [{"start_date": "2023-01-01", "end_date": "2024-09-30"}]
      },
      "fields": [
          "Award ID",
          "Recipient Name",
          "Start Date",
          "End Date",
          "Award Amount",
          "Awarding Agency",
          "Awarding Sub Agency",
          "Contract Award Type",
          "Award Type",
          "Funding Agency",
          "Funding Sub Agency"
      ]
  }

 

 

 

 

 

apathetichell
18 - Pollux

@hellyars 

 

two quick things - 1) I think another endpoint will give you the total count. You can use that with generate rows/offest logic to limit it to 100 per call - and then to create a mapping to create the actual item number 2) I ran for ["a","b","c"] - i think you want to include "d"

Labels