PESTO

A Remote Code Execution Engine that lets you execute any piece of code on a remote server via HTTP REST API.

What is Pesto?

Pesto is a Remote Code Execution Engine that lets you execute any piece of code on a remote server via REST API. It is heavily inspired by Piston. Pesto is not a fork of Piston, it's an entire rewrite from scratch and therefore it's not compatible with Piston but should be similar if you're already familiar with Piston.

How is it different from Piston?

Unlike Piston, Pesto uses TypeScript instead of JavaScript. Think of it as an aggresive refactor approach to simplify the codebase and its functionality.

The way Piston works is you would install the language support separately using the Piston CLI. In Pesto, however, the language is bundled in the docker image. You can choose which language you want to use by defining a language configuration inside a .toml file and an installation script before you deploy your Pesto instance.

Pesto is much simpler than Piston. It doesn't support uploading files to execute and passing arguments or stdin to your program.

How does Pesto execute my code?

Pesto will execute your code in an isolated docker environment from a dedicated temporary user that will get removed once your code is finished being executed. Your code will have no access to the filesystem, internet, and it will have a very limited amount of resources by default.

What Pesto is and isn't

Pesto is not a replacement for a serverless runtime, no. It is meant to execute a short snippet of your code. This is suitable if you're building a code challenge platform or similar because usually you will only need to execute short snippets of code like user's submission for a challenge.

How do I get started?

You can use the provided HTTP REST API to execute your code, but you can also host your own instance of Pesto on your own server. Since we don't have an unlimited resource, an API token is required to limit any incoming requests.

Usage via REST API

  • Request an API token here
  • Send a POST request to the server with the token as the X-Pesto-Token header and an application/json body with the following fields:
    • language The language of the code that you want to execute.
    • version The version of the language (or just fill in with "latest").
    • code The code that you want to execute.
  • Upon sending a successful request, you will receive a response with the following fields:
    • language The language of the code that you sent.
    • version The version of the language.
    • compile/runtime The result of the compilation and execution with the following fields.
      • stdout The content of the stdout when the code is being compiled or executed.
      • stderr The content of the stderr when the code is being compiled or executed.
      • output The combination of stdout and stderr.
      • exitCode The exit code of the program compilation or execution.
      • compileTimeout (Optional) The maximum duration that the code is allowed to compile in millisecond. Maximum value is 30 seconds (30000 milliseconds). If not provided, the default value of 5 seconds will be set.
      • runTimeout (Optional) The maximum duration that the code is allowed to run in millisecond. Maximum value is 30 seconds (30000 milliseconds). If not provided, the default value of 5 seconds will be set.
      • memoryLimit (Optional) The maximum amount of memory that the code is allowed to use in bytes. Maximum value is 512MB (1024 * 1024 * 512). If not provided, the default value of 128MB will be set.

Example

Here's an example on how a request and response should look like.

Request
HTTP POST /api/execute HTTP/1.1
X-Pesto-Token: 
Content-Type: application/json
Accept: application/json

{
  "language": "Python",
  "version": "3.10.10",
  "code": "print('Hello World')"
}
Response
{
  "language": "Python",
  "version": "3.10.10",
  "compile": {
    "stdout": "",
    "stderr": ""
    "output": ""
    "exitCode": 0
  },
  "runtime": {
    "stdout": "Hello World",
    "stderr": ""
    "output": "Hello World"
    "exitCode": 0
  },
}

List of available runtimes

The Pesto REST API currently supports the following runtimes:

  • Python v3.12.0
  • Java OpenJDK 17
  • C/C++ GCC v12.2.0
  • Common Lisp SBCL v2.2.7
  • Elixir v1.14.1
  • Erlang v25.1.2
  • Go v1.21.4
  • Javascript Node v20.9.0
  • Typescript Bun v1.0.13
  • PHP v8.1
  • Brainfuck v2.7.3
  • Ruby v3.2.1
  • Julia v1.9.4
  • Lua v5.4.4
  • Janet v1.27.0
  • SQLite3 3.34.1

More runtimes will be supported in the future.

Request an API key

You can request an API key which you can then use to execute your code via a REST API call using this form.