Authentication
The SDK authenticates using bearer tokens. No OAuth, no API keys — just a token string.
Quickstart
Section titled “Quickstart”import { Client } from "@githosted/sdk";
// Pass a token directlyconst client = new Client({ token: "gw_your_token" });
// Or set GITHOSTED_TOKEN in your environment (Node.js only)// export GITHOSTED_TOKEN=gw_your_tokenconst client = new Client();Token Types
Section titled “Token Types”| Prefix | Type | Scope | Use case |
|---|---|---|---|
gw_ | Workspace | All repos in workspace | Apps, agents, admin tools |
gr_ | Repo | Specific repos only | CI jobs, sandboxes, least-privilege |
Both token types work in the same Client constructor. The SDK auto-detects the type from the prefix.
Credential Resolution Order
Section titled “Credential Resolution Order”The SDK resolves credentials in this order (first match wins):
- Explicit:
new Client({ token: "gw_xxx" }) - Environment:
GITHOSTED_TOKENenv var (Node.js only)
In the browser, always pass the token explicitly — there is no env var fallback.
Browser Usage
Section titled “Browser Usage”const client = new Client({ token: "gw_xxx", baseUrl: "https://api.githosted.dev", // optional, this is the default});Custom Base URL
Section titled “Custom Base URL”For local development or self-hosted instances:
const client = new Client({ token: "gw_xxx", baseUrl: "http://localhost:8080",});