1

I am trying to query a range of dates from an API in R/Shiny. I use dateRangeInput to specify the range, and the API documentation specifies that the call is:

spuddate, Value should be in the RFC3339 format, Latest date that drilling commenced on the property. Example: spuddate=gt(2006-01-02T15:04:05Z) spuddate=le(2017-03).

How would I do this correctly?

I've tried several methods using anytime and rfc3339 but I keep getting various errors. I suspect it has to be something around the way I structure the input call in server.

#UI - Obviously there are more but for sake of brevity here is the subset
sidebarPanel(
      fluidRow(
        column(12,
               selectizeInput('stateSelect','STATE', choices= paste0(state.abb, sep=''), multiple=FALSE))
      ),
      fluidRow(
        column(12,
               selectizeInput('directionSelect','HOLE DIRECTION', choices= c('H','V','D','U'), multiple=FALSE))
      ),
      fluidRow(
        column(12,
               dateRangeInput("dateSelect", label = h3("Spud Date range")))
      ),
#Server Try So Far -- Obviously there are more but for sake of brevity here is the subset
observeEvent(input$select, {
      wellInfo <- GET("https://di-api.drillinginfo.com/v2/direct-access/producing-entities",
                      add_headers(c('X-API-KEY' = key, 'Authorization' = addToken, 'Accept' = 'text/xml')),
                      query=list(drilltype = dput(input$directionSelect), state = dput(input$stateSelect),
                                 spuddate = (rfc3339(anytime(input$dateSelect[1])),rfc3339(anytime(input$dateSelect[2]))),
                                 pagesize = 100000))
})

I just want to get the query to go off. It works without the spuddate call (ie just the state and drilltype query). Any help would be appreciated! Thanks.

0

1 Answer 1

1

Ok, figured out a brute force solution.


date1 <- paste('btw(',date(anytime(input$dateSelect[1])),
                     ',',date(anytime(input$dateSelect[2])),')', sep='')

      wellInfo <- GET("https://di-api.drillinginfo.com/v2/direct-access/producing-entities",
                      add_headers(c('X-API-KEY' = key, 'Authorization' = addToken, 'Accept' = 'text/xml')),
                      query=list(drilltype = dput(input$directionSelect), state = dput(input$stateSelect),
                                 spuddate = dput(date1),
                                 #spuddate <= (as.POSIXct(as.character(input$dateSelect2, format = '%Y-%m'))),
                                 pagesize = 100000))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.