Skip to Content
Language guide

Call Supervisor from JavaScript

Use the built in fetch client in server side JavaScript without adding a Supervisor package.

Language guide
01

Server side requests

Read SUPERVISOR_API_KEY from the server environment and pass it in the Authorization header. Check response.ok before parsing the successful JSON body.

Keep the request on the server in Next.js route handlers, server actions, Bun services, or another trusted runtime. A browser bundle would expose the credential to every visitor.

import json
import os
import urllib.request
url = "https://api.trysupervisor.com/workspaces/user/me"
request = urllib.request.Request(url, method="GET")
request.add_header("Authorization", f"Bearer {os.environ['SUPERVISOR_API_KEY']}")
request.add_header("Content-Type", "application/json")
with urllib.request.urlopen(request) as response:
result = json.load(response)
print(json.dumps(result, indent=2))
02

No published SDK required

The examples use standard HTTP clients so they match the current API contract without depending on an unpublished package. Generate local types from the response shapes your application uses.