Search code examples
rrestapiplumber

specify param in R plumber


I created a REST API in R using plumber.

#* description
#* @param id Unique ID  
#* @get /data/<id:int>

where id is required to be numeric. However, plumber also sets required = true. How can I set type of id to numeric (integer) without setting required to true? Cannot find any hints in the manual.


Solution

  • Try:

    #* description
    #* @param id:int Unique ID  
    #* @get /data
    function(id=NULL) {}
    

    Source:

    Is there a way to add optional parameter in API using R Plumber?

    https://www.shirin-glander.de/2018/01/plumber/