Logo

REST APIs

JDoodle REST API enables users to run code in various programming languages, manage versions, and handle standard input/output seamlessly

Here are a few features of our REST APIs:

  • Allows running code in various programming languages without needing a local development environment.
  • Supports running code on different versions of programming languages.
  • Enables handling of standard input and output for interactive programs.
  • Manages and monitors API usage through a credit consumption model.
  • Ensures secure API usage by requiring an authentication token for all requests.

You could also import our Postman collection: Run In Postman

Authentication

You must include your Client ID and Client Secret in the request payload to authenticate your API requests. You do not need to obtain an authentication token.

Parameters

ParameterDescriptionTypeRequired
clientIdYour Client IDStringYes
clientSecretYour Client SecretStringYes

Execute endpoint

You can run or compile code using JDoodle API through the execute endpoint.

EndpointDescriptionMethod

Input parameters

ParameterDescriptionTypeRequired
clientIdYour Client IDStringYes
clientSecretYour Client SecretStringYes
scriptProgram to compile and/or executeStringYes
stdinStandard InputStringNo
languageLanguage of the scriptStringYes
versionIndexVersion index of the languageStringYes
compileOnlyCompile without executing (True/False)BooleanNo

Example request

curl -L \
  -X POST \
  -H 'Content-Type: application/json' \
  'https://api.jdoodle.com/v1/execute' \
  -d '{"clientId":"your_client_id_here","clientSecret":"your_client_secret_here","script":"print(\"Hello, World!\")","stdin":"","language":"python3","versionIndex":"0","compileOnly":False}'

Success response

FieldDescriptionType

Success response example

{
    "output": "sum of x+y = 35",
    "error": None,
    "statusCode": 200,
    "memory": "8192",
    "cpuTime": "0.01",
    "compilationStatus": None,
    "projectKey": None,
    "isExecutionSuccess": True,
    "isCompiled": True
}

Client libraries

JDoodle does not directly provide client libraries for their APIs. However, using the Swagger editor, you can generate client libraries in various programming languages.

Steps to generate client libraries

  1. Go to the Swagger Editor.
  2. Copy and paste the provided JSON API description into the editor.
  3. Click on “generate client” and select the desired programming language.

Example Swagger JSON for JDoodle API

{
    "swagger": "2.0",
    "info": {
        "description": "JDoodle Compiler API",
        "version": "1.0.0",
        "title": "JDoodle Compiler API",
        "termsOfService": "https://www.jdoodle.com/terms",
        "contact": {
            "email": "jdoodle@nutpan.com"
        }
    },
    "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 check credit usage",
                "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": "Number of credits used today"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized"
                    }
                }
            }
        }
    },
    "externalDocs": {
        "description": "Find out more about JDoodle Compiler API",
        "Url": "https://www.jdoodle.com/docs/jdoodle-apis/introduction-to-compiler-apis"
    }
}