@obul.ai/obulx
v0.2.13
Published
Obul x402 CLI and library.
Downloads
115
Readme
@obul.ai/obulx
Obul x402 CLI and library.
Install
npm install -g @obul.ai/obulxDirect x402 mode (non-proxy) requires installing the optional addon:
npm install -g @obul.ai/obulx-x402What It Does
obulx is a CLI for calling x402-protected endpoints. It supports:
- Proxy mode (via Obul proxy) API key auth.
- Direct x402 mode with a local private key for signing payments.
CLI Usage
obulx <command>
obulx [options] <url>Commands:
obulx login: OAuth device login. If already authenticated, prints current session and exits. Use--forceto re-authenticate.obulx logout: Best-effort refresh token revocation + local credential removal.obulx whoami: Prints the current authenticated user.
Key Parameters
--obul-proxy <BASE>: Enables proxy mode and rewrites the URL asBASE/{scheme}/{host}{path}?{query}. Defaults toOBUL_PROXY_URLorhttps://proxy.obul.ai/proxy.--network <NETWORK>: Required for direct x402 mode. Repeatable or comma-separated.--auto-approve-limit <N>: Optional for direct x402 mode. Integer string in token units. Defaults to0(always prompt for approval).--asset <ADDRESS>: Optional in direct mode. Exact match (case-insensitive).-X, --method <METHOD>: HTTP method (defaultGET).-d, --data <BODY>: Raw request body. Defaults method toPOSTif method is not set.-H, --header <NAME: VALUE>: Add a request header (repeatable).-v: Show final response status and headers.-vv: Show final request + response.-vvv: Also show probe request + response in direct x402 mode.--force: Withobulx login, forces a fresh auth flow even if already logged in.
Environment Variables
OBUL_ISSUER_URL: OAuth issuer URL (defaults tohttps://api.obul.ai) used bylogin,logout, andwhoami.OBUL_PROXY_URL: Override proxy base (defaults tohttps://proxy.obul.ai/proxy).OBUL_API_KEY: API key for proxy mode.OBUL_X402_PRIVATE_KEY: Private signing key for direct x402 mode.PRIVATE_KEY: Fallback private key for direct x402 mode.
Auth Precedence (Proxy Mode)
When running proxy fetches (obulx [options] <url>), auth selection is:
OBUL_API_KEYenv var- OAuth access token from
~/.obul/credentials.json(auto-refreshes with refresh token) - error if neither is available
Notes:
- Credentials are stored in
~/.obul/credentials.json(file mode0600). whoamiand post-login identity output are JWT-first and opportunistically use/oauth/userinfowhen available.
Examples
Login:
obulx loginWho am I:
obulx whoamiLogout:
obulx logoutProxy mode (API key):
export OBUL_PROXY_URL="https://proxy.devnet.obul.ai/proxy"
export OBUL_API_KEY="your-api-key"
obulx <x402-protected endpoint>Proxy mode with custom headers:
obulx --obul-proxy https://proxy.devnet.obul.ai/proxy \
-H "Content-Type: application/json" \
-H "X-Custom: value" \
<x402-protected endpoint>Direct x402 mode:
export OBUL_X402_PRIVATE_KEY="0x..."
npm install -g @obul.ai/obulx-x402
obulx --network base --auto-approve-limit 1000 \
https://x402.example.com/resourceDirect mode with network priority and asset filter:
export OBUL_X402_PRIVATE_KEY="0x..."
npm install -g @obul.ai/obulx-x402
obulx --network base,optimism --asset 0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 \
--auto-approve-limit 1000 \
https://x402.example.com/resourceVerbose output (final request + response):
obulx -vv --obul-proxy https://proxy.devnet.obul.ai/proxy \
<x402-protected endpoint>Verbose output (probe + final in direct mode):
npm install -g @obul.ai/obulx-x402
obulx -vvv --network base --auto-approve-limit 1000 \
https://x402.example.com/resourceCLI
obulx --obul-proxy https://proxy.devnet.obul.ai/proxy \
-X POST -d '<x402 request body>' \
<x402-protected endpoint>Library
import { obulxFetch } from "@obul.ai/obulx"
const response = await obulxFetch({
url: "<x402-protected endpoint>",
method: "POST",
body: "...",
obulProxy: "https://proxy.devnet.obul.ai/proxy",
obulApiKey: process.env.OBUL_API_KEY,
verbose: 1
})
process.stdout.write(response.body)