Prerequisites: Node.js 18+, npm, HopX API key
Time: ~5 minutes This quickstart gets you from zero to your first successful code execution. Follow these steps in order.
What You’ll Learn
In this quickstart, you’ll learn how to:- Install and verify the JavaScript SDK
- Set up API key authentication
- Create a sandbox from a template
- Execute code in the sandbox using async/await
- Access execution results and output
- Clean up sandboxes properly
Step 1: Install the SDK
Step 1.5: Verify Installation
Verify the SDK is installed correctly:HopX SDK installed successfully
Step 2: Set Your API key
Set theHOPX_API_KEY environment variable:
Get your API key from console.hopx.dev → Settings → API Keys
Step 3: Create and Run Your First Sandbox
Create a filehello-HopX.js:
Step 4: Run It
If using ES modules, ensure your
package.json has "type": "module", or use .mjs extension.Expected Output
What Just Happened?
Sandbox.create()- Created a new sandbox from thecode-interpretertemplate (Python environment)sandbox.runCode()- Executed Python code in the sandboxresult.stdout- Retrieved the standard output from code executionsandbox.kill()- Deleted the sandbox to free resources
Related
- API Quickstart - Get started with the API
- Python SDK Quickstart - Python SDK equivalent
- Sandbox Class Reference - Complete SDK reference
- Creating Sandboxes - Learn more about sandbox creation
Next Steps
Now that you have a working setup, explore more:- Creating Sandboxes - Learn about different templates and options
- Code Execution - Run Python, JavaScript, Bash, and more
- File Operations - Read, write, and manage files in sandboxes
- CLI Quickstart - Use HopX from the command line
- API Reference - Complete SDK documentation
Quickstart Variations
For more advanced quickstart examples including error handling, environment variables, and TypeScript patterns, see the Advanced Quickstart Guide (coming soon).
Troubleshooting
“API key required” error?- Verify
HOPX_API_KEYis set:echo $HOPX_API_KEY - Get your key at console.hopx.dev
- Use
template: 'code-interpreter'(default Python template) - See Available Templates for options
- Run
npm install @hopx-ai/sdk - Check Node.js version:
node --version(should be 18+)
- Check internet connection
- Verify firewall allows HTTPS (port 443)

