Piston¶
- class ultra_piston.PistonClient(*, api_key=None, rate_limit=1.0, app_name='Ultra-Piston-Wrapper', base_url='https://emkc.org/api/v2/piston/', http_client=<class 'ultra_piston.http_clients.HTTPXClient'>, **http_client_kwargs)¶
The main client to interact with the piston-api.
- Parameters:
- api_key
- The API key to use if any.
- rate_limit
- Ratelimit to set for the dispatched requests.Takes in a integer / float of the amount of delay between each request.Defaults to 1 request per second.
- app_name
- Name of your app / project. To be used by the HTTP client’s User-Agent.
- base_url
- Base URL of the API.
- http_client
- The http client through which the requests are made with.
- http_client_kwargs
- The attributes to set to the http client.Useful when you want to make your own HTTP client.
- Parameters:
- async get_runtimes_async()¶
Return a list of available languages asynchronously.
- Return type:
List[Runtime]
- get_packages()¶
Returns a list of all possible packages, and their installation status.
Warning
This method is not available for the public API.
- Raises:
ultra_piston.errors.NotFoundError- If the endpoint is inaccessible.
- Return type:
List[Package]
- async get_packages_async()¶
Returns a list of all possible packages, and their installation status asynchronously.
Warning
This method is not available for the public API.
- Raises:
ultra_piston.errors.NotFoundError- If the endpoint is inaccessible.
- Return type:
List[Package]
- post_packages(language, version)¶
Install the given package.
Warning
This method is not available for the public API.
- Parameters:
- language
- The name of the programming language.
- version
- The version of the language.
- Raises:
ultra_piston.errors.NotFoundError- If the endpoint is inaccessible.
ultra_piston.errors.BadRequestError- Raised if an invalid version or language was passed.
- async post_packages_async(language, version)¶
Install the given package asynchronously.
Warning
This method is not available for the public API.
- Parameters:
- language
- The name of the programming language.
- version
- The version of the language.
- Raises:
ultra_piston.errors.NotFoundError- If the endpoint is inaccessible.
ultra_piston.errors.BadRequestError- Raised if an invalid version or language was passed.
- post_execute(language, version, file, stdin=None, args=None, compile_timeout=10000, run_timeout=3000, compile_memory_limit=-1, run_memory_limit=-1)¶
Runs the given code, using the given runtime and arguments, returning the result.
- Parameters:
- language
- The name of the programming language.
- version
- The version of the language.
- file
- The file containing the code to be executed.
- stdin
- Text to pass into stdin of the program.
- args
- Arguments to pass to the program.
- compile_timeout
- The maximum allowed time in milliseconds for the run stage to finish before bailing out.Must be a number, less than or equal to the configured maximum timeout. Defaults to maximum.
- run_timeout
- The maximum allowed time in milliseconds for the compile stage to finish before bailing out.Must be a number, less than or equal to the configured maximum timeout.
- compile_memory_limit
- The maximum amount of memory the compile stage is allowed to use in bytes.Must be a number, less than or equal to the configured maximum.Defaults to maximum, or -1 (no limit) if none is configured.
- run_memory_limit
- The maximum amount of memory the run stage is allowed to use in bytes.Must be a number, less than or equal to the configured maximum.Defaults to maximum, or -1 (no limit) if none is configured.
- Returns:
- Returns the ExecutionOutput data containing various data related to the ran code. ..
- Raises:
ultra_piston.errors.BadRequestError- Raised if an invalid version or language was passed.
- async post_execute_async(language, version, file, stdin=None, args=None, compile_timeout=10000, run_timeout=3000, compile_memory_limit=-1, run_memory_limit=-1)¶
Runs the given code, using the given runtime and arguments, returning the result asynchronously.
- Parameters:
- language
- The name of the programming language.
- version
- The version of the language.
- files
- The file containing the code to be executed.
- stdin
- Text to pass into stdin of the program.
- args
- Arguments to pass to the program.
- compile_timeout
- The maximum allowed time in milliseconds for the run stage to finish before bailing out.Must be a number, less than or equal to the configured maximum timeout. Defaults to maximum.
- run_timeout
- The maximum allowed time in milliseconds for the compile stage to finish before bailing out.Must be a number, less than or equal to the configured maximum timeout.
- compile_memory_limit
- The maximum amount of memory the compile stage is allowed to use in bytes.Must be a number, less than or equal to the configured maximum.Defaults to maximum, or -1 (no limit) if none is configured.
- run_memory_limit
- The maximum amount of memory the run stage is allowed to use in bytes.Must be a number, less than or equal to the configured maximum.Defaults to maximum, or -1 (no limit) if none is configured.
- Returns:
- Returns the ExecutionOutput data containing various data related to the ran code.
- Raises:
ultra_piston.errors.BadRequestError- Raised if an invalid version or language was passed.
- delete_packages(language, version)¶
Uninstall the given package.
Warning
This method is not available for the public API.
- Raises:
ultra_piston.errors.NotFoundError- If the endpoint is inaccessible.
ultra_piston.errors.BadRequestError- Raised if an invalid version or language was passed.
- async delete_packages_async(language, version)¶
Uninstall the given package asynchronously.
Warning
This method is not available for the public API.
- Raises:
ultra_piston.errors.NotFoundError- If the endpoint is inaccessible.
ultra_piston.errors.BadRequestError- Raised if an invalid version or language was passed.