@bedrock-rbx/ocale

中文文档
0.4.0发布于 2026/11/03MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 9349

Roblox Open Cloud API client

原始使用文档
文档目录9 节
  1. What is @bedrock-rbx/ocale ?
  2. Install
  3. Quick start
  4. Available clients
  5. Rate limiting and retries
  6. Per-request configuration overrides
  7. Testing helpers
  8. Status, docs, and contributing
  9. License

@bedrock-rbx/ocale

Zero-dependency TypeScript SDK for Roblox Open Cloud.

npm version License: MIT CI

Status: 0.1, pre-1.0. The public API is stabilizing; breaking changes may land in minor releases until 1.0.

What is @bedrock-rbx/ocale?

A typed HTTP client for Roblox Open Cloud. Each Roblox feature (universes, places, game passes, developer products, badges, storage, Luau execution) is exposed as its own client class with the methods, request types, and response types you would otherwise build by hand against the raw REST endpoints.

The SDK has zero runtime dependencies and runs on Node >= 24.12 or Bun >= 1.3 using the standard fetch, FormData, and TextEncoder web APIs. Rate-limit queueing and retry handling are built in: requests are queued per-operation against Roblox's published limits, and idempotent calls automatically retry on 429 and 5xx responses without consumer code reaching for try/catch or setTimeout.

@bedrock-rbx/ocale is the foundation that @bedrock-rbx/core uses internally to talk to Roblox, and it is publishable as a standalone package for anyone building tooling, scripts, or services that need typed Open Cloud calls without bedrock's full IaC engine. If you already depend on @bedrock-rbx/core, ocale is installed transitively; reach for it directly when you need HTTP-level control that core's IaC engine does not expose.

Install

pnpm add @bedrock-rbx/ocale
# or: npm install @bedrock-rbx/ocale
# or: bun add @bedrock-rbx/ocale

Runtime: Node >= 24.12 or Bun >= 1.3.

Authentication: every client takes a credential at construction, for example { kind: "apiKey", apiKey }. Generate an API key at Creator Hub > Credentials > API Keys and grant it the scopes for the operations you plan to call (each method's JSDoc lists its required scopes).

Quick start

import { GamePassesClient } from "@bedrock-rbx/ocale/game-passes";

const client = new GamePassesClient({
    credential: { apiKey: "your-open-cloud-api-key", kind: "apiKey" },
});

const result = await client.get({
    gamePassId: "9876543210",
    universeId: "1234567890", // from your experience URL in Creator Hub
});

if (!result.success) {
    console.error(`Open Cloud call failed: ${result.err.message}`);
    process.exit(1);
}

console.log(`${result.data.name} (${result.data.id})`);

Every method returns Promise<Result<T, OpenCloudError>>. Result is a discriminated union: result.success is true with the parsed response on result.data, or false with a structured error on result.err. No exception ever escapes a client method.

Available clients

Resource clients live on subpaths so unused features tree-shake out of your bundle.

SubpathClientWhat it covers
@bedrock-rbx/ocale/universesUniversesClientUniverse metadata, social links, icon and thumbnail uploads, server restarts.
@bedrock-rbx/ocale/placesPlacesClientPlace metadata, .rbxl publishing, Luau execution tasks scoped to a place.
@bedrock-rbx/ocale/game-passesGamePassesClientGame pass CRUD, icon upload, localized name and description updates.
@bedrock-rbx/ocale/developer-productsDeveloperProductsClientDeveloper product CRUD, icon upload, localized name and description updates.
@bedrock-rbx/ocale/badgesBadgesClientBadge CRUD and localized icon uploads.
@bedrock-rbx/ocale/storageStorageClientMemory stores (sorted maps, queues) for live game state.
@bedrock-rbx/ocale/luau-executionLuauExecutionClientStandalone Luau execution tasks with binary inputs and log streaming.
@bedrock-rbx/ocale/localesROBLOX_CREATOR_LOCALES (data)Reference list of locales Roblox supports for localized fields.

Additional Open Cloud features (messaging, data stores, OAuth, groups, analytics) are not yet wrapped; they are tracked on the roadmap.

The package root (@bedrock-rbx/ocale) deliberately re-exports only shared utilities: Result, Page, OpenCloudError and its subclasses (ApiError, RateLimitError, NetworkError, ValidationError, and similar), and the OpenCloudClientOptions type. Resource clients are not on the root barrel.

Rate limiting and retries

The SDK queues every request behind a per-operation rate-limit bucket sourced from Roblox's published OpenAPI schema. You fire calls at whatever rate your code needs; the SDK paces them.

Retry behavior is idempotency-aware:

Method kind429 (rate limit)5xx (server error)
CreateRetryDo not retry
Read / ListRetryRetry
UpdateRetryRetry
DeleteRetryRetry

Create operations skip 5xx retries because Roblox does not support idempotency keys and a duplicate retry would silently produce a second resource. If you can detect duplicates externally, opt back into 5xx retry on a per-call basis via retryableStatuses on the request options argument.

After retry attempts are exhausted, the final failure surfaces on result.err as the typed error that caused it (RateLimitError for 429s, ApiError for 5xx, NetworkError for transport-level faults, and so on).

A 429 status does not identify one semantic cause. RateLimitError preserves the upstream code, parsed details, and an allowlisted responseHeaders record so consumers can inspect the available evidence. Treat those fields as evidence rather than an exhaustive kind: request quota, a longer shared meter, and occupied operation capacity can produce overlapping response shapes. Resource-specific code should classify a narrower cause only from positive domain evidence, such as validated blocker task references.

Observability hooks (onRequest, onRetry, onRateLimit) accept callbacks on the client constructor for logging, metrics, or tracing integration.

Per-request configuration overrides

Client-level config is frozen on construction. Every method accepts an optional second RequestOptions argument that overrides config for a single call:

const client = new GamePassesClient({
    credential: { apiKey: "main-key", kind: "apiKey" },
});

const result = await client.create(parameters, {
    credential: { apiKey: "asset-upload-key", kind: "apiKey" }, // different key for moderation safety
    deadlineMs: Date.now() + 495_000,
    timeout: 60_000,
});

This pattern fits multi-tenant tooling (different API keys per workspace), credential rotation (swap mid-batch), and isolating retry / timeout policies to specific calls. deadlineMs is an absolute timestamp for the whole logical call. A retry, operation-queue wait, or reported-budget wait that cannot finish before it fails with RequestDeadlineExceededError; an oversized retry keeps its server delay on the more specific RetryDelayExceededError.

Testing helpers

A @bedrock-rbx/ocale/testing subpath exports the same fakes the SDK's own integration tests use:

  • createFakeHttpClient(...) for swapping the HTTP transport with a recorded fake that validates request bodies against the vendored OpenAPI schema.
  • createFakeSend(...) for a lightweight scripted send-callback fake that records requests and replays responses for single-call tests, without schema validation.
  • createFakeSleep(...) for deterministic retry and rate-limit timing.
  • valid*Body fixtures (validGamePassBody, validPlaceBody, validUniverseBody, and similar) for synthesising realistic response payloads.

Pass the fake into any client via the httpClient and sleep parameters on OpenCloudClientOptions and assert against the captured requests.

Status, docs, and contributing

This package is pre-1.0 and under active development. Track scope and timing on the project board.

License

MIT (c) Christopher Buss.

版本与发布记录

@bedrock-rbx/ocale 共发布 41 个版本,首次发布于 2026/05/06;过去 12 个月发布了 41 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.0latest2026/11/034 天前
0.3.42026/10/021 个月前
0.3.4-beta.1beta2026/09/291 个月前
0.3.4-beta.02026/09/251 个月前
0.3.32026/09/241 个月前
0.3.22026/09/231 个月前

关于 @bedrock-rbx/ocale 的常见问题

@bedrock-rbx/ocale 是什么?

Roblox Open Cloud API client

如何安装 @bedrock-rbx/ocale?

在项目目录运行 npm install @bedrock-rbx/ocale,或使用 pnpm add / yarn add / bun add。

@bedrock-rbx/ocale 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bedrock-rbx/ocale 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bedrock-rbx/ocale 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bedrock-rbx/ocale 可以商用吗?

@bedrock-rbx/ocale 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bedrock-rbx/ocale 的下载量有多少?

根据 npm 官方下载统计,@bedrock-rbx/ocale 在 2026/10/08 – 2026/11/06 这 30 天内被下载 9,349 次,日均约 312 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bedrock-rbx/ocale 还在维护吗?

最新版本 0.4.0 发布于 2026/11/03(4 天前);至今共发布 41 个版本,其中过去 12 个月发布了 41 个;首次发布于 2026/05/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。