Skip to main content

Python SDK for Code Sandbox API

Project description

Code Sandbox Python SDK

Use the Code Sandbox API to run code in 10+ languages from Python.

Install

pip install code-sandbox-sdk

Or from source in this repo:

pip install -e packages/python-sdk

Usage

from code_sandbox import Client

client = Client(api_key="your-api-key")

# Execute code
result = client.execute(language="python", code="print(2 + 2)")
print(result.stdout)   # 4
print(result.success)  # True
print(result.exit_code)  # 0

# List runtimes
for r in client.runtimes():
    print(r.language, r.version)

API

  • Client(api_key, base_url=None) – Create a client. base_url defaults to http://localhost:3001.
  • client.execute(language, code, stdin=None, version=None) – Run code. Returns an ExecuteResult with success, stdout, stderr, exit_code, run_time_ms, error, compile_output.
  • client.runtimes() – List supported languages and versions. Returns a list of Runtime objects with language, version, aliases.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_sandbox_sdk-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_sandbox_sdk-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file code_sandbox_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: code_sandbox_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for code_sandbox_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0ea041043c935c9ae0afa3a668ff3fe978aea17d41a3b37c5b85ca3ac13589d6
MD5 ea009916100e63d21842617105826227
BLAKE2b-256 2f0d40ef3bcb516545e441e0e2abc0224c25693c32b0ebb93e271f68fd44a073

See more details on using hashes here.

File details

Details for the file code_sandbox_sdk-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for code_sandbox_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c41652a922dacda93c65183d12059ee282ca776c00b0ea4ba0f27c3ce6bc75d
MD5 0f79eacc3d6fb9d587f3281bb49b2f30
BLAKE2b-256 40aabfd92ada7fc5c53904b22a19a42532f4d32b87d200964344ac39a6cbe1be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page