canonical: https://jentic.com/apis/hackerearth.com/hackerearth

# HackerEarth Code Evaluation API

Jentic publishes the only available OpenAPI specification for HackerEarth Code Evaluation API, keeping it validated and agent-ready. The HackerEarth Code Evaluation API v4 compiles and executes source code in 30+ programming languages and returns the run output, runtime, memory usage, and compilation status. Agents submit a code string with the target language, runtime input, and resource limits, then poll for a result by submission id. It is widely used as a remote sandbox for online judges, coding interview platforms, and AI-generated code validation.

## For AI agents

Submit source code in 30+ languages for compilation and execution and retrieve output, runtime, memory, and status by submission id.

## Scope

Does not handle interview workflow, candidate scoring, or test case management - use for raw code compilation and execution only.

## Capabilities

- Submit source code in over 30 languages including Python, Java, C++, Go, and Rust for compilation
- Run user-supplied stdin against submitted code in a sandboxed environment
- Configure per-submission CPU time and memory limits
- Poll a submission by id to retrieve compile status, run output, and resource metrics
- Receive results asynchronously by configuring a callback URL on the submission

## Use cases

### AI-Generated Code Validation

Use HackerEarth as the execution sandbox for code an LLM has just written. The agent posts the generated source plus a test input to `/code-evaluation/submissions`, polls `/code-evaluation/submissions/{id}` for completion, and verifies the output matches the expected value before showing it to the user. This is the standard pattern for code-writing agents that want to avoid running untrusted code locally.

Example prompt: POST a Python solution that reads stdin and prints its sum to `/code-evaluation/submissions`, poll `/code-evaluation/submissions/{id}` until status is COMPLETED, and confirm the output equals the expected total.

### Online Judge for a Learning Platform

Power a coursework grading flow that runs student submissions against hidden test cases. The platform sends each submission to HackerEarth with strict time and memory limits, collects per-test output, and assigns a verdict (accepted, wrong answer, time limit, runtime error). The two-endpoint design keeps the integration small.

Example prompt: Submit a student's C++ solution with a 1-second time limit and 256 MB memory limit, and report the verdict based on the returned status field.

### Interview Coding Sandbox

Provide a remote run-button inside an interview platform so candidates can execute code against sample inputs in real time. The platform calls `/code-evaluation/submissions` on each click, awaits completion, and streams output back to the candidate's editor. The async callback mode avoids blocking polling loops.

Example prompt: POST the candidate's current editor buffer with stdin from the sample test, then GET `/code-evaluation/submissions/{id}` until completion and stream the output back to the UI.

### Agent Discovery Through Jentic

AI coding agents discover the HackerEarth submit and result-fetch operations by searching Jentic with intents like 'execute this python code'. Jentic returns the matching operation with its input schema and the agent posts the source. Credentials stay isolated in your Jentic One instance.

Example prompt: Use Jentic search 'execute python code' to find the HackerEarth submit operation, execute it with a Python source string, and poll the result endpoint until status is COMPLETED.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/code-evaluation/submissions` | Submit source code for compilation and execution |
| GET | `/code-evaluation/submissions/{id}` | Fetch the result of a code submission by id |

## Key resources

- **Submissions** — Create a new code submission with source, language, stdin, and resource limits
- **Submission result** — Fetch a submission by id to read compile status, run output, runtime, and memory usage

## Why Jentic

- **Setup:** Wiring the HackerEarth Code Evaluation API by hand means setting its client-secret header, submitting code to one endpoint, then polling a second endpoint by submission id yourself. Through Jentic you install once, import the HackerEarth Code Evaluation API from the API Directory, store the client secret once, and your agent calls it.
- **Permission scoping:** The HackerEarth Code Evaluation API only submits code and reads back a result by id, so scope your agent to the operations it needs, such as creating a submission and fetching its status. You choose which of the two operations it may call.
- **Credential handling:** Your HackerEarth client-secret partner 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 'execute python code' or 'poll a code submission result', and Jentic returns the HackerEarth submit and status operations with their input schemas so the agent calls the right endpoint without browsing the partner docs.

## Related APIs

- **GitHub API** — Pull source from a GitHub repo and run it in HackerEarth.
- **HackerRank for Work API** — Hiring-focused platform with built-in tests and candidate workflow.
- **Codeforces API** — Competitive programming archive of problems to run against the sandbox.

## FAQ

### Why is there no official OpenAPI spec for HackerEarth Code Evaluation API?

HackerEarth does not publish an OpenAPI specification. Jentic generates and maintains this spec so that AI agents and developers can call HackerEarth Code Evaluation API via structured tooling. It is validated against the live API and kept up to date. Get started with Jentic One, the self-hosted execution layer.

### What authentication does the HackerEarth Code Evaluation API use?

Requests must include a client-secret header containing the partner key issued from the HackerEarth developer dashboard. Through Jentic, this secret is stored encrypted in the vault and injected at execution time so the agent never sees the raw key.

### Which languages does the HackerEarth Code Evaluation API support?

The v4 API supports over 30 languages including Python 2 and 3, Java, C, C++, C#, Go, Rust, Kotlin, Ruby, JavaScript (Node), TypeScript, PHP, Swift, Scala, and Haskell. The exact identifier list is documented in the HackerEarth language reference and passed in the lang field of the submission body.

### How do I submit code and read the result?

POST to `/code-evaluation/submissions` with the source, lang, input, time_limit, and memory_limit fields. The response returns a submission id. Poll GET `/code-evaluation/submissions/{id}` until the status field reads COMPLETED, then read the output, time_used, and memory_used fields. To avoid polling, supply a callback URL in the submission body.

### What are the rate limits for the HackerEarth Code Evaluation API?

Limits are tied to the partner plan associated with the client-secret. Free trial keys are heavily throttled while paid partner plans receive higher concurrent execution allowances. Check the response headers and your dashboard for current usage versus quota.

### How do I use HackerEarth code execution with AI agents through Jentic?

Run pip install jentic, search 'execute python code', and Jentic returns the HackerEarth POST `/code-evaluation/submissions` operation. Execute it with the source, then call the GET `/code-evaluation/submissions/{id}` operation until completion.

### Can I limit what my agent is allowed to do with the HackerEarth Code Evaluation API?

Yes. Because Jentic One is self-hosted, you run it and your own rules decide which of this API's operations and credentials the agent may use. This API exposes only two operations, submitting code with POST `/code-evaluation/submissions` and fetching a result by id with GET `/code-evaluation/submissions/{id}`, so you can allow your agent to poll and read existing results while withholding the ability to create new submissions, or grant both. Your HackerEarth client-secret partner key stays with your Jentic One instance and is injected only for the operations you have permitted.
