API Documentation
Complete guide to integrating secure code execution into your application.
Quick Start
Execute code in two simple steps:
- Submit your code to get a job ID
- Poll the status endpoint until execution completes
Authentication
All API requests require authentication using your API key in the X-API-KEY header.
💡 Get your API key from the Dashboard
Submit Code
POST
/api/v1/runner/submitRequest Body
{
"code": "print('Hello, World!')",
"language": "python",
"input": ""
}Supported languages: python, javascript, cpp, java
Response
{
"success": true,
"data": {
"jobId": "694736e4b1f2f3fedab4d30f",
"status": "queued"
}
}Get Status
GET
/api/v1/runner/{jobId}/resultResponse
{
"code": 200,
"success": true,
"message": "job result fetched successfully",
"data": {
"jobId": "695bd82641bcbdea08ee3fbc",
"status": "success",
"language": "cpp",
"stdout": "Hello Neuron",
"stderr": "",
"executionTimeMs": 802,
"queueTimeMs": 132,
"totalTimeMs": 934,
"exitCode": 0,
"sandboxErrorType": null,
"sandboxErrorMessage": "",
"queuedAt": "2026-01-05T15:26:30.796Z",
"startedAt": "2026-01-05T15:26:30.928Z",
"finishedAt": "2026-01-05T15:26:31.73Z"
}
}Poll every 1 second until status is "queued" or "running"
Response Fields
| Field | Type | Description |
|---|---|---|
jobId | string | Unique identifier for the job |
status | string | queued, running, success, failed |
stdout | string | Standard output from execution |
stderr | string | Standard error output |
executionTimeMs | number | Execution time in milliseconds |
queueTimeMs | number | Time spent in queue in milliseconds |
totalTimeMs | number | Total time (queue + execution) in milliseconds |
exitCode | number | Process exit code (0 for success) |
sandboxErrorType | string | null | Error type if failed (TLE, MLE, etc.) |
sandboxErrorMessage | string | Error message if failed |
queuedAt | string | ISO timestamp when job was queued |
startedAt | string | ISO timestamp when execution started |
finishedAt | string | ISO timestamp when execution finished |
Generating API Keys
- Sign in to your account
- Navigate to the Dashboard
- Click "Generate API Key"
- Copy and securely store your key (format:
nr_live_...)
⚠️ You can only have one active API key at a time. Generating a new key will revoke the previous one.
Securing Credentials
- •Never commit API keys to version control
- •Use environment variables (
process.env.NEURON_API_KEY) - •Rotate keys regularly
- •Use server-side API calls only
Rate Limits
To ensure fair usage and system stability, we enforce rate limits on API endpoints:
- Authentication Routes: 10 requests/minute
- Code Submission: 60 requests/minute
Exceeding rate limits will result in
429 Too Many Requests errorsHow Credits Work
Each successful code execution costs 1 credit.
Only successful executions (status = "success") consume credits. Failed runs are free.
Fair Billing Policy
You won't be charged for:
- Time Limit Exceeded (TLE)
- Memory Limit Exceeded (MLE)
- Compilation errors
- Runtime errors
Free Credits
200 Free Credits
Every new account starts with 200 free credits (100 normally, 200 for early users)
- No credit card required to start
- Perfect for testing and small projects
- View remaining balance in Dashboard
- Credits never expire during beta
Code Limitations
All code executions run in isolated Docker containers with these limits:
- Execution Time: 3 seconds maximum
- Memory: 256MB maximum
- Network Access: Disabled for security
Error Types
| Error Type | Description | Charged? |
|---|---|---|
TLE | Time Limit Exceeded: the program ran longer than allowed | No |
MLE | Memory Limit Exceeded: the program used more memory than allowed | No |
CompilationError | Compilation failed. See error details | No |
RuntimeError | Runtime Error: the program crashed during execution | No |
SandboxError | Sandbox Error: execution environment failed | No |
InternalError | Internal Error: something went wrong on the server | No |
Troubleshooting
Invalid API Key Error
Check that:
- Your API key starts with
nr_live_ - You're using the
X-API-KEYheader - The key hasn't been revoked
Code Takes Too Long
- Optimize your code for efficiency
- Avoid infinite loops
- Time limit is 3 seconds per execution
Dashboard
Track all your API activity:
- View execution history
- Monitor credit usage and balance
- See execution times and success rates
- Filter by language, status, date
Complete Example
// Submit code
const res = await fetch('https://api.neuron-labs.xyz/api/v1/runner/submit', {
method: 'POST',
headers: {
'X-API-KEY': 'nr_live_...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
code: 'print("Hello")',
language: 'python',
input: ''
})
});
const { data: { jobId } } = await res.json();
// Poll for results
const poll = async () => {
const statusRes = await fetch(
`https://api.neuron-labs.xyz/api/v1/runner/${jobId}/result`,
{ headers: { 'X-API-KEY': 'nr_live_...' } }
);
const { data } = await statusRes.json();
if (data.status === 'queued' || data.status === 'running') {
setTimeout(poll, 1000);
} else {
console.log('Output:', data.stdout);
}
};
poll();Best Practices
- ✓Always use HTTPS in production
- ✓Store API keys in environment variables
- ✓Make API calls from backend only
- ✓Implement rate limiting
- ✓Validate user input before sending
- ✓Handle errors gracefully