WebSocket API
Documentation for https://www.jdoodle.com/compiler-api/
How WebSocket API is different from the REST API
REST API does not support interactive program execution - you have to send all the required input along with the program which is good for some use cases (similar to the non-interactive mode in JDoodle.com). With Websocket API, you can provide an interactive experience to the user like they run a program in their local machine (similar to interactive mode in JDoodle).
How can I make a Websocket call?
Running a WebSocket API is a two-step process.
Get auth token from JDoodle by passing by calling https://api.jdoodle.com/v1/auth-token endpoint with your Client ID/Secret. The token is valid for 180 seconds. You need to make this call from your server to JDoodle.
Using the token you received in step 1, will call WebSocket Endpoint from the browser to provide an interactive experience to the user.
WebSocket call flow
Input Parameters for the "get-token" 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
The response contains the token in the body.
Output Parameters for the "credit-spent" API call when the execution failed
Parameter | Description |
error | error message |
statusCode | Status Code of the result |
Integrating WebSocket requests to your Website
Below is a sample implementation of WebSocket in a standalone HTML file. This is pretty much self-explanatory. You have to replace the token with the token you receive in the "auth-token" request.
More details on languages, versions, credit-spent, etc
Please refer our REST API documentation.
Where can I find help and support?
For any help, doubts, suggestions, etc. Please get in touch with us at hello@jdoodle.com
Last updated