Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are the list of filters for api/v1/awards? #2005

Closed
lhux opened this issue Aug 30, 2019 · 12 comments
Closed

What are the list of filters for api/v1/awards? #2005

lhux opened this issue Aug 30, 2019 · 12 comments

Comments

@lhux
Copy link

lhux commented Aug 30, 2019

More specifically, I am trying to filter by DUNS number and fiscal year. What are the filter names for this?

@BrianZito
Copy link
Contributor

First things first, is there specific functionality from v1 that you need to be using? https://github.com/fedspendingtransparency/usaspending-api/blob/master/usaspending_api/api_docs/api_documentation/advanced_award_search/spending_by_award.md is the equivalent in v2, which is better documented and actively supported. You can check the link to the filter object to find DUNS and fiscal year.

@lhux
Copy link
Author

lhux commented Aug 30, 2019

Yes, I wasn't able to get my code to function under v2, only v1.

@BrianZito
Copy link
Contributor

Is this because of the 500 error in the issue before this? If you're seeing the problem between versions that will be valuable to add to our DEV ticket and resolve the problem faster. My assumption is that some kind of data formatting/quality check was added between versions and wasn't documented correctly.

@lhux
Copy link
Author

lhux commented Aug 30, 2019

Yes, I get an internal server error when using v2. I also tried using recipient_unique_id as a filter and it doesn't appear to work with v1.

@lisaam
Copy link

lisaam commented Aug 30, 2019

Have you tried using the Advanced Search on USAspending.gov to form your query string? (Or just download the info you need?)

@lhux
Copy link
Author

lhux commented Aug 30, 2019

Is there a way to get the query code from the Advanced Search tool on the gov site?

@BrianZito
Copy link
Contributor

Anytime you're on a website and it sends out a request, you can look at what was sent. It's a very powerful tool in a developer's utility belt https://www.google.com/search?ei=ezlpXcDzEcTQ-gT77Z_gDg&q=network+tab+chrome&oq=network+tab+on+browsers&gs_l=psy-ab.1.0.0i71l8.0.0..10624...0.2..0.0.0.......0......gws-wiz.Dj4ZWxXdkYU

@lhux
Copy link
Author

lhux commented Aug 30, 2019

I can't find the necessary information that way.

@lisaam
Copy link

lisaam commented Aug 30, 2019

I'll have an example for you in a few minutes.

@lisaam
Copy link

lisaam commented Aug 30, 2019

I searched on FY 2019 and DUNS 152670030

The Chrome screen where I pulled the query from looks like:
Advance_Search_API

The query string is:

{"filters":{"time_period":[{"start_date":"2018-10-01","end_date":"2019-09-30"}],"award_type_codes":["A","B","C","D"],"recipient_search_text":["152670030"]},"fields":["Award ID","Recipient Name","Start Date","End Date","Award Amount","Awarding Agency","Awarding Sub Agency","Contract Award Type"],"page":1,"limit":60,"sort":"Award Amount","order":"desc","subawards":false}

Documentation for the API endpoint is at:
https://github.com/fedspendingtransparency/usaspending-api/blob/master/usaspending_api/api_docs/api_documentation/advanced_award_search/spending_by_award.md

I hope this helps.

@lhux
Copy link
Author

lhux commented Aug 30, 2019

Capture

Do you have any suggestions?

@lisaam
Copy link

lisaam commented Aug 30, 2019

It looks like you may be missing some json details. Try this:

import requests

json_body = {
"filters": {"time_period": [
{
"start_date": "2018-10-01",
"end_date": "2019-09-30"
}],
"award_type_codes": ["A","B","C","D"],
"recipient_search_text": ["152670030"]
},
"fields": ["Award ID", "Recipient Name", "Start Date", "End Date", "Award Amount", "Awarding Agency", "Awarding Sub Agency","Contract Award Type"],
"page": 1,
"limit": 60,
"sort": "Award Amount",
"order": "desc",
"subawards":"false"
}
r = requests.post('https://api.usaspending.gov/api/v2/search/spending_by_award', json=json_body)
print(r.status_code)

@lhux lhux closed this as completed Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants