ah_code_compiler_sdk
v1.0.8
Published
A modern, cross-platform code compilation SDK by Akash Halder. Easily integrate online code execution into your web apps, CLIs, or automation workflows using a simple and powerful API.
Maintainers
Readme
An easy-to-use SDK written in Typescript for compiling and executing code. 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
- Execute code in multiple programming languages
- 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
📦 Installation
> npm i ah_code_compiler_sdk
> bun i ah_code_compiler_sdkor
> pnpm add ah_code_compiler_sdk
> yarn add ah_code_compiler_sdkor
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js"></script>
<!-- or -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser/index.global.js"></script>
🚀 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;
}Example Languages Supported
- Python (
python3) - JavaScript (
node) - C++
- Java
- Go
- Rust
- C#
- ...and many more
Use sdk.getRuntimes() to dynamically fetch the latest list.
📄 License
MIT License © Akash Halder
