Skip to main content
Get the public URL for accessing a specific port on your sandbox.

Basic Usage

from gravixlayer import GravixLayer

client = GravixLayer(api_key="YOUR_API_KEY")

host = client.sandbox.sandboxes.get_host_url("your-sandbox-id", port=8000)
print(f"URL: {host.url}")

Parameters

ParameterTypeRequiredDescription
sandbox_idstringYesSandbox ID (UUID)
portintegerYesPort number (1-65535)

Response

{
  "url": "https://550e8400-e29b-41d4-a716-446655440000-8000.gravixlayer.com"
}

Common Ports

PortServiceUse Case
3000Node.js/ReactWeb development
5000FlaskPython web applications
8000HTTP ServerSimple web servers
8080Alternative HTTPWeb applications
8888JupyterNotebook servers

Example: Access Web Server

Start a web server in your sandbox, then get its public URL:
from gravixlayer import GravixLayer

client = GravixLayer(api_key="YOUR_API_KEY")

sandbox = client.sandbox.sandboxes.create(template="python-base-v1", timeout=300)
sid = sandbox.sandbox_id

# Start a simple HTTP server
code = """\
import http.server, socketserver
from threading import Thread

class Handler(http.server.SimpleHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        self.wfile.write(b"Hello from AgentBox!")

server = socketserver.TCPServer(("", 8000), Handler)
Thread(target=server.serve_forever, daemon=True).start()
print("Server started on port 8000")
"""

client.sandbox.sandboxes.run_code(sid, code=code, language="python")

# Get the public URL
host = client.sandbox.sandboxes.get_host_url(sid, port=8000)
print(f"Access your server at: {host.url}")

Next Steps

Get Metrics

Monitor resource usage

Execute Code

Run web servers and applications

Run Commands

Install and configure services

Get Sandbox Info

Monitor sandbox status