Python

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
  • Sync/stream: Basic 30s, Pro 60s, Ultra/Mega 150s; async: Ultra 300s, Mega 600s
  • 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. Files written under /home/sandbox and packages added with the pip install endpoint persist between calls; each call starts a fresh process, so variables do not carry over. Ideal for code interpreters and iterative agents.

# 1. Create a session (PRO, ULTRA, or MEGA)
curl -X POST https://sandboxapi.p.rapidapi.com/v1/sessions \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: sandboxapi.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"language":"python3","idle_ttl":300}'
# → {"id":"sess_abc","language":"python3",...}

# 2. Write a file in the session
curl -X POST https://sandboxapi.p.rapidapi.com/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: sandboxapi.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"code":"open('/home/sandbox/state.txt','w').write('42')"}'

# 3. A later call reads it back: files persist, variables do not
curl -X POST https://sandboxapi.p.rapidapi.com/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: sandboxapi.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"code":"print(int(open('/home/sandbox/state.txt').read()) * 2)"}'
Read the sessions docs →

Need more? Get API access

Integrate secure code execution into your own apps with our REST API. Basic includes 500 requests per RapidAPI subscription period.