Skip to main content
Get up and running with HopX; this guide walks you through creating your first sandbox, executing code, and cleaning up.

What You’ll Learn

In this quickstart, you’ll learn how to:
  • Install and set up the HopX SDK (Python or JavaScript) or CLI
  • Create your first sandbox from a pre-built template
  • Execute code in multiple languages (Python, JavaScript, Bash, Go)
  • Work with files in sandboxes (read, write, list)
  • Clean up sandboxes to free resources
  • Use context managers for automatic cleanup (Python)

Prerequisites

  • HopX API key (get one here if you don’t have it)
  • Python 3.8+ or Node.js 18+ or CLI installed
  • Basic experience with Python, JavaScript, or command line

Run your first sandbox

Choose your preferred method: Python SDK, JavaScript SDK, or CLI. This guide focuses on SDKs. For CLI, see the CLI Quickstart.
1

Install the SDK or CLI

Install the HopX SDK for your preferred language, or use the CLI:
2

Create Your First Sandbox

Create a sandbox using a pre-built template. Templates provide pre-configured environments with common tools and packages.
Expected Output:
You can also use Sandbox.create() without specifying an API key if you set the HOPX_API_KEY environment variable.
3

Execute Code

Run code in your sandbox.
The run_code() method automatically captures rich outputs like matplotlib plots and pandas DataFrames. See Rich Output Capture for more details.
The sandbox will execute code written in any language as long as the template you use provides the necessary dependencies.

See the Getting Template Details page for information on available templates and their environments, alternatively create your own template with the Building Templates guide.
4

Work with Files

Upload, read, and write files in your sandbox:
Expected Output:
5

Clean Up

Always clean up your sandbox when you’re done to free resources:
Expected Output:
Calling kill() permanently deletes the sandbox and all its data. Make sure you’ve saved any important files before cleaning up. See Downloading Files for more details.

Using Context Managers (Python)

Python SDK supports context managers for automatic cleanup:
Expected Output:

Complete Example

Here’s a complete example that brings it all together:

Next Steps

Now that you’ve created your first sandbox, explore more:
For AI agent developers, check out the MCP Integration guide to enable AI assistants to execute code safely in sandboxes.