ah_code_compiler_sdk
v1.1.0
Published
A modern, cross-platform code compilation SDK by Akash Halder. Execute code in 30+ programming languages with rich CLI output, SQL table formatting, and a built-in interactive editor.
Maintainers
Readme
An easy-to-use SDK written in Typescript for compiling and executing code in 30+ programming languages. Ideal for building online code editors, education platforms, and developer tools.
Try out the live Online Code Editor & Compiler powered by this SDK: https://www.akashhalder.in/code-compiler
✨ Features
- Fetch all supported runtimes dynamically from the API
- Execute code in 30+ programming languages (Python, JavaScript, C++, Java, Go, Rust, SQL, and more)
- Styled SQL output — multiple query results rendered as colorful CLI tables
- Fully typed and written in modern TypeScript
- Includes a built-in interactive CLI code editor
- Compatible with Node.js projects and CLI tools
- Also available for the Python ecosystem → AHCodeCompiler on PyPI
💡 CLI Editor Demo
📦 Installation
> npm i ah_code_compiler_sdk
> bun i ah_code_compiler_sdkor
> pnpm add ah_code_compiler_sdk
> yarn add ah_code_compiler_sdk🚀 Usage
Using CommonJS (ES5)
Make sure you're running in a Node.js environment with CommonJS support (
.cjsor no"type": "module"inpackage.json).
const { CodeCompiler } = require("ah_code_compiler_sdk");
const compiler = new CodeCompiler();
compiler.help() // Displays a CLI based usage example
// Displays all the supported Runtimes by this SDK
compiler.getRuntimes().then(console.log);
compiler.execute({
language: "python",
version: "3.10.0",
files: [
{
name: "main.py",
content: "print('Successfully Installed! ✅')",
},
],
});
Using ModuleJS (ES6) – Recommended
To enable ES Modules, add
"type": "module"in yourpackage.json:
{
"type": "module"
}import { CodeCompiler } from "ah_code_compiler_sdk";
const compiler = new CodeCompiler();
compiler.help() // Displays a CLI based usage example
// Displays all the supported Runtimes by this SDK
compiler.getRuntimes().then(console.log);
compiler.execute({
language:"python",
files:[{
content:"print('Successfully Installed! ✅')"
}]
})
Try Out the build in CLI Code Editor:
Common JS(ES5):
const { CLIEditor } = require("ah_code_compiler_sdk") const editor = new CLIEditor() editor.start() // Launches the AH CLI Code EditorModule JS(ES6):
import { CLIEditor } from "ah_code_compiler_sdk"; const editor = new CLIEditor() editor.start() // Launches the AH CLI Code Editor
🧠 API Reference
1. new CodeCompiler()
Create an instance of the SDK.
2. sdk.help()
Get help and usage about this SDK and its methods
3. sdk.getRuntimes(): Promise<Runtime[]>
Fetch all supported programming runtimes along with version info.
4. sdk.execute(payload: ExecuteRequest): Promise<ExecuteResponse>
Execute source code in a given language and version.
Payload Structure:
interface ExecuteRequest {
language: string;
version: string;
files: { name: string; content: string }[];
stdin?: string;
}Supported Languages (30+)
This SDK supports 30+ runtimes including popular languages and aliases:
- Python (
python,py,python3) - JavaScript / TypeScript (
javascript,js,typescript,ts) - C / C++ (
c,c++,cpp) - Java, Go, Rust, C#, PHP, Ruby, Kotlin, Swift
- SQL / SQLite (
mysql,sql,sqlite3) - Bash, Haskell, Lua, Perl, Dart, Elixir, and many more esoteric languages
Use sdk.getRuntimes() to dynamically fetch the full, up-to-date list from the API.
📄 License
MIT License © Akash Halder
