Search…
Compiler API

Introduction

JDoodle Compiler API is a REST API service. It supports Java, C/C++, PHP, Perl, Python, Ruby and many more languages.

Can I call this API directly from a web page?

This API is meant for a server-to-server call and is protected with a client ID and Client Secret. If you make calls directly from a web page, then the client ID and Secret will be exposed in the page which is not secure, and we request you not to do that. The best way is to direct the request from your webpage to your own server and call JDoodle API from your server.
Alternatively, you can try our IDE Plugin or contact us for a custom version or Websocket-based API.

Is Websocket supported?

We offer Websocket as part of custom plans. Please contact us for more details.

What is the request endpoint for compiler API?

https://api.jdoodle.com/v1/execute (only POST method supported with Content-Type: application/json)

What is the request endpoint to check my today's usage?

https://api.jdoodle.com/v1/credit-spent (only POST method supported with Content-Type: application/json)

What subscription options are available?

We have multiple plans including a Free plan. Please refer compiler API home page for current Plans. Please contact us if you need a custom version.

Is plan costs in USD?

All the costs mentioned are in USD.

Can I change from one plan to another plan?

Yes. If you are upgrading from a lower volume plan to an upper volume plan, your change will be immediate. If you are moving from an upper volume plan to a lower volume plan, your change will be effective from the end of your current billing period.

What is the billing period and when my credit card is charged?

When you subscribe to a paid plan for the first time, you are paying for the plan and your billing period starts from that date. Your credit card will be charged every month on that day. For example, if you subscribe for a paid plan on the 5th of November, your billing period is the 5th of every month, and you will be charged on the 5th of every month.

How is the cost calculated when I move from a lower volume plan to an upper volume plan, and when I will be charged (upgrade)?

You are always charged only on your billing date, that is at the end of the current billing period. If you move to an upper volume plan, the cost is calculated on prorate basis and the additional cost for the current billing period will be included in the next payment. For example, if your billing period starts on the 1st of April and your current plan is $10 per month, and if you are moving to the $20 plan on the 16th of April. Your next bill will be calculated approximately like = (usage on current plan $10 on prorate from 1st to 15th) $5 + (usage on new plan $20 for 16th to 30th on prorate basis) $10 + (next billing period cost for 1st May to 31st May) $20 - (Amount you have already paid for 1st to 30th April) $10 = $25.

How is the cost calculated when I move from an upper volume plan to a lower volume plan (downgrade)?

When you are moving from an upper volume plan to a lower volume plan, the change is effective only from the start of your next billing period, so you will be charged for the new plan from the start of the new billing period. You can continue using your current plan until the end of the current billing period, and no refund will be provided.

What happens when I cancel my subscription?

The cancellation will be processed immediately If you are on the Free plan. If you are on a Paid plan, your subscription will be cancelled at the end of your current billing period, you can use your plan until the end of the current billing period, and no refund will be provided.

Can I reactivate my subscription?

If you have cancelled, you can reactivate any time until your current billing period ends. If the end of the billing period is already reached, you have to subscribe again.

Is My Credit Card Details safe?

We use Stripe for all Credit Card processing, and we are not storing or handling your Credit Card details in our systems.

Input Parameters for the execute API call

Parameter
Description
clientId
Client ID for your subscription
clientSecret
Client Secret for your subscription
script
program to compile and execute
stdin
StdIn
language
language of the script (refer the supported language list below)
versionIndex
version of the language to be used (refere the supportoed languages and versions in list below)

Output Parameters for the execute API call when the execution is successful

Parameter
Description
output
Output of the program
statusCode
Status Code of the result
memory
Memory used by the program
cpuTime
CPU Time used by the program

Output Parameters for the execute API call when the execution failed

Parameter
Description
error
error message
statusCode
Status Code of the result

Input Parameters for the "credit-spent" API call

Parameter
Description
clientId
Client ID for your subscription
clientSecret
Client Secret for your subscription

Output Parameters for the "credit-spent" API call when the execution is successful

Parameter
Description
used
No of credits used today

Output Parameters for the "credit-spent" API call when the execution failed

Parameter
Description
error
error message
statusCode
Status Code of the result

Language Codes and Version Index

Please refer - Language Codes and Versions

Java Example for the Execute API Call

The below is a quick and dirty Java example, but please use your favourite rest API client and JSON Java libraries for clean code for production use.
package com.jdoodle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class APITest {
public static void main(String args[]) {
String clientId = "YourClientID"; //Replace with your client ID
String clientSecret = "YourClientSecret"; //Replace with your client Secret
String script = "";
String language = "php";
String versionIndex = "0";
try {
URL url = new URL("https://api.jdoodle.com/v1/execute");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
String input = "{\"clientId\": \"" + clientId + "\",\"clientSecret\":\"" + clientSecret + "\",\"script\":\"" + script +
"\",\"language\":\"" + language + "\",\"versionIndex\":\"" + versionIndex + "\"} ";
System.out.println(input);
OutputStream outputStream = connection.getOutputStream();
outputStream.write(input.getBytes());
outputStream.flush();
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Please check your inputs : HTTP error code : "+ connection.getResponseCode());
}
BufferedReader bufferedReader;
bufferedReader = new BufferedReader(new InputStreamReader(
(connection.getInputStream())));
String output;
System.out.println("Output from JDoodle .... \n");
while ((output = bufferedReader.readLine()) != null) {
System.out.println(output);
}
connection.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

NodeJs Example for the Execute API Call

var request = require('request');
var program = {
script : "",
language: "php",
versionIndex: "0",
clientId: "YourClientID",
clientSecret:"YourClientSecret"
};
request({
url: 'https://api.jdoodle.com/v1/execute',
method: "POST",
json: program
},
function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body);
})

Curl Example for the execute API Call

The below is a curl example (note: may need slight syntax change in windows)
curl -H "Content-Type: application/json; charset=UTF-8" -X POST -d '{"clientId": "YourClientId","clientSecret":"YourClientSecret","script":"","language":"php","versionIndex":"0"}' https://api.jdoodle.com/v1/execute

Curl Example for the "credit-spent" API Call

The below is a curl example (note: may need slight syntax change in windows)
curl -H "Content-Type: application/json; charset=UTF-8" -X POST -d '{"clientId": "YourClientId","clientSecret":"YourClientSecret"}' https:

Postman Examples

Right-click the below JSON file and save it in your system, then import the file to your postman and change the clientId and clientSecret for a quick start.
jdoodle_api_postman.json
2KB
Code
Select "Raw" type and "JSON"
Content Type should be application/json

Do you have any client libraries for these APIs?

We don't provide API client libraries, but you can generate client libraries in so many different languages using http://editor.swagger.io/ and the below JSON API Description. Simply go to http://editor.swagger.io/, copy paste the below JSON into the editor, click on Generate Client and select the language.
{
"swagger": "2.0",
"info": {
"description": "JDoodle Compiler API",
"version": "1.0.0",
"title": "JDoodle Compiler API",
"termsOfService": "https://www.jdoodle.com/terms",
"contact": {
"email": "[email protected]"
}
},
"host": "api.jdoodle.com",
"basePath": "/v1",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/execute": {
"post": {
"summary": "Execute Program",
"description": "Endpoint to execute code",
"tags": [
"execute"
],
"parameters": [
{
"name": "execute",
"in": "body",
"description": "the body",
"required": true,
"schema": {
"properties": {
"clientId": {
"type": "string"
},
"clientSecret": {
"type": "string"
},
"script": {
"type": "string"
},
"stdin": {
"type": "string"
},
"language": {
"type": "string"
},
"versionIndex": {
"type": "string"
}
}
}
}
],
"responses": {
"200": {
"description": "Execution success",
"schema": {
"type": "object",
"properties": {
"output": {
"type": "string",
"description": "Output"
},
"statusCode": {
"type": "integer",
"description": "Status Code"
},
"memory": {
"type": "number",
"description": "Memory used"
},
"cpuTime": {
"type": "number",
"description": "CPU Time used"
}
}
},
"401": {
"description": "Unauthorized"
},
"429": {
"description": "Daily limit reached"
}
}
}
},
"/credit-spent": {
"post": {
"summary": "Credit Spent",
"description": "Endpoint to execute code",
"tags": [
"credit-spent"
],
"parameters": [
{
"name": "credit",
"in": "body",
"description": "the body",
"required": true,
"schema": {
"properties": {
"clientId": {
"type": "string"
},
"clientSecret": {
"type": "string"
}
}
}
}
],
"responses": {
"200": {
"description": "Execution success",
"schema": {
"type": "object",
"properties": {
"used": {
"type": "integer",
"description": "No of credits used today"
}
}
}
},
"401": {
"description": "Unauthorized"
}
}
}
}
},
"externalDocs": {
"description": "Find out more about JDoodle Compiler API",
"url": "https://www.jdoodle.com/compiler-api"
}
}

Where can I find help and support?

For any help, doubts, suggestions, etc. Please get in touch with us at [email protected].com