Logo

Multi-file support for APIs

Compiler APIs simplify code management—upload, execute, and save seamlessly.

Multi-file support in compiler APIs enhances the processing and compilation of multiple interconnected source files. The workflow for multi-file compilation involves parsing individual files, analyzing dependencies to determine the correct compilation order, compiling each file considering these dependencies, and finally linking the compiled files to produce the executable or final output.

API usage workflow

  • Scenario 1: Upload project files and execute them at once.

image (13).png

  • Scenario 2: Upload project files, then execute in the next API call.

Screenshot 2024-01-04 at 10.42.00 am (1).png

  • Scenario 3: Upload project files and execute at once, then execute the existing file again.

image (15).png

Multi-file API endpoints

EndpointDescriptionType
Upload and execute project files at onceP
Upload project files for next time executionP
Execute previously uploaded project filesP

Upload and execute at once endpoint

 https://api.jdoodle.com/engine/execute-api-multifile

image (16).png

Input parameters

ParameterTypeRequiredDescription
------ client
YesYour
YesYour
YesProgramming language (e.g., “c99”) version
YesCompiler version index multi
YesSet to
OptionalLibraries to include (e.g., [“pcre”]) main
OptionalStandard input for the program

Example request

curl -L \
  -X POST \
  -H 'Content-Type: application/json' \
  'https://api.jdoodle.com/v1/engine/execute-api-multifile' \
  -d '{"clientId":"your_client_id_here","clientSecret":"your_client_secret_here","language":"c99","versionIndex":5,"multiFile":True,"files":[{"name":"main.c","content":"#include <stdio.h>\nint main() { printf(\"Hello, World!\\n\"); return 0; }"}],"libs":["pcre"],"mainFile":"main.c","args":"","stdin":""}'

Response fields

FieldTypeDescription
stringOutput from the executed program status
integerH
stringMemory used during execution (in kilobytes) cpu
stringC
stringUnique identifier for the uploaded project files

Response example

{
"output": "Pattern matched at offset 0\n",
"statusCode": 200,
"memory": "1920",
"cpuTime": "0.00",
"compilationStatus": None,
"projectKey": "32904e2a-c9be-4d84-a9c3-27b2cc8a2e2a"
}

Note : You can remove the “libs” field if no library is used, and “projectKey” can be used in the next execution API call.

Upload only endpoint

https://api.jdoodle.com/engine/execute-api-multifile-upload-only

image (17).png

Input Parameters

ParameterTypeRequiredDescription
------ client
YesYour
YesYour
YesProgramming language (e.g., “c99”) version
YesCompiler version index multi
YesSet to
YesArray of file objects to upload

Example request

curl -L \
  -X POST \
  -H 'Content-Type: application/json' \
  'https://api.jdoodle.com/v1/engine/execute-api-multifile-upload-only' \
  -d '{"clientId":"your_client_id_here","clientSecret":"your_client_secret_here","language":"c99","versionIndex":5,"multiFile":True,"files":[{"name":"main.c","content":"#include <stdio.h>\nint main() { printf(\"Hello, World!\\n\"); return 0; }"}]}'

Response Fields

FieldTypeDescription
stringUnique identifier for the uploaded project files

Example response

{
"projectKey": "32904e2a-c9be-4d84-a9c3-27b2cc8a2e2a"
}

Execute existing file endpoint

 https://api.jdoodle.com/engine/execute-api-multifile-existing

Input parameters

ParameterTypeRequiredDescription
------ client
YesYour
YesYour
YesProgramming language (e.g., “c99”) version
YesCompiler version index project
YesIdentifier of the previously uploaded project multi
YesSet to
OptionalLibraries to include (e.g., [“pcre”]) main
OptionalStandard input for the program

Example payload

{
"language": "c99",
"versionIndex": 5,
"projectKey": "projectKeyGoesHere", // the one from /execute-api-multifile-upload-only or /execute-api-multifile endpoint
"multiFile": True,
"libs": ["pcre"],
"mainFile": "main.c",
"args": "",
"stdin": "",
"hasInputFiles": False,
"clientId": "clientIdGoesHere",
"clientSecret": "clientIdGoesHere"
}

Response fields

FieldTypeDescription
stringOutput from the executed program status
integerH
stringMemory used during execution (in kilobytes) cpu
stringC

Example response

{
"output": "Pattern matched at offset 0\n",
"statusCode": 200,
"memory": "1664",
"cpuTime": "0.00",
"compilationStatus": None,
"projectKey": None
}