Documentation

Everything you need to integrate Monaco into your institution's assessment workflow.

Quick Start

Start executing code through the API in minutes. Here's a complete example:

Step 1: Submit Code

Send a POST request to submit your code for execution:

javascript
const response = await fetch('https://api.ishikabhoyar.tech/api/submit', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    language: 'python',
    code: 'print("Hello, Monaco!")',
    input: ''  // Optional stdin input
  })
});

const { id } = await response.json();
console.log('Execution ID:', id);

Step 2: Connect to WebSocket

Connect to the WebSocket endpoint for real-time output:

javascript
const ws = new WebSocket(`wss://api.ishikabhoyar.tech/api/ws/terminal/${id}`);

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  
  switch (msg.type) {
    case 'output':
      console.log(msg.content.text);
      break;
    case 'status':
      if (msg.content === 'completed') {
        console.log('Execution finished!');
        ws.close();
      }
      break;
    case 'error':
      console.error(msg.content);
      break;
  }
};

Alternative: Polling for Results

If you prefer REST over WebSocket, you can poll for results:

javascript
// Check status
const statusRes = await fetch(`https://api.ishikabhoyar.tech/api/status/${id}`);
const { status } = await statusRes.json();
// status: "queued" | "running" | "completed" | "failed"

// Get result when completed
const resultRes = await fetch(`https://api.ishikabhoyar.tech/api/result/${id}`);
const result = await resultRes.json();
console.log(result.output);

Pro Tip

Use WebSocket for interactive programs that require user input. Send input via the WebSocket with {type: 'input', content: 'your input'}