canonical: https://jentic.com/apis/api.jdoodle.com/jdoodle

# JDoodle Compiler API

The JDoodle Compiler API runs source code in a hosted sandbox across more than 70 programming languages, returning the program output, CPU time, and memory used. Agents send a code string with the language identifier, version index, and optional stdin to POST /execute and receive the run result without provisioning runtimes locally. A second endpoint returns the daily compile credit balance so callers can budget against the account quota.

## For AI agents

Compile and execute code snippets in over 70 languages and check remaining daily credit usage - without managing local runtimes.

## Scope

Does not handle file system persistence between runs, package installation, long-running services, or interactive debugging - use for one-shot code execution and credit checks only.

## Capabilities

- Execute code in 70+ supported languages including Python, Java, C++, Go, and Rust
- Pass standard input to a program run so test fixtures and sample inputs can be supplied
- Pin a specific language version index for reproducible runs across requests
- Return CPU time and memory consumed alongside the program output
- Check the remaining daily compile credit usage on the account

## Use cases

### In-Product Code Execution

Embed runnable code snippets in documentation, tutorials, or LMS quizzes by sending the source to POST /execute and rendering the response inline. JDoodle handles compilation and runtime isolation, so the calling app does not need to maintain Docker images per language. Latency is typically sub-second for short scripts, which is acceptable for interactive learning experiences.

Example prompt: Call POST /execute with language 'python3', versionIndex '4', and the script 'print(sum(range(11)))', then return the output and CPU time.

### Automated Code Sample Validation

Validate code samples in documentation pull requests by running each snippet against expected output before merge. CI scripts post each sample to /execute, compare the response to the expected stdout, and fail the build on mismatch. This keeps a body of tutorial code permanently green without provisioning a CI matrix per language.

Example prompt: Call POST /execute for each snippet in docs/, capture the output, and fail the job when the output does not match the expected fixture.

### Credit Usage Monitoring

Track remaining daily compile credits to stay inside the JDoodle plan limit. POST /credit-spent returns the count of credits used so far in the current billing day; an agent can subtract this from the plan cap and surface a warning when the remaining budget is low. Useful for product teams that expose JDoodle to end-users.

Example prompt: Call POST /credit-spent and return the current spend; if it exceeds 90% of the daily cap, raise an alert to the operations channel.

### AI Agent Code Execution Tool

An LLM-powered agent that writes code can use JDoodle through Jentic to run the snippet in a sandbox before presenting it to the user. Jentic exposes /execute as a discoverable tool so the agent picks it by intent - for instance 'run this Python code'. The clientId/clientSecret stay in your Jentic One instance.

Example prompt: Search for 'execute a code snippet', load the POST /execute schema, and run the agent's generated Python solution to verify it produces the expected output before returning it to the user.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/execute` | Compile and execute a code snippet |
| POST | `/credit-spent` | Check today's compile credit usage |

## Key resources

- **Execute** — Compile and run a code snippet in a chosen language
- **Credits** — Check daily compile credit usage on the account

## Why Jentic

- **Setup:** Wiring the JDoodle Compiler API by hand means setting up its API key auth and coding your own calls to the execute and credit-spent endpoints. Through Jentic you install once, import the JDoodle Compiler API from the API Directory, store the key once, and your agent calls it.
- **Permission scoping:** JDoodle code and language inputs travel in the request body rather than as ids in the URL path, so limit the agent to the operations it needs: you can allow the credit-spent check on its own or add execute when the agent must run code. Every operation you grant is your explicit choice.
- **Credential handling:** Your JDoodle API key is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'run a code snippet' or 'check remaining execution credits', and Jentic returns the matching JDoodle operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Judge0 API** — Judge0 is a self-hostable code execution engine; JDoodle is a managed SaaS with first-party language packs
- **HackerEarth Compiler API** — HackerEarth's compiler API is similar in scope; JDoodle covers a broader set of languages and exposes credit usage
- **HackerRank API** — HackerRank focuses on coding interviews and assessments; JDoodle is for raw code execution

## FAQ

### What authentication does the JDoodle Compiler API use?

JDoodle uses a clientId and clientSecret pair, sent as fields inside the JSON body of each /execute and /credit-spent request rather than as a header. Through Jentic, both values are stored encrypted in your Jentic One instance and merged into the request payload at execution time.

### Which languages can I run with the JDoodle Compiler API?

JDoodle supports 70+ languages including Python (python3, python2), Java, C, C++, C#, Go, Rust, Node.js, Ruby, PHP, Kotlin, Swift, Scala, Haskell, R, and many others. Each language exposes one or more versionIndex values that pin the compiler or runtime version.

### What are the rate limits and credit caps for the JDoodle API?

Each plan ships with a daily compile credit cap; the free tier is small (around 200 credits per day at time of writing) and paid tiers scale higher. Use POST /credit-spent to see current spend. There is no per-second rate limit in the spec, but throttle aggressive bursts to avoid 429 responses.

### How do I run a code snippet in Python through Jentic?

Run pip install jentic, search for 'execute a code snippet', and Jentic returns the POST /execute operation. Load its schema, pass language='python3', versionIndex='4' (or your pinned version), the script string, and any stdin, then execute the call to receive the program output.

### Is the JDoodle Compiler API free?

JDoodle has a free plan with a small daily credit cap and paid plans that scale credits and concurrency. Pricing is published on jdoodle.com. Each /execute call consumes one credit; /credit-spent itself is free and does not affect the daily count.

### Can I pass standard input to my code with the JDoodle API?

Yes. POST /execute accepts a stdin field as part of the JSON body. Anything you place there is fed to the program as standard input, which is essential for sample-input style problems and for testing programs that call input() or read from stdin.

### Can I limit what my agent is allowed to do with the JDoodle Compiler API?

Yes. Because you run Jentic One yourself, your own rules decide which JDoodle operations the agent may call, and this API exposes only two: POST /execute to compile and run code and POST /credit-spent to read the daily credit usage. If the agent only needs to monitor quota, grant it credit-spent alone and add execute solely when it must actually run code. Since the language, version, and code string all travel in the request body rather than in the URL path, scoping is done at the operation level with the credentials your instance injects at call time.
