vignettes/files/apis/07-02-plot-safe.R

#* This is an example of an safe endpoint which
#* checks user input to avoid a DOS attack
#* @get /
#* @query pts:integer(10)
#* @serializer png
function(query) {
  if (query$pts > 1000 & query$pts < 1){
    abort_bad_request("pts must be between 1 and 1,000")
  }
  plot(1:pts)
}

Try the plumber2 package in your browser

Any scripts or data that you put into this service are public.

plumber2 documentation built on Jan. 20, 2026, 5:06 p.m.