Registry / communication / agora-rest-client

agora-rest-client

JSON →
library0.1.0jsnpmunverified

A TypeScript SDK for the Agora REST API, designed for Node.js (>=18). Version 0.1.0 wraps Agora's cloud recording service and provides automatic domain failover, request retries, and typed responses. It uses Basic Auth credentials and requires an Agora App ID. The package ships TypeScript types and is ESM-only. Community-maintained with limited testing; not production-ready.

npm install agora-rest-client
INSTALL
IMPORT
SIG · AGORA-REST-CLIENT
A
agora-rest-client
communicationjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CloudRecordingClient
import { CloudRecordingClient } from 'agora-rest-client'
const CloudRecordingClient = require('agora-rest-client')
ESM-only since v0.1.0; CommonJS require will fail.
BasicCredential
import { BasicCredential } from 'agora-rest-client'
import AgoraRestClient from 'agora-rest-client'; const { BasicCredential } = AgoraRestClient;
Named export, not default.
DomainArea
import { DomainArea } from 'agora-rest-client'
import { DomainAreaEnum } from 'agora-rest-client'
DomainArea is an enum object, not a string union.
AcquireResourceRes
import { AcquireResourceRes } from 'agora-rest-client'
TypeScript type import; use `import type` for type-only imports.

Shows how to initialize CloudRecordingClient with BasicCredential, acquire a resource, and start cloud recording using the mix scenario API.

import { CloudRecordingClient, BasicCredential, DomainArea, AcquireResourceRes, StartResourceRes, RecordingRequestChannelTypeEnum, QueryMixHLSAndMP4RecordingResourceRes, StopResourceRes } from 'agora-rest-client'; const appId = process.env.AGORA_APP_ID ?? ''; const cname = process.env.AGORA_CHANNEL ?? ''; const uid = process.env.AGORA_UID ?? ''; const username = process.env.AGORA_USERNAME ?? ''; const password = process.env.AGORA_PASSWORD ?? ''; const token = process.env.AGORA_TOKEN ?? ''; if (!appId || !cname || !uid || !username || !password) { console.error('Missing required environment variables'); process.exit(1); } const credential = new BasicCredential(username, password); const client = new CloudRecordingClient({ appId, credential, domainArea: DomainArea.CN }); async function startRecording() { const acquireRes: AcquireResourceRes = await client.mixScenario().acquire(cname, uid, { resourceExpiredHour: 1 }); const resourceId = acquireRes.resourceId!; const startRes: StartResourceRes = await client.mixScenario().start(cname, uid, resourceId, { token, recordingConfig: { channelType: RecordingRequestChannelTypeEnum.Live, streamTypes: 2, maxIdleTime: 30, audioProfile: 2, transcodingConfig: { width: 640, height: 480, fps: 15 }, }, }); console.log('Recording started:', startRes.sid); return { resourceId, sid: startRes.sid }; } startRecording().catch(console.error);
Debug
Known issues
gotchaSDK is community-maintained and may have bugs; not production-tested.
fix
Use with caution and test thoroughly. Consider using Agora's official REST API directly.
affects: >=0.0.0
deprecatedThe SDK currently only supports Cloud Recording service; other Agora REST API endpoints are not wrapped.
fix
For other services, use direct HTTP calls or wait for future releases.
affects: 0.1.0
breakingAll exports are ESM-only; CommonJS require() will fail with ERR_REQUIRE_ESM.
fix
Use 'import' syntax or dynamic import() in CommonJS projects. Set 'type': 'module' in package.json.
affects: >=0.1.0
gotchaBasicCredential uses plaintext username/password; never hardcode credentials in source code.
fix
Use environment variables or a secrets manager.
affects: >=0.0.0
gotchaDomainArea must match the geographic region of your Agora project; wrong region may cause connection failures.
fix
Set domainArea to the region where your Agora App ID is registered (CN, US, EU, AP).
affects: >=0.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/agora-rest-client/dist/index.js not supported.
The package is ESM-only and cannot be required() in CommonJS contexts.
fix
Convert your project to ESM (set "type": "module" in package.json) or use dynamic import(): const { CloudRecordingClient } = await import('agora-rest-client').
Error: BasicCredential is not a constructor
Attempting to use BasicCredential without importing it correctly (e.g., using default import or destructuring from the wrong object).
fix
Ensure you use: import { BasicCredential } from 'agora-rest-client'
TypeError: client.mixScenario is not a function
Trying to call mixScenario on an incorrectly instantiated CloudRecordingClient or using an older version of the SDK.
fix
Verify that CloudRecordingClient is imported correctly and instantiated with the required { appId, credential, domainArea }.
Property 'resourceId' does not exist on type 'AcquireResourceRes'
Not accounting for the type structure; AcquireResourceRes has resourceId? as optional.
fix
Check the response shape: const resourceId = acquireRes.resourceId; if (!resourceId) throw new Error('Failed to acquire resource');
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
50 hits · last 30 days
node
42
OpenAI (training)
1
Resources
agora-rest-client — npm install agora-rest-client · libregistry