Overview

Introduction

This document describes Sphere Engine Compilers webservice. It is explained in here how the methods should be used and how to interpret data returned by them. All URLs referenced in the documentation have the base http://<endpoint>/api/v3/. One of available access tokens is <access_token>.

Functionality

Sphere Engine Compilers API is designed for:

  • uploading a source code of the program,
  • executing the program using various compilers,
  • executing programs with input data,
  • fetching results of the execution, including:
    • generated output,
    • standard error,
    • compilation information,
    • execution time,
    • consumed memory.

The webservice

All API URLs listed in this document are relative to the http://<endpoint>/api/v3/ link called an endpoint. For example, the /test API call is reachable at http://<endpoint>/api/v3/test?access_token=<access_token>.

The Sphere Engine Compilers API is a RESTful API. This implies the following:

  • API calls should be made with HTTP requests (GET, POST, etc.),
  • successes are represented by the 2xx codes,
  • errors are represented by 4xx and 5xx codes,
  • error code from 4xx group represents client errors,
  • error code from 5xx group represents connection or server error.

Requests

Request data is passed to the API by posting parameters to the API endpoints. To communicate with API endpoint you can use any HTTP client/library. Each function takes at least one parameters - access_token. For every GET and DELETE request parameters have to be submitted in the query (i.e. url). For POST and PUT request you can send parameters in the two possible ways:

  • as a FORM (i.e. Content-Type: application/x-www-form-urlencoded)
  • as a JSON (i.e. Content-Type: application/json)

The documentation for each API call will contain more details on the parameters accepted by the call.

Responses

Each response has two components: Http Status Code and JSON-encoded message.

The RESTful API uses HTTP response code to communicate the success or error. Here is the general list of possible codes for Sphere Engine Compilers API.

Value Interpretation
200 success
201 success (for creation methods)
400 bad request (invalid parameters)
401 unauthorized access (missing or incorrect access token)
403 forbidden access (referring to foreign or secured content)
404 non existing content (submission or compiler)
5xx server side problem

Status and result

Variables status and result returned with submission details (i.e. using GET /submissions/:id API method) require further explanation.

Status specifies stage of program's execution. It's values should be interpreted in the following way:

Value Name Description
< 0 waiting for compilation the submission awaits execution in the queue
0 finished the program has finished
1 compilation the program is being compiled
3 running the program is being executed

It's a common practice to implement the following scenario for waiting for execution:

  1. submit source code,
  2. wait 5 seconds,
  3. retrieve submission details,
  4. (optional) present current status to the user,
  5. if the status <> 0 go back to step (2),
  6. (optional) present all execution details to the user.

The following diagram presents the idea of this algorithm (click to enlarge): Submission pooling ilustration

When the submission's status is 0 you can find out how the program has finished by checking the result variable.

Value Name Description
11 compilation error the program could not be executed due to compilation error
12 runtime error the program finished because of the runtime error, for example: division by zero, array index out of bounds, uncaught exception
13 time limit exceeded the program didn't stop before the time limit
15 success everything went ok
17 memory limit exceeded the program tried to use more memory than it is allowed to
19 illegal system call the program tried to call illegal system function
20 internal error some problem occurred on Sphere Engine; try to submit the program again and if that fails too, then please contact us

Binary data

The output data produced by a program doesn't need to be a text file (i.e. human readable string). If the output stream is a binary file then the response for the submission details API method call contains url to the raw output stream.

If the output data is an image (png, jpg, gif, bmp) then this information is reflected in the API response (see. output_type field).

Client libraries

There are client libraries available for the following programming languages:

For every API method there is an example of calling this method from the client library.

GET /test?access_token=<access_token>
For testing purposes. Returns the same data every time it is called (if wrong token is provided, then AUTH_ERROR error code is returned).

Parameters:

Name Type Located in Description
access_token* string query access token

Response HTTP Code:

Code Description
200 success
401 unauthorized access

Success Response:

Field Type Description
moreHelp string hints where to find more information
pi float approximate value of π
answerToLifeAndEverything integer as far as we know it's 42
oOok boolean boolean field

Response example:

{
    "moreHelp": "For more help please log in to Sphere Engine and go to Compilers -> API Documentation.",
    "pi": 3.14,
    "answerToLifeAndEverything": 42,
    "oOok": true
}

Examples

curl -X GET -H 'Content-Type: application/json' 'http://<endpoint>/api/v3/test?access_token=<access_token>'
	
package compilers;
/**
 * Example presents usage of the successful test() API method  
 */

import javax.ws.rs.NotAuthorizedException;

import com.SphereEngine.Api.CompilersClientV3;
import com.google.gson.JsonObject;

public class testErrorHandling
{

	public static void main(String[] args) 
	{
		CompilersClientV3 client = new CompilersClientV3(
				"<access_token>", 
				"<endpoint>");
		
		try {
			JsonObject response = client.test();
		} catch (NotAuthorizedException e) {
			System.out.println("Invalid access token");
		}
	}	
}
<?php
/**
 * Example presents usage of the successful test() API method  
 */

use SphereEngine\Api\CompilersClientV3;
use SphereEngine\Api\SphereEngineResponseException;

// require library
require_once('../../autoload.php');

// define access parameters
$accessToken = '<access_token>';
$endpoint = '<endpoint>';

// initialization
$client = new CompilersClientV3($accessToken, $endpoint);

// API usage
try {
    $response = $client->test();
} catch (SphereEngineResponseException $e) {
	if ($e->getCode() == 401) {
		echo 'Invalid access token';
	}
}
"""
Example presents usage of the successful test() API method
"""
from sphere_engine import CompilersClientV3
from sphere_engine.exceptions import SphereEngineException

# define access parameters
accessToken = '<access_token>'
endpoint = '<endpoint>'

# initialization
client = CompilersClientV3(accessToken, endpoint)

# API usage
try:
    response = client.test()
except SphereEngineException as e:
    if e.code == 401:
        print('Invalid access token')
var request = require('request');

var accessToken = '<access_token>';
var endpoint = '<endpoint>';

request({
    
    url: 'http://' + endpoint + '/api/v3/test?access_token=' + accessToken,
    method: 'GET'
}, function (error, response, body) {
    
    if (error) {
        console.log('Connection problem');
    }
    
    if (response) {
        if (response.statusCode === 200) {
            console.log(JSON.parse(response.body)); // test message in JSON
        } else {
            if (response.statusCode === 401) {
                console.log('Invalid access token');
            }
        }
    }
});
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace csharpexamples
{
	public class test
	{
		public static void Main(string[] args)
		{
			string endpoint = "<endpoint>";
			string accessToken = "<access_token>";

			try {
				WebClient client = new WebClient();

				byte[] responseBytes = client.DownloadData("http://" + endpoint + "/api/v3/test?access_token=" + accessToken);
				string responseBody = Encoding.UTF8.GetString(responseBytes);

				Console.WriteLine(responseBody);

			} catch (WebException exception) {
				WebResponse response = exception.Response;
				HttpStatusCode statusCode = (((HttpWebResponse) response).StatusCode);

				if (statusCode == HttpStatusCode.Unauthorized) {
					Console.WriteLine("Invalid access token");
				}

				response.Close();
			}
		}
	}
}

GET /compilers?access_token=<access_token>
Returns a list of supported compilers.

Parameters:

Name Type Located in Description
access_token* string query access token

Response HTTP Code:

Code Description
200 success
401 unauthorized access

Success Response:

Field Type Description
items[].id integer compiler id
items[].name string compiler name
items[].ver string compiler version
items[].short string short name
items[].ace string syntax highlighting identifier for Ace
items[].geshi string syntax highlighting identifier for Geshi
items[].pygments string syntax highlighting identifier for Pygments
items[].highlighting string syntax highlighting identifier for Highlighting
items[].rouge string syntax highlighting identifier for Rouge
items[].codemirror string syntax highlighting identifier for CodeMirror

Response example:

{
    "items": [
        {
            "id": 1,
            "name": "C++",
            "ver": "gcc 6.3",
            "short": "CPP",
            "ace": "c_cpp", 
            "geshi": "cpp",
            "pygments": "cpp",
            "highlights": "c",
            "rouge": "cpp",
            "codemirror": "clike"
        },
        {
            "id": 116,
            "name": "Python 3",
            "ver": "3.5",
            "short": "PYTHON3",
            "ace": "python",
            "geshi": "python",
            "pygments": "python",
            "highlights": "python",
            "rouge": "python",
            "codemirror": "python"
        }
    ]
}

Examples

curl -X GET -H 'Content-Type: application/json' 'http://<endpoint>/api/v3/compilers?access_token=<access_token>'
	
package compilers;
/**
 * Example presents usage of the successful getCompilers() API method  
 */

import javax.ws.rs.NotAuthorizedException;

import com.SphereEngine.Api.CompilersClientV3;
import com.google.gson.JsonObject;

public class getCompilersErrorHandling
{

	public static void main(String[] args) 
	{
		CompilersClientV3 client = new CompilersClientV3(
				"<access_token>", 
				"<endpoint>");
		
		try {
			JsonObject response = client.getCompilers();
		} catch (NotAuthorizedException e) {
			System.out.println("Invalid access token");
		}
	}	
}
<?php
/**
 * Example presents usage of the successful getCompilers() API method
*/

use SphereEngine\Api\CompilersClientV3;
use SphereEngine\Api\SphereEngineResponseException;

// require library
require_once('../../autoload.php');

// define access parameters
$accessToken = '<access_token>';
$endpoint = '<endpoint>';

// initialization
$client = new CompilersClientV3($accessToken, $endpoint);

// API usage
try {
    $response = $client->getCompilers();
} catch (SphereEngineResponseException $e) {
	if ($e->getCode() == 401) {
		echo 'Invalid access token';
	}
}
"""
Example presents usage of the successful compilers() API method
"""
from sphere_engine import CompilersClientV3
from sphere_engine.exceptions import SphereEngineException

# define access parameters
accessToken = '<access_token>'
endpoint = '<endpoint>'

# initialization
client = CompilersClientV3(accessToken, endpoint)

# API usage
try:
    response = client.compilers()
except SphereEngineException as e:
    if e.code == 401:
        print('Invalid access token')
var request = require('request');

var accessToken = '<access_token>';
var endpoint = '<endpoint>';

request({
    
    url: 'http://' + endpoint + '/api/v3/compilers?access_token=' + accessToken,
    method: 'GET'
}, function (error, response, body) {
    
    if (error) {
        console.log('Connection problem');
    }
    
    if (response) {
        if (response.statusCode === 200) {
            console.log(JSON.parse(response.body)); // list of compilers in JSON
        } else {
            if (response.statusCode === 401) {
                console.log('Invalid access token');
            }
        }
    }
});
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace csharpexamples
{
	public class getCompilers
	{
		public static void Main(string[] args)
		{
			string endpoint = "<endpoint>";
			string accessToken = "<access_token>";

			try {
				WebClient client = new WebClient();

				byte[] responseBytes = client.DownloadData("http://" + endpoint + "/api/v3/compilers?access_token=" + accessToken);
				string responseBody = Encoding.UTF8.GetString(responseBytes);

				Console.WriteLine(responseBody);

			} catch (WebException exception) {
				WebResponse response = exception.Response;
				HttpStatusCode statusCode = (((HttpWebResponse) response).StatusCode);

				if (statusCode == HttpStatusCode.Unauthorized) {
					Console.WriteLine("Invalid access token");
				}

				response.Close();
			}
		}
	}
}

GET /submissions/:id?access_token=<access_token>
Returns information about a submission.

Parameters:

Name Type Located in Description
access_token* string query access token
id* integer path submission id
withSource boolean formData whether source code of the submission should be returned
withInput boolean formData whether input data of the submission should be returned
withOutput boolean formData whether output produced by the program should be returned
withStderr boolean formData whether stderr should be returned
withCmpinfo boolean formData whether compilation information should be returned

Response HTTP Code:

Code Description
200 success
401 unauthorized access
403 access denied
404 submission not found

Success Response:

Field Type Description
time float execution time in seconds
memory integer memory consumed by the program in kilobytes
date string creation date and time (on server); format: yyyy-mm-­dd hh:mm:ss; eg. 2009­-05-­19 02:­34:­56
status integer current status; see section "Status and result"
result integer current result; see section "Status and result"
signal integer signal raised by the program
compiler.id integer compiler id
compiler.name string compiler name
compiler.ver string compiler version
source string source code of the submission; this value is returned if the withSource parameter is set to true
input string input data of the submission; this value is returned if the withInput parameter is set to true
output string output produced by the program or url to raw output stream if the output data is a binary file; this value is returned if the withOutput parameter is set to true
output_type string content type of the output stream; text, image or binary; output stream is recognized as an image only for PNG, JPG, GIF and BMP formats; this value is returned if the withOutput parameter is set to true
stderr string stderr produced by the program; this value is returned if the withStderr parameter is set to true
cmpinfo string compilation information regarding the program; this value is returned if the withCmpinfo parameter is set to true

Response example:

{
    "time": 0.4,
    "memory": 2048,
    "date": "2017-02-24 14:24:21",
    "status": 0,
    "result": 0,
    "signal": 0,
    "compiler": {
        "id": 1,
        "name": "C++",
        "ver": "gcc 6.3"
    }
}

Examples

curl -X GET -H 'Content-Type: application/json' 'http://<endpoint>/api/v3/submissions/:id?access_token=<access_token>'
package compilers.submissions;
/**
 * Example presents error handling for getSubmission() API method
 */

import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.NotFoundException;

import com.SphereEngine.Api.CompilersClientV3;
import com.google.gson.JsonObject;

public class getSubmissionErrorHandling 
{

	public static void main(String[] args) 
	{
		CompilersClientV3 client = new CompilersClientV3(
				"<access_token>", 
				"<endpoint>");
		
		try {
			JsonObject response = client.getSubmission(2016);
		} catch (NotAuthorizedException e) {
			System.out.println("Invalid access token");
		} catch (NotFoundException e) {
			System.out.println("Submission does not exist");
		}
	}	
}
<?php
/**
 * Example presents error handling for getSubmission() API method
*/

use SphereEngine\Api\CompilersClientV3;
use SphereEngine\Api\SphereEngineResponseException;

// require library
require_once('../../../autoload.php');

// define access parameters
$accessToken = '<access_token>';
$endpoint = '<endpoint>';

// initialization
$client = new CompilersClientV3($accessToken, $endpoint);

// API usage
try {
	$nonexisting_submission_id = 999999999;
	$response = $client->getSubmission($nonexisting_submission_id);
} catch (SphereEngineResponseException $e) {
	if ($e->getCode() == 401) {
		echo 'Invalid access token';
	} elseif ($e->getCode() == 404) {
    	echo 'Submission does not exist';
    }
}
"""
Example presents error handling for submissions.get() API method
"""
from sphere_engine import CompilersClientV3
from sphere_engine.exceptions import SphereEngineException

# define access parameters
accessToken = '<access_token>'
endpoint = '<endpoint>'

# initialization
client = CompilersClientV3(accessToken, endpoint)

# API usage
try:
    nonexisting_submission_id = 999999999;
    response = client.submissions.get(nonexisting_submission_id)
except SphereEngineException as e:
    if e.code == 401:
        print('Invalid access token')
    elif e.code == 404:
        print('Submission does not exist')
var request = require('request');

var accessToken = '<access_token>';
var endpoint = '<endpoint>';

var submissionId = 2016;

request({
	
	url: 'http://' + endpoint + '/api/v3/submissions/' + submissionId + '?access_token=' + accessToken,
    method: 'GET'
}, function (error, response, body) {
   
    if (error) {
        console.log('Connection problem');
    }
    
    if (response) {
        if (response.statusCode === 200) {
            console.log(JSON.parse(response.body)); // submission data in JSON
        } else {
            if (response.statusCode === 401) {
                console.log('Invalid access token');
            }
            if (response.statusCode === 403) {
                console.log('Access denied');
            }
            if (response.statusCode === 404) {
                console.log('Submision not found');
            }
        }
    }
});
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace csharpexamples
{
	public class getSubmission
	{
		public static void Main(string[] args)
		{
			string endpoint = "<endpoint>";
			string accessToken = "<access_token>";

			int submissionId = 2016;

			try {
				WebClient client = new WebClient();

				byte[] responseBytes = client.DownloadData("http://" + endpoint + "/api/v3/submissions/" + submissionId + "?access_token=" + accessToken);
				string responseBody = Encoding.UTF8.GetString(responseBytes);

				Console.WriteLine(responseBody);

			} catch (WebException exception) {
				WebResponse response = exception.Response;
				HttpStatusCode statusCode = (((HttpWebResponse) response).StatusCode);

				if (statusCode == HttpStatusCode.Unauthorized) {
					Console.WriteLine("Invalid access token");
				} else if (statusCode == HttpStatusCode.Forbidden) {
					Console.WriteLine("Access denied");
				} else if (statusCode == HttpStatusCode.NotFound) {
					Console.WriteLine("Submission not found");
				}

				response.Close();
			}
		}
	}
}

GET /submissions/:id/:stream?access_token=<access_token>
Returns raw stream data.

Parameters:

Name Type Located in Description
access_token* string query access token
id* integer path submission id
stream* integer path stream name (input, output, stderr, cmpinfo or source)

Response HTTP Code:

Code Description
200 success
401 unauthorized access
403 access denied
404 submission not found | stream not found

Response example:

Raw data from selected stream.

Examples

curl -X GET -H 'Content-Type: application/json' 'http://<endpoint>/api/v3/submissions/:id/output?access_token=<access_token>'
package compilers.submissions;
/**
 * Example presents error handling for getSubmissionStream() API method
 */

import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.NotFoundException;

import com.SphereEngine.Api.CompilersClientV3;
import com.google.gson.JsonObject;

public class getSubmissionStreamErrorHandling 
{

	public static void main(String[] args) 
	{
		CompilersClientV3 client = new CompilersClientV3(
				"<access_token>", 
				"<endpoint>");
		
		try {
			JsonObject response = client.getSubmissionStream(2016, "nonexistingstream");
		} catch (NotAuthorizedException e) {
			System.out.println("Invalid access token");
		} catch (NotFoundException e) {
			// aggregates two possible reasons of 404 error
			// non existing submission or stream
			System.out.println("Non existing resource (submission, stream), details available in the message: " + e.getMessage());
		}
	}	
}
<?php
/**
 * Example presents error handling for getSubmissionStream() API method
*/

use SphereEngine\Api\CompilersClientV3;
use SphereEngine\Api\SphereEngineResponseException;

// require library
require_once('../../../autoload.php');

// define access parameters
$accessToken = '<access_token>';
$endpoint = '<endpoint>';

// initialization
$client = new CompilersClientV3($accessToken, $endpoint);

// API usage
try {
	$nonexisting_submission_id = 999999999;
	$response = $client->getSubmissionStream($nonexisting_submission_id, 'output');
} catch (SphereEngineResponseException $e) {
	if ($e->getCode() == 401) {
		echo 'Invalid access token';
	} elseif ($e->getCode() == 404) {
		// aggregates two possible reasons of 404 error
		// non existing submission or stream
    	echo 'Non existing resource (submission, stream), details available in the message: ' . $e->getMessage();
    }
}
"""
Example presents error handling for submissions.getStream() API method
"""
from sphere_engine import CompilersClientV3
from sphere_engine.exceptions import SphereEngineException

# define access parameters
accessToken = '<access_token>'
endpoint = '<endpoint>'

# initialization
client = CompilersClientV3(accessToken, endpoint)

# API usage
try:
    response = client.submissions.getStream(2016, 'nonexistingstream')
except SphereEngineException as e:
    if e.code == 401:
        print('Invalid access token')
    elif e.code == 404:
        # aggregates two possible reasons of 404 error
        # non existing submission or stream
        print('Non existing resource (submission, stream), details available in the message: ' + str(e))
var request = require('request');

var accessToken = '<access_token>';
var endpoint = '<endpoint>';

var submissionId = 2016;

request({
    
    url: 'http://' + endpoint + '/api/v3/submissions/' + submissionId + '/input?access_token=' + accessToken,
    method: 'GET'
}, function (error, response, body) {
    
    if (error) {
        console.log('Connection problem');
    }
    
    if (response) {
        if (response.statusCode === 200) {
            console.log(response.body); // raw data from selected stream
        } else {
            if (response.statusCode === 401) {
                console.log('Invalid access token');
            }
            if (response.statusCode === 403) {
                console.log('Access denied');
            }
            if (response.statusCode === 404) {
                console.log('Submision or stream not found');
            }
        }
    }
});
POST /submissions?access_token=<access_token>
Creates a new submission. Note that every usage of this method decreases submissions pool for your account.

Parameters:

Name Type Located in Description
access_token* string query access token
source string formData source code to run, default: empty
compilerId integer formData compiler identifier, default: 1 (C++)
input string formData data that will be provided to the program as stdin stream, default: empty

Response HTTP Code:

Code Description
201 success
401 unauthorized access

Success Response:

Field Type Description
id integer id of created submission

Response example:

{
    "id": 42
}

Examples

$ cat request.json
{ 
    "language": 11, 
    "sourceCode": "<source code>" 
}

$ curl -X POST -H 'Content-Type: application/json' -d "`cat request.json`" "http://<endpoint>/api/v3/submissions?access_token=<access_token>"
package compilers.submissions;
/**
 * Example presents usage of the successful createSubmission() API method
*/
import javax.ws.rs.NotAuthorizedException;

import com.SphereEngine.Api.CompilersClientV3;
import com.google.gson.JsonObject;

public class createSubmissionErrorHandling 
{

	public static void main(String[] args) 
	{
		CompilersClientV3 client = new CompilersClientV3(
				"<access_token>", 
				"<endpoint>");
		
		String source = "<source code>";
		Integer compiler = 11; // C language
		String input = "2016";
		
		try {
			JsonObject response = client.createSubmission(source, compiler, input);
			// response.get("id") stores the ID of the created submission
		} catch (NotAuthorizedException e) {
			System.out.println("Invalid access token");
		}
	}	
}
<?php
/**
 * Example presents error handling for createSubmission() API method
*/

use SphereEngine\Api\CompilersClientV3;

// require library
require_once('../../../autoload.php');

// define access parameters
$accessToken = '<access_token>';
$endpoint = '<endpoint>';

// initialization
$client = new CompilersClientV3($accessToken, $endpoint);

// API usage
$source = '<source code>';
$compiler = 11; // C language
$input = '2016';

try {
	$response = $client->createSubmission($source, $compiler, $input);
	// response['id'] stores the ID of the created submission
} catch (SphereEngineResponseException $e) {
	if ($e->getCode() == 401) {
		echo 'Invalid access token';
	}
}
"""
Example presents error handling for submissions.create() API method
"""
from sphere_engine import CompilersClientV3
from sphere_engine.exceptions import SphereEngineException

# define access parameters
accessToken = '<access_token>'
endpoint = '<endpoint>'

# initialization
client = CompilersClientV3(accessToken, endpoint)

# API usage
source = '<source code>'
compiler = 11 # C language
input = '2016'

try:
    response = client.submissions.create(source, compiler, input)
    # response['id'] stores the ID of the created submission
except SphereEngineException as e:
    if e.code == 401:
        print('Invalid access token')
var request = require('request');

var accessToken = '<access_token>';
var endpoint = '<endpoint>';

var submissionData = {
    language: 11,
    sourceCode: '<source_code>'
};

request({
    
    url: 'http://' + endpoint + '/api/v3/submissions?access_token=' + accessToken,
    method: 'POST',
    form: submissionData
}, function (error, response, body) {
    
    if (error) {
        console.log('Connection problem');
    }
    
    if (response) {
        if (response.statusCode === 201) {
            console.log(JSON.parse(response.body)); // submission data in JSON
        } else {
            if (response.statusCode === 401) {
                console.log('Invalid access token');
            }
        }
    }
});
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace csharpexamples
{
	public class createSubmission
	{
		public static void Main(string[] args)
		{
			string endpoint = "<endpoint>";
			string accessToken = "<access_token>";

			try {
				WebClient client = new WebClient ();

				NameValueCollection formData = new NameValueCollection ();
				formData.Add("source", "<source_code>");
				formData.Add("compilerId", "11");

				byte[] responseBytes = client.UploadValues ("http://" + endpoint + "/api/v3/submissions?access_token=" + accessToken, "POST", formData);
				string responseBody = Encoding.UTF8.GetString(responseBytes);

				Console.WriteLine(responseBody);

			} catch (WebException exception) {
				WebResponse response = exception.Response;
				HttpStatusCode statusCode = (((HttpWebResponse)response).StatusCode);

				if (statusCode == HttpStatusCode.Unauthorized) {
					Console.WriteLine("Invalid access token");
				}

				response.Close();
			}
		}
	}
}

GET /submissions?access_token=<access_token>
Returns information about submissions. Results are sorted ascending by id.

Parameters:

Name Type Located in Description
access_token* string query access token
ids* string query ids of submissions separated by comma, maximum 20 ids

Response HTTP Code:

Code Description
200 success
401 unauthorized access

Success Response:

Field Type Description
items[].id integer submission id
items[].time float execution time in seconds
items[].memory integer memory consumed by the program in kilobytes
items[].date string creation date and time (on server); format: yyyy-mm-­dd hh:mm:ss; eg. 2009­-05-­19 02:­34:­56
items[].status integer current status; see section "Status and result"
items[].result integer current result; see section "Status and result"
items[].signal integer signal raised by the program
items[].compiler.id integer compiler id
items[].compiler.name string compiler name
items[].compiler.ver string compiler version

Response example:

{
    "items": [
        {
            "id": 1,
            "time": 0.4,
            "memory": 2048,
            "date": "2017-02-24 14:24:21",
            "status": 0,
            "result": 0,
            "signal":0,
            "compiler": {
                "id": 1,
                "name": "C++",
                "ver": "gcc 6.3"
            }
        }
    ]
}

Examples

curl -X GET -H 'Content-Type: application/json' 'http://<endpoint>/api/v3/submissions?ids=:ids&access_token=<access_token>'
package compilers.submissions;
/**
 * Example presents error handling for getSubmissions() API method
 */

import javax.ws.rs.NotAuthorizedException;

import com.SphereEngine.Api.CompilersClientV3;
import com.google.gson.JsonObject;

public class getSubmissionsErrorHandling 
{

	public static void main(String[] args) 
	{
		CompilersClientV3 client = new CompilersClientV3(
				"<access_token>", 
				"<endpoint>");
		
		try {
			Integer[] ids = new Integer[2];
			ids[0] = 2017;
			ids[1] = 2018;

			JsonObject response = client.getSubmissions(ids);
		} catch (NotAuthorizedException e) {
			System.out.println("Invalid access token");
		}
	}	
}
<?php
/**
 * Example presents error handling for getSubmissions() API method
*/

use SphereEngine\Api\CompilersClientV3;
use SphereEngine\Api\SphereEngineResponseException;

// require library
require_once('../../../autoload.php');

// define access parameters
$accessToken = '<access_token>';
$endpoint = '<endpoint>';

// initialization
$client = new CompilersClientV3($accessToken, $endpoint);

// API usage
try {
	$response = $client->getSubmissions(array(2017, 2018));
} catch (SphereEngineResponseException $e) {
	if ($e->getCode() == 401) {
		echo 'Invalid access token';
	}
}
"""
Example presents error handling for submissions.getMulti() API method
"""
from sphere_engine import CompilersClientV3
from sphere_engine.exceptions import SphereEngineException

# define access parameters
accessToken = '<access_token>'
endpoint = '<endpoint>'

# initialization
client = CompilersClientV3(accessToken, endpoint)

# API usage
try:
    response = client.submissions.getMulti([2017, 2018])
except SphereEngineException as e:
    if e.code == 401:
        print('Invalid access token')
var request = require('request');

var accessToken = '<access_token>';
var endpoint = '<endpoint>';

var submissionsIds = [2016, 2017];

request({
	
	url: 'http://' + endpoint + '/api/v3/submissions?ids=' + submissionsIds.join() + '&access_token=' + accessToken,
    method: 'GET'
}, function (error, response, body) {
    
    if (error) {
        console.log('Connection problem');
    }
    
    if (response) {
        if (response.statusCode === 200) {
            console.log(JSON.parse(response.body)); // list of submissions in JSON
        } else {
            if (response.statusCode === 401) {
                console.log('Invalid access token');
            }
        }
    }
});