Skip to content

danimydev/code-runner-api

Repository files navigation

code-runner-api

A deno api for running code in different programming languages.

Requirements

Supported Languages

Run Locally

Clone the project

  git clone https://github.com/thieves-guild/code-runner-api.git

Go to the project directory

  cd code-runner-api

Start the server

  # locally production
  deno task start
  # locally development
  deno task dev
  # container
  docker-compose up --build

API Reference

You can use Bruno to open code-runner-api folder (collection).

Health check

GET /health

HTTP/1.1 200 OK

Get all supported languages

GET /languages

HTTP/1.1 200 OK
Content-Type: application/json

{
  "languages": [
    {
      "name": "typescript",
      "info": {
        "enviromentCommand": "--version",
        "executionCommand": "deno",
        "executionArgs": [
          "run"
        ],
        "extension": "ts",
        "websiteUrl": "https://www.typescriptlang.org/"
      },
      "enviroment": [
        "deno 1.37.0 (release, x86_64-unknown-linux-gnu)",
        "v8 11.8.172.3",
        "typescript 5.2.2"
      ]
    },
    {
      "name": "python3",
      "info": {
        "enviromentCommand": "--version",
        "executionCommand": "python3",
        "executionArgs": [],
        "extension": "py",
        "websiteUrl": "https://www.python.org/"
      },
      "enviroment": [
        "Python 3.10.13"
      ]
    }
  ],
  "timeStampt": 1695563685183
}

Get supported languages by name (unique)

GET /languages/:languageName

HTTP/1.1 200 OK
Content-Type: application/json

{
  "name": "python3",
  "info": {
    "enviromentCommand": "--version",
    "executionCommand": "python3",
    "executionArgs": [],
    "extension": "py",
    "websiteUrl": "https://www.python.org/"
  },
  "enviroment": [
    "Python 3.10.13"
  ],
  "timeStampt": 1695563724530
}

Run code

POST /code
Content-Type: application/json

{
  "language": "typescript",
  "code": "console.log('hello world');"
}

HTTP/1.1 201 OK
Content-Type: application/json

{
  "languague": "typescript",
  "code": 0,
  "stdout": "hello world\n",
  "stderr": "",
  "timeStampt": 1695563805981
}

About

Rest API that runs your code in containers and provide stdout and stderr

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published