Execute Python code.
POST/code/python
This endpoint runs Python code in a Linux sandbox using the CPython interpreter. You can return data from the code by setting the global result
variable. Logging something to the console has no effect. To import dependencies, first add all dependencies to the requirements
array, and then import them using the common import
statement. All dependencies will be automatically downloaded and installed for you, with the exception of native system dependencies. There is a time limit of 180s and a memory limit of 512MB applied to your code, which also includes the dependency download process. One execution of this module costs 50 credits.
Request
Header Parameters
The API key that can be retrieved from 0codekit.com.
- application/json
Bodyrequired
The Python code that will be executed.
import requests
result = { "data": requests.get("https://0codekit.com").text }
The PyPI libraries your Python code requires. For backwards compatibility, this can be left empty, and your dependencies will be discovered automatically. Please do not use this and specify your requirements explicitly, as the automatic discovery is inaccurate and unreliable, and its only purpose is to prevent old code from breaking.
[]
The system dependencies your Python code requires. These will be installed using apk, the Alpine Package manager.
[]
Responses
- 200
- 400
Success
- application/json
- Schema
- Example (auto)
Schema
The data returned by the Python code.
{}
Bad Request
- application/json
- Schema
- Example (auto)
Schema
{
"status": 0,
"errorMessage": "string"
}