the file
by posting the file:
curl https://public.opencpu.org/ocpu/library/utils/R/read.csv -F "[email protected]"
which outputs:
/ocpu/tmp/x0667b22ae7/R/.val
/ocpu/tmp/x0667b22ae7/stdout
/ocpu/tmp/x0667b22ae7/source
/ocpu/tmp/x0667b22ae7/console
/ocpu/tmp/x0667b22ae7/info
/ocpu/tmp/x0667b22ae7/files/airquality.csv
/ocpu/tmp/x0667b22ae7/files/DESCRIPTION
where x0667b22ae7
becomes the session id for our next call.
set to the session id:
curl https://public.opencpu.org/ocpu/library/utils/R/head -d "x=x0667b22ae7"
which outputs:
/ocpu/tmp/x07505e8fc7/R/.val
/ocpu/tmp/x07505e8fc7/stdout
/ocpu/tmp/x07505e8fc7/source
/ocpu/tmp/x07505e8fc7/console
/ocpu/tmp/x07505e8fc7/info
/ocpu/tmp/x07505e8fc7/files/DESCRIPTION
of this last session:
curl https://public.opencpu.org/ocpu/tmp/x07505e8fc7/R/.val/print
which outputs:
Ozone Solar.R Wind Temp Month Day
1 41 190 7.4 67 5 1
2 36 118 8.0 72 5 2
3 12 149 12.6 74 5 3
4 18 313 11.5 62 5 4
5 NA NA 14.3 56 5 5
6 28 NA 14.9 66 5 6
read_csv_session=$(curl https://public.opencpu.org/ocpu/library/utils/R/read.csv -F "[email protected]" | head -n1 | cut -f 4 -d "/")
head_data_session=$(curl https://public.opencpu.org/ocpu/library/utils/R/head -d "x=$read_csv_session" | head -n1 | cut -f 4 -d "/")
curl https://public.opencpu.org/ocpu/tmp/$head_data_session/R/.val/print
The general pattern is we can call functions at the various endpoints by POSTing named paramaters.
To get what the parameter names should be, we can do do a curl like this:
curl https://public.opencpu.org/ocpu/library/utils/R/head/print
or, we can go to https://public.opencpu.org/ocpu/library/utils/R/head in your browser to see. If we go to https://public.opencpu.org/ocpu/library/utils/R/, we can see all available functions to call with the utils route. We can see base R functions at https://public.opencpu.org/ocpu/library/base/R/.
The same goes for the base path of any library, such as going to https://public.opencpu.org/ocpu/library/ggplot2/R/, or https://public.opencpu.org/ocpu/library/ggplot2/info/ for the info/help.
See the docs for openCPU here for more about the endpoints.
There are also some cool ways to use the JavaScript library which conveniently wraps making calls to the ocpu
endpoints in JavaScript functions.