Python
Python 3.12

Run Python 3.12 Online

Execute Python code instantly in a secure, isolated sandbox. No setup, no installs — just write and run.

main.py
Output
Click "Run Code" to execute...

About Python

Python is the most popular programming language in the world, widely used for AI/ML, data science, web development, and automation. Its clean syntax and vast ecosystem of libraries make it the go-to choice for beginners and experts alike.

Our sandbox runs Python 3.12 with full standard library support.

Sandbox Features

  • Secure execution with Docker + gVisor isolation
  • Python 3.12 with standard library included
  • Up to 300s execution time (Pro tier)
  • Stdin support for interactive programs
  • REST API for programmatic access
  • No setup or installation required

Use Python with stateful sessions

Open a session once, then call execute repeatedly — variables, files, and installed packages persist between runs. Perfect for code interpreters and REPL-style agents.

# 1. Create a session
curl -X POST https://api.sandboxapi.dev/v1/sessions \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"language":"python3","idle_ttl":300}'
# → {"id":"sess_abc","language":"python3",...}

# 2. Execute — first call
curl -X POST https://api.sandboxapi.dev/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"code":"x = 42"}'

# 3. Execute again — state carries over
curl -X POST https://api.sandboxapi.dev/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"code":"print(x * 2)"}'
Read the sessions docs →

Run Code in Other Languages

Need More? Get API Access

Integrate secure code execution into your own apps with our REST API. Free tier includes 500 executions per month.

Get API Key on RapidAPI