Public APIs
Hackerearth favicon

Hackerearth

Programming

For compiling and running code in several languages.

Hackerearth's website screenshot

About Hackerearth

HackerEarth API V4 is a code-compilation-and-execution API that lets registered client applications submit source code in a specified programming language for compiling and running, along with optional input data, memory and time limits, and a callback URL. Access requires registering a web application to obtain a client-specific client-secret, which is passed in the request header for authentication. The API operates only asynchronously: a submission returns a temporary response while the request is queued, and results can be retrieved either by polling a getStatus endpoint or by receiving a callback POST once compilation and execution complete.

Requests are made via a single POST endpoint that handles both compilation and execution in one call, differing from the prior v3 API, which required two separate endpoint calls and supported both synchronous and asynchronous modes. Parameters include the language, source code, optional input, memory limit (up to 262144 KB), time limit (up to 5 seconds), a context string for passing client-side identifiers, and an optional callback URL that is invoked after compilation and again after execution, with up to 3 retries and 5 redirects supported. Responses include status codes such as REQUEST_INITIATED, REQUEST_QUEUED, CODE_COMPILED, REQUEST_COMPLETED, and REQUEST_FAILED, along with execution details like memory used, time used, exit code, and output.

This is aimed at developers building applications that need to compile and run user-submitted code, such as online coding platforms, judges, or educational tools, and who need programmatic access to execution results including compile status and runtime metrics.

Key features

  • Asynchronous code compilation and execution via a single API endpoint
  • Supports multiple programming languages
  • Callback URL support to receive compilation and execution results without polling
  • getStatus/reconciliation endpoint to check status of any previous code-evaluation request
  • Configurable memory limit (up to 256 MB) and time limit (up to 5 seconds) per submission
  • Client-secret header-based authentication for registered applications

Frequently asked questions

Is there a free tier?

Yes, there is a cap on the number of free requests a user can make, along with a cap on the number of clients a user can register.

How do I authenticate with the API?

You register your web application to receive a unique client-secret, which is then passed in the request header under the key client-secret.

Does the API support synchronous requests?

No, API v4 only supports asynchronous code evaluation requests, unlike v3 which supported both synchronous and asynchronous.

How do I get the results of my code evaluation?

You can either poll the getStatus endpoint or provide a callback URL in the request to receive a POST with compilation and execution results.

What is the request content type and format?

Requests must be sent as application/json with fields like lang, source, input, memory_limit, time_limit, context, and callback.

Advertise here

Featured products

  • SerpApi - Search API favicon
  • Screenshot Scout favicon
  • TalorData favicon
  • CoreClaw favicon

Show your product to thousands of developers

· 100k monthly pageviews
· 7k newsletter subscribers

Advertise your product