### Run Web API Examples Source: https://docs.agora.io/en/realtime-media/video/reference/api-examples Install dependencies and start the development server to run the Web examples. ```bash npm install npm run dev ``` -------------------------------- ### Start Local Quickstart with npm Source: https://docs.agora.io/en/ai/device-kit/build/run-r1-demo Start the local quickstart services using npm. This command runs the development server. ```bash npm run dev ``` -------------------------------- ### Start Local Quickstart with Bun Source: https://docs.agora.io/en/ai/device-kit/build/run-r1-demo Start the local quickstart services using Bun. This command runs the development server. ```bash bun run dev ``` -------------------------------- ### Install Project Dependencies Source: https://docs.agora.io/en/realtime-media/broadcast-streaming/build/set-up-your-project/compile-run-sample-project Navigate to the example directory and run this command to install all necessary dependencies for the sample project using Yarn. ```bash yarn ``` -------------------------------- ### Quick start Python project with Agora CLI Source: https://docs.agora.io/en/introduction/agora-cli Logs in, initializes a new Python starter project, installs dependencies using bun, and starts the development server. ```bash agora login agora init my-python-demo --template python cd my-python-demo bun install bun run dev ``` -------------------------------- ### Go Project Setup Commands Source: https://docs.agora.io/en/realtime-media/rtm/build/connect-and-authenticate/authentication-workflow Commands to initialize a Go module, install dependencies, and run the token server. Ensure you have Go installed and are in your project directory. ```bash go mod init sampleServer ``` ```bash go get ``` ```bash go run server.go ``` -------------------------------- ### Example Pod Install Output Source: https://docs.agora.io/en/realtime-media/flexible-classroom/build/integrate-the-sdks/integrate-flexible-classroom This is an example of the terminal output after running 'pod install' for Flexible Classroom SDK v2.80.20. ```bash Analyzing dependencies Downloading dependencies Installing AgoraClassroomSDK_iOS (2.8.20) Installing AgoraEduCore (2.8.20) Installing AgoraEduUI (2.8.20) Installing AgoraLog (1.0.2) Installing AgoraMediaPlayer_iOS (1.3.0) Installing AgoraRtcEngine_iOS (3.7.2) Installing AgoraRtm_iOS (1.4.8) Installing AgoraUIBaseViews (2.8.0) Installing AgoraWidget (2.8.0) Installing AgoraWidgets (2.8.20) Installing Agora_Chat_iOS (1.0.6) Installing AliyunOSSiOS (2.10.8) Installing Armin (1.1.0) Installing CocoaLumberjack (3.6.1) Installing Masonry (1.1.0) Installing NTLBridge (3.1.5) Installing Protobuf (3.17.0) Installing SDWebImage (5.12.0) Installing SSZipArchive (2.4.2) Installing SwifterSwift (5.2.0) Installing Whiteboard (2.16.51) Installing YYModel (1.0.4) Generating Pods project Integrating client project ``` -------------------------------- ### Example Pod Install Output Source: https://docs.agora.io/en/realtime-media/flexible-classroom/build/integrate-the-sdks/integrate-flexible-classroom This is an example of the output you might see when running `pod install` after adding the proctoring SDK dependencies. ```text Analyzing dependencies Downloading dependencies Installing AgoraProctorSDK (1.0.0) Installing AgoraProctorUI (1.0.0) Installing AgoraEduCore (2.8.20) Installing AgoraLog (1.0.2) Installing AgoraMediaPlayer_iOS (1.3.0) Installing AgoraRtcEngine_iOS (3.7.2) Installing AgoraRtm_iOS (1.4.8) Installing AgoraUIBaseViews (2.8.0) Installing AgoraWidget (2.8.0) Installing AliyunOSSiOS (2.10.8) Installing Armin (1.1.0) Installing CocoaLumberjack (3.6.1) Installing Masonry (1.1.0) Installing Protobuf (3.17.0) Installing SDWebImage (5.12.0) Installing SSZipArchive (2.4.2) Installing SwifterSwift (5.2.0) Installing YYModel (1.0.4) Generating Pods project Integrating client project ``` -------------------------------- ### Setup and Start Local Video Preview Source: https://docs.agora.io/en/realtime-media/video/core-concepts Configure and start the local video preview. This allows the user to see their own video feed before joining a channel. ```javascript setupLocalVideo startPreview ``` -------------------------------- ### Main HTTP Server Setup Source: https://docs.agora.io/en/realtime-media/voice/build/optimize-and-operate/receive-notifications Sets up and starts an HTTP server that listens for incoming notifications. It registers handlers for the root path and the NCS notification endpoint, and logs any errors during server startup. ```Go func main() { http.HandleFunc("/", rootHandler) http.HandleFunc("/ncsNotify", ncsHandler) port := ":80" fmt.Printf("Notifications webhook server started on port %s\n", port) if err := http.ListenAndServe(port, nil); err != nil { log.Fatalf("Failed to start server: %v", err) } } ``` -------------------------------- ### Complete Signaling SDK Quickstart Source: https://docs.agora.io/en/signaling/get-started/sdk-quickstart This comprehensive example demonstrates the core functionalities of the Agora Signaling SDK, including client initialization, event listening, user login, channel subscription, message publishing, and user logout. Ensure you replace placeholder values for `userId`, `appId`, and `token`. ```dart import 'package:flutter/material.dart'; import 'package:agora_rtm/agora_rtm.dart'; import 'dart:convert'; void main() async { WidgetsFlutterBinding.ensureInitialized(); const userId = 'your_userId'; const appId = 'your_appId'; const token = 'your_token'; const channelName = 'getting-started'; late RtmClient rtmClient; // Create a Signaling client instance try { // Create rtm client final (status, client) = await RTM( appId, userId); if (status.error == true) { print('${status.operation} failed due to ${status.reason}, error code: ${status.errorCode}'); } else { rtmClient = client; print('Initialize success!'); } // Add events listener rtmClient.addListener( // Add message event handler message: (event) { print('received a message from channel: ${event.channelName}, channel type : ${event.channelType}'); print('message content: ${utf8.decode(event.message!)}, custom type: ${event.customType}'); }, // add link state event handler linkState: (event) { print('link state changed from ${event.previousState} to ${event.currentState}'); print('reason: ${event.reason}, due to operation ${event.operation}'); }); } catch (e) { print('Initialize failed!:${e}'); } // Login to Signaling try { // login rtm service var (status,response) = await rtmClient.login(token); if (status.error == true) { print('${status.operation} failed due to ${status.reason}, error code: ${status.errorCode}'); } else { print('login RTM success!'); } } catch (e) { print('Failed to login: $e'); } // Subscribe to a channel try { var (status,response) = await rtmClient.subscribe(channelName); if (status.error == true) { print('${status.operation} failed due to ${status.reason}, error code: ${status.errorCode}'); } else { print('subscribe channel: ${channelName} success!'); } } catch (e) { print('Failed to subscribe channel: $e'); } // Publish messages // Send a message every second for 100 seconds for (var i = 0; i < 100; i++) { try { var (status, response) = await rtmClient.publish( channelName, 'message number : $i', channelType: RtmChannelType.message, customType: 'PlainText' ); if (status.error == true ){ print('${status.operation} failed, errorCode: ${status.errorCode}, due to ${status.reason}'); } else { print('${status.operation} success! message number:$i'); } } catch (e) { print('Failed to publish message: $e'); } await Future.delayed(Duration(seconds: 1)); } // Unsubscribe from a channel try { var (status,response) = await rtmClient.unsubscribe(channelName); if (status.error == true) { print('${status.operation} failed due to ${status.reason}, error code: ${status.errorCode}'); } else { print('unsubscribe success!'); } } catch (e) { print('something went wrong with logout: $e'); } // Logout of Signaling try { // logout rtm service var (status,response) = await rtmClient.logout(); if (status.error == true) { print('${status.operation} failed due to ${status.reason}, error code: ${status.errorCode}'); } else { print('logout RTM success!'); } } catch (e) { print('something went wrong with logout: $e'); } } ``` -------------------------------- ### Install Dependencies Source: https://docs.agora.io/en/realtime-media/voice/quickstart Navigate to your project directory and install the necessary dependencies using npm. ```bash cd agora-sdk-quickstart npm install ``` -------------------------------- ### Install Build Tools Source: https://docs.agora.io/en/realtime-media/voice/quickstart Install the necessary build tools for compiling the SDK on Debian/Ubuntu-based systems. ```text sudo apt install build-essential python3-dev ``` -------------------------------- ### Activity Setup and Button Clicks Source: https://docs.agora.io/en/signaling/get-started/sdk-quickstart Handles basic Android Activity setup, including view binding and click listeners for login, logout, and subscribe actions. ```java override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) } fun onClickLogin(v: View) { etUserId = findViewById(R.id.uid) val userId = etUserId.text.toString() val token = getString(R.string.token) if (createClient(userId)) { login(token) } } fun onClickLogout(v: View) { logout() } fun onClickSubscribe(v: View) { etChannelName = findViewById(R.id.channel_name) val channelName = etChannelName.text.toString() subscribe(channelName) } ``` -------------------------------- ### Install Fastboard SDK and Dependencies Source: https://docs.agora.io/en/realtime-media/whiteboard/build/set-up-and-build-your-first-app/get-started-uikit Run this npm command to install the Fastboard SDK, Window Manager, and White-web-sdk, which are necessary for building the web application. ```bash npm add @netless/fastboard @netless/window-manager white-web-sdk ``` -------------------------------- ### Start Audio Mixing Source: https://docs.agora.io/en/video-calling/advanced-features/audio-mixing-and-sound-effects This snippet demonstrates how to start playing a music file for audio mixing and register a callback for state changes. ```APIDOC ## Incorporate Audio Mixing Call the `startAudioMixing` method to play a music file. When the music mixing state changes after a successful call to this method, the SDK triggers the `onAudioMixingStateChanged` callback to report the changed music file playback status and the reason for the change. ### Method Signature ```javascript startAudioMixing(options: { filePath: string, loopback?: boolean, cycle?: number, startPos?: number }): void ``` ### Parameters - **filePath** (string) - Required - Sets the music file path. - **loopback** (boolean) - Optional - Sets whether music files are only played locally. `false` indicates that files are published to the remote end, and both local and remote users can hear the music. - **cycle** (number) - Optional - Sets the number of times the music file is played. `-1` means infinite loop playback. - **startPos** (number) - Optional - Sets the playback position of the music file in ms. `0` means playback starts at the beginning. ### Callback - **onAudioMixingStateChanged(state, reason)** - **state** (number) - The state of the music file playback. - **reason** (number) - The reason for the state change. ### Request Example ```javascript // Register the music file's playback state has changed callback const EventHandler = { onAudioMixingStateChanged: (state, reason) => { console.log(`state:${state}, reason:${reason}`); } } rpcEngine.registerEventHandler(EventHandler); // Playing Music Files rpcEngine.startAudioMixing( filePath: 'your file path', // Sets the music file path loopback: false, // Sets whether music files are only played locally. 'false' indicates that files are published to the remote end, and both local and remote users can hear the music cycle: -1, // Sets the number of times the music file is played. -1 means infinite loop playback startPos: 0, // Sets the playback position of the music file in ms. 0 means playback starts st the beginning. ); ``` If you play a short sound effect file using `startAudioMixing`, or a long music file using `playEffect`, the playback may fail. ``` -------------------------------- ### Quick start Go project with Agora CLI Source: https://docs.agora.io/en/introduction/agora-cli Logs in, initializes a new Go starter project, sets up dependencies, and starts the development server using make commands. ```bash agora login agora init my-go-demo --template go cd my-go-demo make setup make dev ``` -------------------------------- ### Rerun pod install After Generating Configuration Source: https://docs.agora.io/en/api-reference/faq/integration/flutter_pod After successfully running `flutter pub get`, rerun `pod install` to complete the iOS dependency setup. ```bash pod install ``` -------------------------------- ### Start Screen Capture by Display ID (After Join) Source: https://docs.agora.io/en/realtime-media/video/reference/release-notes?platform=windows-cpp Start screen capture using `StartScreenCaptureByDisplayId` after joining a channel. Subsequently, call `UpdateChannelMediaOptions` to enable publishing the screen track. ```cpp StartScreenCaptureByDisplayId(displayId); UpdateChannelMediaOptions(ChannelMediaOptions(true, true)); ``` -------------------------------- ### Run the Sample Project Source: https://docs.agora.io/en/realtime-media/broadcast-streaming/build/set-up-your-project/compile-run-sample-project Use this command to start the sample project development server. ```bash npm run dev ``` -------------------------------- ### Start Agent with TypeScript SDK Source: https://docs.agora.io/en/ai/build/start-stop-agent Starts a conversational AI agent by joining an Agora channel. This example demonstrates the setup for Speech-to-Text, Language Model, and Text-to-Speech services. ```typescript import { Agent, AgoraClient, Area, DeepgramSTT, OpenAI, MicrosoftTTS } from 'agora-agents'; const client = new AgoraClient({ area: Area.US, appId: 'your-app-id', appCertificate: 'your-app-certificate', }); const agent = new Agent({ client }) .withStt(new DeepgramSTT({ model: 'nova-3', language: 'en-US' })) .withLlm(new OpenAI({ apiKey: 'your-llm-api-key', url: 'https://api.openai.com/v1/chat/completions', model: 'gpt-4o-mini', systemMessages: [{ role: 'system', content: 'You are a helpful chatbot.' }], greetingMessage: 'Hello, how can I help you?', failureMessage: 'Sorry, I don't know how to answer this question.', maxHistory: 10, })) .withTts(new MicrosoftTTS({ key: 'your-tts-api-key', region: 'eastus', voiceName: 'en-US-AndrewMultilingualNeural', })); const session = agent.createSession({ channel: 'your_channel_name', agentUid: '0', remoteUids: ['1002'], name: 'unique_name', idleTimeout: 120, }); const agentId = await session.start(); console.log('Agent started:', agentId); ``` -------------------------------- ### Initialize and Run Go Starter Project Source: https://docs.agora.io/en/ai/get-started/quickstart Clone the Go starter project, set up dependencies using make, and start the development server. ```bash agora init my-go-demo --template go cd my-go-demo make setup make dev ``` -------------------------------- ### HTTP Request Example for Call Sessions Source: https://docs.agora.io/en/api-reference/api-ref/agora-analytics/analytics-rest-api This example demonstrates how to construct an HTTP GET request to retrieve call session data. It includes required query parameters like start and end timestamps, app ID, call ID, and optional pagination parameters. ```http GET /beta/analytics/call/sessions?start_ts=1548665345&end_ts=1548670821&appid=axxxxxxxxxxxxxxxxxxxx&call_id=cxxxxxxxxxxxxxxxxxxxx&page_no=1&page_size=20&uids=uxx1,uxx2 HTTP/1.1 Host: api.agora.io Accept: application/json Authorization: Basic ZGJhZDMyNmFkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxWQzYTczNzg2ODdiMmNiYjRh ``` -------------------------------- ### Start Transcription Response Example Source: https://docs.agora.io/en/api-reference/api-ref/speech-to-text/rest-api-v6/start Example of a successful response when starting a transcription job. ```APIDOC ## Response example ### 200 ```json { "taskId": "XXXX", "createTs": 1678505852, "status": "IN_PROGRESS" } ``` ### Non-200 ```json { "message": "The reason why the request failed." } ``` ``` -------------------------------- ### Start Audio Mixing in Kotlin Source: https://docs.agora.io/en/video-calling/advanced-features/audio-mixing-and-sound-effects Initiate audio mixing by specifying the file path, whether to play locally, loop count, and start position. Override the callback for audio mixing state changes to handle playback status updates. ```Kotlin mRtcEngine.startAudioMixing( "Your file path", // Specify the path of the local or online music file false, // Set whether to play the music file only locally. false means both local and remote users can hear the music -1, // Set the number of times the music file should be played. -1 indicates infinite loop 0 // Set the starting playback position of a music file ) // Override callback for audio mixing state changes override fun onAudioMixingStateChanged(state: Int, errorCode: Int) { super.onAudioMixingStateChanged(state, errorCode) } ``` ```Kotlin // Pause or resume playing the music file rtcEngine.pauseAudioMixing() rtcEngine.resumeAudioMixing() // Get the total duration of the current music file rtcEngine.getAudioMixingDuration() // Set the playback position of the current music file (e.g., 500 ms) rtcEngine.setAudioMixingPosition(500) // Adjust the playback volume of the current music file for remote users rtcEngine.adjustAudioMixingPublishVolume(50) // Adjust the playback volume of the current music file locally rtcEngine.adjustAudioMixingPlayoutVolume(50) ``` -------------------------------- ### Example GET Request Signature Source: https://docs.agora.io/en/api-reference/api-ref/extensions-marketplace/signature-algorithm An example of a generated signature for a GET request, derived from the specified SourceString and apiSecret. ```text SFVnCVlRbrZcjMPGTWVxAE4QWZ8%3D ``` -------------------------------- ### Run the Sample Project Command Source: https://docs.agora.io/en/realtime-media/broadcast-streaming/build/set-up-your-project/compile-run-sample-project Execute this command in the `/example` directory to start the sample project. Ensure you have Yarn installed. ```bash yarn start ``` -------------------------------- ### Install Dependencies and Run Demo Server Source: https://docs.agora.io/en/realtime-media/broadcast-streaming/build/authenticate-users/deploy-token-server Navigate to the server directory and install dependencies, then run the demo server using Node.js. ```bash npm i node DemoServer.js ``` -------------------------------- ### Run the Demo Server Source: https://docs.agora.io/en/realtime-media/video/build/authenticate-users/deploy-token-server Navigate to the server directory and install dependencies, then run the demo server using npm and node. ```bash npm i node DemoServer.js ``` -------------------------------- ### Get Room Information Request Example Source: https://docs.agora.io/en/api-reference/api-ref/whiteboard/room-management Example of a GET request to retrieve information about a specific whiteboard room. Ensure the 'token' and 'region' headers are correctly set. ```bash GET /v5/rooms/a7exxxxxxa69 Host: api.netless.link region: us-sv Content-Type: application/json token: NETLESSSDK_YWs9xxxxxxM2MjRi ``` -------------------------------- ### Make Setup Script Executable and Run Source: https://docs.agora.io/en/ai/device-kit/build/run-r1-demo Make the downloaded setup script executable and then run it, providing your 2.4 GHz Wi-Fi SSID, password, and your backend ngrok URL. The ngrok URL should be the full HTTPS forwarding URL obtained from 'ngrok http 8000'. ```bash chmod +x bk_aidk_codespaces_setup.sh ./bk_aidk_codespaces_setup.sh \ --ssid "YOUR_WIFI_SSID" \ --password "YOUR_WIFI_PASSWORD" \ --server-url "YOUR_BACKEND_NGROK_URL" ``` -------------------------------- ### HTTP Request Example for Get Call List Source: https://docs.agora.io/en/api-reference/api-ref/agora-analytics/analytics-rest-api This example demonstrates an HTTP GET request to retrieve a list of calls based on specified criteria such as time range, app ID, and pagination. ```http GET /beta/analytics/call/lists?start_ts=1550024508&end_ts=1550025508&appid=xxxxxxxxxxxxxxxxxxxx&page_no=1&page_size=20 HTTP/1.1 Host: api.agora.io Accept: application/json Authorization: Basic ZGJhZDMyNmFkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxWQzYTczNzg2ODdiMmNiYjRh ``` -------------------------------- ### Initialize and Run Python Starter Project Source: https://docs.agora.io/en/ai/get-started/quickstart Clone the Python starter project, install dependencies with bun, and start the development server. ```bash agora init my-python-demo --template python cd my-python-demo bun install bun run dev ``` -------------------------------- ### Install Go SDK Source: https://docs.agora.io/en/ai/build/start-stop-agent Install the Go SDK for the Conversational AI Engine using go get. ```sh go get github.com/AgoraIO/agora-agents-go/v2@v2.2.0 ``` -------------------------------- ### Install and Update Agora Skills with OpenClaw Source: https://docs.agora.io/en/ai/get-started/skills-integrate Manage Agora Skills installation and updates through ClawHub. Use 'install' for the initial setup and 'update' for subsequent upgrades. ```bash clawhub install voice-ai-integration ``` ```bash clawhub update voice-ai-integration ``` -------------------------------- ### Main Server Setup Source: https://docs.agora.io/en/realtime-media/broadcast-streaming/build/connect-across-channels/receive-notifications Sets up and starts the HTTP server, registering handlers for the root path and the notification callback endpoint. It listens on port 80. ```go func main() { http.HandleFunc("/", rootHandler) http.HandleFunc("/ncsNotify", ncsHandler) port := ":80" fmt.Printf("Notifications webhook server started on port %s\n", port) if err := http.ListenAndServe(port, nil); err != nil { log.Fatalf("Failed to start server: %v", err) } } ``` -------------------------------- ### Example Cloud Recording Start Request Body Source: https://docs.agora.io/en/ai/best-practices/record-agent-conversation This JSON object shows an example request body for starting Cloud Recording after the agent is running. It includes configurations for channel name, token, recording settings, and storage. ```json { "cname": "{{AccessChannel}}", "uid": "{{RecordingUID}}", "clientRequest": { "token": "{{token}}", "recordingConfig": { "maxIdleTime": 120, "streamTypes": 0, "audioProfile": 1, "channelType": 1 }, "recordingFileConfig": { "avFileType": [ "hls", "mp4" ] }, "storageConfig": { "vendor": "{{Vendor}}", "region": "{{Region}}", "bucket": "{{Bucket}}", "accessKey": "{{AccessKey}}", "secretKey": "{{SecretKey}}" } } } ```