The new version of CodeX API with it's backen

Overview

CodeX API

This API is still in very early stages of development. So consider not using the API in production.

Introducing the new CodeX API

Here's how you can execute code in various languages on your own website for free (no, there's no fucking catch, it's literally free),

Execute Code and fetch output

POST /

This endpoint allows you to execute your script and fetch output results.

What are the Input Parameters for execute api call?

Parameter Description
"code" Should contain the script that needs to be executed
"language" Language that the script is written in for example: java, cpp, etc. (Check language as a payload down below in next question)
"input" In case the script requires any kind of input for execution, leave empty if no input required

What are the languages that are supported for execution?

Whichever language you might mention in the language field, it would be automatically executed with the latest version of it's compiler.

Languages Language as a payload
Java java
Python py
C++ cpp
C c

More coming very soon!

NodeJS Example to Execute API Call?

var axios = require("axios");
var qs = require("qs");
var data = qs.stringify({
  code: "import java.util.Scanner;\npublic class MatSym {\n    public static void main(String[]args) {\n       Scanner in = new Scanner(System.in);\nSystem.out.println(in.nextLine());\nSystem.out.println(in.nextLine());\n    }\n}",
  language: "java",
  input: "Hello\nWorld",
});
var config = {
  method: "post",
  url: "https://codex-api.herokuapp.com/",
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
  },
  data: data,
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

Sample Output

The output is a JSON object comprising only one parameter that is the output.

{
  "success": true,
  "timestamp": "2022-05-26T19:59:08.014Z",
  "output": "Hello\nWorld\n",
  "language": "java",
  "version": "11.0.15"
}

Since a lot of people had issues with executing the previous API from backend or serverless function, unlike the previous version of the API, this version of the API won't throw any Cross Origin errors so you can use this from the front end without any worries. Thank me later ;)

GET /list

This endpoint allows you to list all languages supported and their versions.

[
  {
    "language": "java",
    "compilerVersion": "11.0.15"
  },
  {
    "language": "cpp",
    "compilerVersion": "11.2.0"
  },
  {
    "language": "py",
    "compilerVersion": "3.7.7"
  },
  {
    "language": "c",
    "compilerVersion": "11.2.0"
  }
]

Happy hacking!

Comments
  • C language seems to be using a cpp compiler?

    C language seems to be using a cpp compiler?

    When I try to compile my C code using the CodeX C compiler, i get a lot of errors complaining about casting a void* to something else, which is fine in C however forbidden in CPP (source: https://stackoverflow.com/a/22744183/11804669)

    Which is really weird because that would mean the C language for CodeX is actually compiled as if it was C++

    So as a test I tried copy pasting a C++ Hello World script into it (which should not AT ALL) compile if it was really C

    and that worked

    opened by justlucdewit 4
  • Heroku Issue

    Heroku Issue

    As Heroku has closed its free tiers the API is down. Please host it on sites like railway or porter so that the API can be up again. Thank you for the amazing API.

    opened by GunjanRajTiwari 3
  • Deploy in another platform

    Deploy in another platform

    As from 28th Nov 2022 Heroku going to charge money for free dynos ,so I am saying you to host it another platform to get free api hosting service. Thank you!!

    opened by surjendu104 2
  • added lang support for go, js, and cs

    added lang support for go, js, and cs

    Went ahead an implemented the lang support for go, cs, and javascript.

    One thing I believe we need to come to consensus of is the version of each compiler/interpreter that should be downloaded. As it stands, the most recent version is downladed through 'sudo apt-get install [compiler/interpreter]'. But this may not match up with the language versions hardcoded in the program/may break the endpoints with future updates. Thus, as aforementioned, I propose we standardize the version downloaded in the apt-get install command to avoid such inconsistencies. Wanted to run it by you first though Jaagrav.

    Thanks for the great api. Cheers!

    opened by YasserDbeis 2
  • API is crashed

    API is crashed

    I written a program in C++ for infinite memory usage which is as follows

    #include<iostream>
    using namespace std;
    
    int main() {
        while(true) {
            int *n = new int[10000];
        }
    }
    

    I think the API has been crashed after executing above code as it is showing 'Network Error' now (earlier it was working fine). please try to resolve this issue and place a limit on memory usage and execution time.

    opened by SaurabhKhade 1
  • [Enhancement] Repetitive Code to Run/Execute Each Language

    [Enhancement] Repetitive Code to Run/Execute Each Language

    Creating this as an issue to be tackled in a future PR.

    Just noticed that the code to run/execute each language is basically the same, minus the spawn command. Thought the code could be refactored to avoid such redudancy.

    I will likely pick this issue up if someone does not already in the upcoming day(s).

    enhancement 
    opened by YasserDbeis 1
  • API has crashed

    API has crashed

    Getting the following response

    response: { status: 503, statusText: 'Service Unavailable', headers: { connection: 'close', server: 'Cowboy', date: 'Sun, 30 Oct 2022 07:40:57 GMT', 'content-length': '506', 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache, no-store' },

    opened by basura-persistent 0
  • Java code not working

    Java code not working

    I cloned this project, run rpm install. Everything seems to working fine. I tested c, cpp, js codes, all work fine but java code is not working.

    case 'java':
                return {
                    executeCodeCommand: 'java',
                    executionArgs: [
                        join(process.cwd(), `codes/${jobID}.java`)
                    ],
                    compilerInfoCommand: 'java --version'
                };
    
    opened by abhishekk-raj 1
  • Delayed asynchronous code features

    Delayed asynchronous code features

    Is there a way to work with asynchronous code that have delay? For example, setTimeout() in javascript.

    If i made a code inside the timeout and make the delay to be 2 seconds, all of the code just executed. Here is example code

    console.log("before timeout");
    setTimeout(() => {
        console.log("inside timeout");
    }, 2000);
    
    enhancement 
    opened by BanDroid 5
  • Implementation in Java

    Implementation in Java

    private JSONObject getCompileResult(String code, String input, String language) throws UnirestException { Unirest.setTimeouts(0, 0); HttpResponse<String> response = Unirest.post("https://codex-api.herokuapp.com") .header("Content-Type", "application/x-www-form-urlencoded") .field("code", code) .field("language", language) .field("input", input==null ? "" : input) .asString(); return new JSONObject(response.getBody()); }

    opened by Aleksov2020 0
  • [Enhancement] Add compilation/running of multiple files

    [Enhancement] Add compilation/running of multiple files

    Future feature to be implemented: running code with multiple files.

    This seems fairly straight forward with compiled languages. For example, for c/cpp we can send the code as an array of strings, have the file for each code string created, and the g++ command should take care of the rest in creating the executable. Some minor accomodations may need to be made to differentiate b/w header and non-header files, but that is not a big deal.

    For interpreted languages, like python, I am not sure its as straight forward with the current mechanism. This is because if a python file imports from a file called "x", the imported filename will be modified to a UUID with the current set-up and thus the import statement will be broken. However, I might be misunderstanding and welcome criticism/solutions.

    opened by YasserDbeis 1
Releases(v1-alpha)
Owner
LÆS
18 | I like problems
LÆS
Can see everything, beware of its omniscience, kneel before its greatness.

Can see everything, beware of its omniscience, kneel before its greatness. Summary Presentation Installation Removing Credits Presentation Main goal T

Duc Justin 3 Sep 30, 2022
:new:A new version of Icalingua.

Icalingua 3 新版 Icalingua。将抛弃 Electron,转向网页前端 + Node 后端(类似于原来 icalingua-bridge-oicq)的模式。 正在开发中。当前技术栈选型: oicq2 socket.io Vue3 Fastify WindiCSS rxjs Mikr

Icalingua++ 150 Dec 27, 2022
Extract a JS/TS module and its dependencies into a new package

module-extractor Extract a module and its dependencies into a new package Usage import { extractModules } from 'module-extractor' const extraction =

Alec Larson 12 Aug 9, 2022
The Remix version of the fakebooks app demonstrated on https://remix.run. Check out the CRA version: https://github.com/kentcdodds/fakebooks-cra

Remix Fakebooks App This is a (very) simple implementation of the fakebooks mock app demonstrated on remix.run. There is no database, but there is an

Kent C. Dodds 61 Dec 22, 2022
Its an app that uses a weather API with access to over 200,000 cities current weather conditons.

Weather App Its an app that uses a weather API with access to over 200,000 cities current weather conditons. Screenshots Links Live Site URL: live sit

Yusuf Lawal 5 Aug 17, 2022
Easily open daily notes and periodic notes in new pane; customize periodic notes background; quick append new line to daily notes.

Obsidian daily notes opener This plugin adds a command for opening daily notes in a new pane (so that a keyboard shortcut could be used!) and gives ex

Xiao Meng 16 Dec 26, 2022
P.S Its easy is a website to cater to all your PS allotment needs

P.S. It's Easy All-in-one Web App for all your Practice School Allotment needs! Note: Developers trying to fork and test. Please wait, we'll set up a

Tanya Prasad 33 Sep 26, 2022
The app helps you to add todo items to your list, mark completed ones and also delete finished items. Its a handy tool for your day today activies. Check out the live demo.

Todo List App The app helps you to add todo items to your list, mark completed ones and also delete finished items. Its a handy tool for your day toda

Atugonza ( Billions ) Joel 14 Apr 22, 2022
A cross-platform AutoHotKey-like thing with TypeScript as its scripting language

suchibot A cross-platform AutoHotKey-like thing with JavaScript/TypeScript as its scripting language. Built on top of uiohook-napi and nut.js. Install

Lily Scott 79 Sep 21, 2022
I forgot about el.outerHTML so I made this, it takes a DOM element and returns its html as string

htmlToString Convert html/DOM element to string Works with rendered and virtual DOM Installation npm install htmltostring Or using CDN <script src="ht

Shuvo 4 Jul 22, 2022
A nuxt 2 wrapper around derrickreimer/fathom-client to be able to use usefathom.com in all its glory

This package is a nuxt 2 wrapper around derrickreimer/fathom-client to be able to use usefathom.com in all its glory. Thanks to @derrickreimer for this framework agnostic library ❤️‍??.

wellá 6 Aug 18, 2022
📜 Sharable eslint configuration rimac technology uses in all of its projects.

Eslint Config Usage Install the library as a dev dependency alongside required dependencies using yarn add -D @rimac-technology/eslint-config

Rimac Technology 8 Nov 23, 2022
Transmute one JavaScript string into another by way of mutating its AST. Powered by babel and recast.

equivalent-exchange Transmute one JavaScript string into another by way of mutating its AST. Powered by babel and recast. Features Can parse code usin

Lily Scott 51 Jul 9, 2022
↕️ A little Alpine.js plugin to automatically resize a textarea to fit its content.

↕️ Alpine Autosize ↕️ A little Alpine.js plugin to automatically resize a textarea to fit its content. ?? Installation CDN Include the following <scri

Marc Reichel 42 Nov 5, 2022
This is a Microverse (@microverseinc) project in which I created a To-do list using Webpack. User can add a task, delete it, edit its description, and clear the completed tasks.

Microverse To-Do list This is a Microverse (@microverseinc) project in which I created a To-do list using webpack. Requirements Build a Todo list usin

Manel Hammouche 11 Aug 3, 2022
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations and read random math-related quotes. Its built using react

Math Magician "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations a

Charles Gobina 5 Feb 23, 2022
Simple and Extensible Markdown Parser for Svelte, however its simplicity can be extended to any framework.

svelte-simple-markdown This is a fork of Simple-Markdown, modified to target Svelte, however due to separating the parsing and outputting steps, it ca

Dave Caruso 3 May 22, 2022