API Module

judge0.api.async_execute(*, client=None, submissions=None, source_code=None, test_cases=None, **kwargs)

Create submission(s).

Aliases: async_run.

Parameters:
  • client (Client or Flavor, optional) – A client where submissions should be created. If None, will try to be resolved.

  • submissions (Submission or Submissions, optional) – Submission or submissions for execution.

  • source_code (str, optional) – A source code of a program.

  • test_cases (TestCaseType or TestCases, optional) – A single test or a list of test cases

Returns:

A single submission if submissions arguments is of type Submission or source_code argument is provided, and test_cases argument is of type TestCase. Otherwise returns a list of submissions.

Return type:

Submission or Submissions

Raises:
  • ClientResolutionError – If client cannot be resolved from the submissions or the flavor.

  • ValueError – If both or neither submissions and source_code arguments are provided.

judge0.api.async_run(*, client=None, submissions=None, source_code=None, test_cases=None, **kwargs)

Create submission(s).

Aliases: async_run.

Parameters:
  • client (Client or Flavor, optional) – A client where submissions should be created. If None, will try to be resolved.

  • submissions (Submission or Submissions, optional) – Submission or submissions for execution.

  • source_code (str, optional) – A source code of a program.

  • test_cases (TestCaseType or TestCases, optional) – A single test or a list of test cases

Returns:

A single submission if submissions arguments is of type Submission or source_code argument is provided, and test_cases argument is of type TestCase. Otherwise returns a list of submissions.

Return type:

Submission or Submissions

Raises:
  • ClientResolutionError – If client cannot be resolved from the submissions or the flavor.

  • ValueError – If both or neither submissions and source_code arguments are provided.

judge0.api.create_submissions(*, client=None, submissions=None)

Create submissions to a client.

Parameters:
  • client (Client, optional) – A Client where submissions should be created. If None, will try to be automatically resolved.

  • submissions (Submission, Submissions) – A submission or submissions to create.

Raises:

ClientResolutionError – Raised if client resolution fails.

Return type:

Union[Submission, Sequence[Submission]]

judge0.api.create_submissions_from_test_cases(submissions, test_cases=None)

Create submissions from the (submission, test_case) pairs.

This function always returns a deep copy so make sure you are using the returned submission(s).

Parameters:
  • submissions (Submission or Submissions) – Base submission(s) that need to be expanded with test cases.

  • test_cases (TestCaseType or TestCases) – Test cases.

Returns:

A single submission if submissions arguments is of type Submission or source_code argument is provided, and test_cases argument is of type TestCase. Otherwise returns a list of submissions.

Return type:

Submissions or Submissions

judge0.api.execute(*, client=None, submissions=None, source_code=None, test_cases=None, **kwargs)

Create submission(s) and wait for their finish.

Aliases: execute, run, sync_run.

Parameters:
  • client (Client or Flavor, optional) – A client where submissions should be created. If None, will try to be resolved.

  • submissions (Submission or Submissions, optional) – Submission or submissions for execution.

  • source_code (str, optional) – A source code of a program.

  • test_cases (TestCaseType or TestCases, optional) – A single test or a list of test cases

Returns:

A single submission if submissions arguments is of type Submission or source_code argument is provided, and test_cases argument is of type TestCase. Otherwise returns a list of submissions.

Return type:

Submission or Submissions

Raises:
  • ClientResolutionError – If client cannot be resolved from the submissions or the flavor.

  • ValueError – If both or neither submissions and source_code arguments are provided.

judge0.api.get_client(flavor=Flavor.CE)
Return type:

Client

judge0.api.get_submissions(*, client=None, submissions=None, fields=None)

Create submissions to a client.

Parameters:
  • client (Client, optional) – A Client where submissions should be created. If None, will try to be automatically resolved.

  • submissions (Submission, Submissions) – A submission or submissions to create.

Raises:

ClientResolutionError – Raised if client resolution fails.

Return type:

Union[Submission, Sequence[Submission]]

judge0.api.run(*, client=None, submissions=None, source_code=None, test_cases=None, **kwargs)

Create submission(s) and wait for their finish.

Aliases: execute, run, sync_run.

Parameters:
  • client (Client or Flavor, optional) – A client where submissions should be created. If None, will try to be resolved.

  • submissions (Submission or Submissions, optional) – Submission or submissions for execution.

  • source_code (str, optional) – A source code of a program.

  • test_cases (TestCaseType or TestCases, optional) – A single test or a list of test cases

Returns:

A single submission if submissions arguments is of type Submission or source_code argument is provided, and test_cases argument is of type TestCase. Otherwise returns a list of submissions.

Return type:

Submission or Submissions

Raises:
  • ClientResolutionError – If client cannot be resolved from the submissions or the flavor.

  • ValueError – If both or neither submissions and source_code arguments are provided.

judge0.api.sync_execute(*, client=None, submissions=None, source_code=None, test_cases=None, **kwargs)

Create submission(s) and wait for their finish.

Aliases: execute, run, sync_run.

Parameters:
  • client (Client or Flavor, optional) – A client where submissions should be created. If None, will try to be resolved.

  • submissions (Submission or Submissions, optional) – Submission or submissions for execution.

  • source_code (str, optional) – A source code of a program.

  • test_cases (TestCaseType or TestCases, optional) – A single test or a list of test cases

Returns:

A single submission if submissions arguments is of type Submission or source_code argument is provided, and test_cases argument is of type TestCase. Otherwise returns a list of submissions.

Return type:

Submission or Submissions

Raises:
  • ClientResolutionError – If client cannot be resolved from the submissions or the flavor.

  • ValueError – If both or neither submissions and source_code arguments are provided.

judge0.api.sync_run(*, client=None, submissions=None, source_code=None, test_cases=None, **kwargs)

Create submission(s) and wait for their finish.

Aliases: execute, run, sync_run.

Parameters:
  • client (Client or Flavor, optional) – A client where submissions should be created. If None, will try to be resolved.

  • submissions (Submission or Submissions, optional) – Submission or submissions for execution.

  • source_code (str, optional) – A source code of a program.

  • test_cases (TestCaseType or TestCases, optional) – A single test or a list of test cases

Returns:

A single submission if submissions arguments is of type Submission or source_code argument is provided, and test_cases argument is of type TestCase. Otherwise returns a list of submissions.

Return type:

Submission or Submissions

Raises:
  • ClientResolutionError – If client cannot be resolved from the submissions or the flavor.

  • ValueError – If both or neither submissions and source_code arguments are provided.

judge0.api.wait(*, client=None, submissions=None, retry_strategy=None)
Return type:

Union[Submission, Sequence[Submission]]