Use the latex endpoint to compile a latex document. This endpoint converts a tex file to pdf, and stores the pdf temporarily as a blob in CoCalc’s PostgreSQL database. The tmp files used for compilation are cleaned up. You can specify a project_id in the API call, or leave that off and your most recent project gets used automatically (or a new one created). By default the compilation uses “latexmk” with certain options, but you can specify a custom command parameter to convert the tex to pdf.

x='sk_xxxxx' # your API key

# c is the latex document as a text string
c='\documentclass{article}\begin{document}\section{Main Section}Hello.\end{document}'

curl -sk \
  -u $x: \
  -d path=/tmp/d.tex \
  -d content=$c \ | jq '.url'


### sample output is a url
### browse to this link to see the compiled pdf document

You can learn more about the latex endpoint by viewing the source code at…/api/v2/latex.ts.