How to use DSA coding lab execution over API?
Learn about using APIs to execute DSA coding labs
The DSA Coding Lab Execution API allows you to programmatically execute code submissions and retrieve results for Data Structures and Algorithms (DSA) problems. This API supports batch operations for efficiency and handles multiple programming languages.
Overview
The API provides two main endpoints that work together:
- Request DSA code execution [batch] - Submit multiple code executions
- Get DSA code execution result [batch] - Retrieve results of submitted executions
Industry Pricing Comparison
Fermion offers the best infrastructure and extremely competitive prices compared to industry standards. For example, consider Judge0’s pricing on RapidAPI vs Fermion’s base plan pricing.
Platform | Cost per Submission | Rate limits |
---|---|---|
Judge0 | $1 per 1,000 submissions | Unknown |
Fermion DSA API | $1 per 5,000 submissions | 10,000 requests per second |
Planning to execute more than 1 million runs per month? Contact our support team for special enterprise pricing and higher rate limits.
Why Choose Fermion over Judge0?
- Better Performance: Optimized specifically for DSA problems
- Batch Operations: Execute multiple problems in a single API call
- Enterprise Support: Dedicated support for high-volume users
- Competitive Pricing: Better rates for volume usage
Fermion’s DSA execution API is a production-ready, enterprise-grade replacement for Judge0 with better performance, reliability, and pricing.
Fermion API Key
You must have a valid Fermion API key to run these coding labs. Create a Fermion account and go to Settings > API access section in your instructor dashboard to get the key.
Supported languages
The API supports the following programming languages:
C
Cpp
(C++)Java
Python
Nodejs
(Node.js)Golang_1_19
(Go)Rust_1_87
(Rust)Dotnet_8
(.NET)Sqlite_3_48_0
(SQLite)
Reach out to Fermion support if you need access to more runtimes than listed here.
Step 1 - Submit Code for Execution
Use the Request DSA code execution [batch] endpoint to submit one or more code executions.
For detailed API specification, request/response schemas, and interactive examples, see the official API documentation: Request DSA code execution [batch]
Special Case: SQLite
For SQLite code execution, you must include a ZIP file containing a db.sqlite
file:
The API returns an array of task IDs in the same order of challenges that you submitted, that you can use to retrieve results later.
Step 2 - Retrieve Execution Results
Use the Get DSA code execution result [batch] endpoint to retrieve results of submitted executions.
For detailed API specification, request/response schemas, and interactive examples, see the official API documentation: Get DSA code execution result [batch]
Using Webhook URLs for Instant Results (Recommended)
Instead of polling for results, it’s recommended to use the
callbackUrlOnExecutionCompletion
parameter in your runConfig
. This
webhook URL will receive a POST request with the execution results
immediately when processing completes, eliminating the need for repeated
polling and providing faster response times.
When using webhook URLs, include the callbackUrlOnExecutionCompletion
in
your execution request
Your webhook endpoint will receive the complete execution result as a POST request body, containing the same data structure as the batch result API response.
Task Status Values
Pending
: Task is queued for executionProcessing
: Task is currently being executedFinished
: Task execution completed
Run Status Values
successful
: Code executed successfullycompilation-error
: Code failed to compiletime-limit-exceeded
: Execution exceeded time limitwrong-answer
: Output doesn’t match expected resultnon-zero-exit-code
: Program exited with non-zero codedied-sigsev
: Segmentation faultdied-sigxfsz
: File size limit exceededdied-sigfpe
: Floating point exceptiondied-sigabrt
: Program abortedinternal-isolate-error
: Internal system errorunknown
: Unknown error occurred
Base64URL Encoding
Base64URL encoding is critical for proper API usage. The DSA execution API requires Base64URL encoding (not standard Base64) for several fields including source code, expected output, stdin input, and file attachments.
Why Base64URL Encoding?
Base64URL encoding is a URL-safe variant of Base64 that:
- Replaces
+
with-
(dash) - Replaces
/
with_
(underscore) - Removes padding
=
characters - Ensures the encoded string is safe for use in URLs and JSON
Using standard Base64 encoding instead of Base64URL will cause API errors or unexpected behavior. Always use Base64URL encoding for the API.
Required Fields
The following fields must be Base64URL encoded:
sourceCodeAsBase64UrlEncoded
- Your source codeexpectedOutputAsBase64UrlEncoded
- Expected program outputstdinStringAsBase64UrlEncoded
- Input data for the programbase64UrlEncodedZip
- ZIP file contents for SQLitestdoutBase64UrlEncoded
- Program output (in responses)stderrBase64UrlEncoded
- Error output (in responses)
Error Handling
The API returns structured error responses:
Always check the status
field in the response and handle errors appropriately in your application.