ropensci / rnassqs

R interface for the USDA National Agricultural Statistical Service's (NASS) 'Quick Stats' API (https://quickstats.nass.usda.gov/api)
https://docs.ropensci.org/rnassqs
Other
46 stars 18 forks source link

Cannot get national level data #37

Closed dwd62 closed 8 months ago

dwd62 commented 9 months ago

I've been trying into get national level data from the NASS for livestock, poultry, and specialty animals. I've been able to get the state and county aggregated data just fine, but the national level data will show that there are zero records and when I make a request regardless there is an error I've provided an example below from the rnassqs vignette example.

Specify the query parameters

params <- list( commodity_desc = "OPERATORS", domain_desc = "AREA OPERATED", agg_level_desc = "NATIONAL", state_alpha = "OR", year = 2012 )

api_key<-"14E99758-813A-3976-B5FE-DAB3689E1E25" Sys.setenv(NASSQS_TOKEN = api_key) nass_set_key("14E99758-813A-3976-B5FE-DAB3689E1E25")

Check that our record request is under the 50,000 limit

nassqs_record_count(params)

> nassqs_record_count(params)

|==============================================================================================#=================================| 100%

$count

[1] 0

$Value

numeric(0)

Get the data

d <- nassqs(params)

Error: HTTP Failure: 400

bad request - invalid query

Does anyone have an idea what is happening here?

potterzot commented 9 months ago

It looks like you are including state_alpha = "OR" in your parameters when querying national data. As you can imagine there is no national level data for Oregon! If I remove that I am able to successfully query 54 records.

dwd62 commented 9 months ago

@potterzot thanks! I didn't know that specifying the states would supersede also grabbing national level data.