socdataR / wonderapi

Assists in making queries to CDC Wonder API
https://socdatar.github.io/wonderapi/
23 stars 14 forks source link

Trying to get age specific mortality data HTTP 500 error #13

Closed coreysparks closed 8 months ago

coreysparks commented 2 years ago

Hello, i'm trying to get 5 or 10 year grouped mortality data by gender or race, and keep getting the same HTTP 500 error. Example queries are below:

Race first, then Age groups

mylist <- list(list("Group Results By", "D76.V8"), list("And By", "D76.V5")) mydata <- getData(TRUE, "Detailed Mortality", mylist)

Error in wondr::make_query(querylist, dbcode) : Internal Server Error (HTTP 500).

Age groups only

mylist <- list(list("Group Results By", "D76.V5"))

mydata <- getData(TRUE, "Detailed Mortality", mylist)

Error in wondr::make_query(querylist, dbcode) : Internal Server Error (HTTP 500).

I can't seem to get anything to work with age groups Any help would be fantastic, thank you

jtr13 commented 2 years ago

Thanks for alerting me to this issue. It's not working for me either. Unfortunately it's very hard to figure out the cause of these errors. The only documentation for the API is here: https://wonder.cdc.gov/wonder/help/WONDER-API.html so there's a lot of guessing in how to set up the queries. Sorry I am not able to be more helpful.

coreysparks commented 2 years ago

Thank you, yes, it is overly complicated

jtr13 commented 2 years ago

Update: I've made some changes to the package. This code should work now. A heads-up that I've removed the need to actively agree to the terms and made agreeing the default so "TRUE" should be removed from all queries.

library(wonderapi)
mylist <- list(list("Group Results By", "D76.V8"), list("And By", "D76.V5"))
getData("Detailed Mortality", mylist)
#> # A tibble: 44 × 5
#>    Race                          `Ten-Year Age …` Deaths Population `Crude Rate`
#>    <chr>                         <chr>             <dbl>      <dbl>        <dbl>
#>  1 American Indian or Alaska Na… < 1 year           7785    1555739        500. 
#>  2 American Indian or Alaska Na… 1-4 years          2008    6103380         32.9
#>  3 American Indian or Alaska Na… 5-14 years         2389   15507116         15.4
#>  4 American Indian or Alaska Na… 15-24 years       13362   15342926         87.1
#>  5 American Indian or Alaska Na… 25-34 years       20030   13479825        149. 
#>  6 American Indian or Alaska Na… 35-44 years       28923   12207744        237. 
#>  7 American Indian or Alaska Na… 45-54 years       46247   10675311        433. 
#>  8 American Indian or Alaska Na… 55-64 years       61783    7438683        831. 
#>  9 American Indian or Alaska Na… 65-74 years       67389    3881756       1736  
#> 10 American Indian or Alaska Na… 75-84 years       63546    1648161       3856. 
#> # … with 34 more rows

Created on 2022-03-26 by the reprex package (v2.0.0)