Endpoints
BRTC introduces the concept of an Endpoint, which is any device that can make or receive a call. Currently, BRTC supports only supports WebRTC Endpoints. Visit the Endpoints API reference for more information on how to manage your Endpoints. The Endpoints APIs are available in all of our SDKs.
WebRTC Endpoints are devices that use the WebRTC protocol to make and receive calls. These devices can be browsers, mobile applications, or any other device that supports WebRTC.
The kind of Endpoint, and related metadata, are meant to instruct Bandwidth on how to communicate with that Endpoint, and allows control of the Endpoint's lifecycle.
During the lifecycle of an Endpoint, you can opt to receive webhooks to inform your platform of Endpoint lifecycle state changes as they happen. This can include:
- When a device connects or disconnects using an Endpoint token
- Each unique connection of an endpoint is assigned a device id for easier tracking
- When a device has negotiated with Bandwidth, and is available to be
<Connect>ed with - When a device is
<Connect>ed - When a device has concluded a call, and is available again
Examples
Register a WebRTC Endpoint
- cURL
- Java
- C#
- Ruby
- NodeJS
- Python
- PHP
curl -X POST https://api.bandwidth.com/v2/accounts/{accountId}/endpoints \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"type": "WEBRTC",
"direction": "BIDIRECTIONAL",
"eventCallbackUrl": "https://myEventCallbackUrl.com/callbacks/bandwidth",
"eventFallbackUrl": "https://fallback.myEventCallbackUrl.com/callbacks/bandwidth",
"tag": "{\"myTag\": \"myTagValue\"}"
}'
import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.api.EndpointsApi;
import com.bandwidth.sdk.model.CreateEndpointResponse;
import com.bandwidth.sdk.model.CreateWebRtcConnectionRequest;
import com.bandwidth.sdk.model.EndpointDirectionEnum;
import com.bandwidth.sdk.model.EndpointTypeEnum;
public class Example {
public static void main(String[] args) {
// The SDK exchanges your client ID and secret for an OAuth access token automatically.
ApiClient client = new ApiClient("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", null);
EndpointsApi apiInstance = new EndpointsApi(client);
String accountId = "9900000";
CreateWebRtcConnectionRequest body = new CreateWebRtcConnectionRequest()
.type(EndpointTypeEnum.WEBRTC)
.direction(EndpointDirectionEnum.BIDIRECTIONAL)
.eventCallbackUrl("https://myEventCallbackUrl.com/callbacks/bandwidth")
.eventFallbackUrl("https://fallback.myEventCallbackUrl.com/callbacks/bandwidth")
.tag("{\"myTag\": \"myTagValue\"}");
try {
CreateEndpointResponse result = apiInstance.createEndpoint(accountId, body);
System.out.println(result);
} catch (ApiException e) {
e.printStackTrace();
}
}
}
using System;
using Bandwidth.Standard.Api;
using Bandwidth.Standard.Client;
using Bandwidth.Standard.Model;
namespace Example
{
public class CreateEndpointExample
{
public static void Main()
{
Configuration config = new Configuration();
// The SDK exchanges your client ID and secret for an OAuth access token automatically.
config.OAuthClientId = "YOUR_CLIENT_ID";
config.OAuthClientSecret = "YOUR_CLIENT_SECRET";
var apiInstance = new EndpointsApi(config);
var accountId = "9900000";
var webRtcRequest = new CreateWebRtcConnectionRequest(
type: EndpointTypeEnum.WEBRTC,
direction: EndpointDirectionEnum.BIDIRECTIONAL,
eventCallbackUrl: "https://myEventCallbackUrl.com/callbacks/bandwidth",
eventFallbackUrl: "https://fallback.myEventCallbackUrl.com/callbacks/bandwidth",
tag: "{\"myTag\": \"myTagValue\"}"
);
try
{
CreateEndpointResponse result = apiInstance.CreateEndpoint(accountId, new CreateEndpointRequest(webRtcRequest));
Console.WriteLine(result);
}
catch (ApiException e)
{
Console.WriteLine("Exception when calling EndpointsApi.CreateEndpoint: " + e.Message);
}
}
}
}
Coming Soon
import {
EndpointsApi,
Configuration,
CreateWebRtcConnectionRequest,
EndpointTypeEnum,
EndpointDirectionEnum
} from 'bandwidth-sdk';
// The SDK exchanges your client ID and secret for an OAuth access token automatically.
const configuration = new Configuration({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET'
});
const apiInstance = new EndpointsApi(configuration);
const accountId = '9900000';
const body: CreateWebRtcConnectionRequest = {
type: EndpointTypeEnum.Webrtc,
direction: EndpointDirectionEnum.Bidirectional,
eventCallbackUrl: 'https://myEventCallbackUrl.com/callbacks/bandwidth',
eventFallbackUrl: 'https://fallback.myEventCallbackUrl.com/callbacks/bandwidth',
tag: '{"myTag": "myTagValue"}'
};
const { status, data } = await apiInstance.createEndpoint(accountId, body);
console.log(data);
import os
from bandwidth import ApiClient, Configuration
from bandwidth.api.endpoints_api import EndpointsApi
from bandwidth.models.create_web_rtc_connection_request import CreateWebRtcConnectionRequest
from bandwidth.models.endpoint_direction_enum import EndpointDirectionEnum
from bandwidth.models.endpoint_type_enum import EndpointTypeEnum
from bandwidth.rest import ApiException
from pprint import pprint
# The SDK exchanges your client ID and secret for an OAuth access token automatically.
configuration = Configuration(
client_id=os.environ["CLIENT_ID"],
client_secret=os.environ["CLIENT_SECRET"]
)
with ApiClient(configuration) as api_client:
api_instance = EndpointsApi(api_client)
account_id = '9900000'
body = CreateWebRtcConnectionRequest(
type=EndpointTypeEnum.WEBRTC,
direction=EndpointDirectionEnum.BIDIRECTIONAL,
event_callback_url='https://myEventCallbackUrl.com/callbacks/bandwidth',
event_fallback_url='https://fallback.myEventCallbackUrl.com/callbacks/bandwidth',
tag='{"myTag": "myTagValue"}'
)
try:
api_response = api_instance.create_endpoint(account_id, body)
pprint(api_response)
except ApiException as e:
print("Exception when calling EndpointsApi->create_endpoint: %s\n" % e)
Coming Soon