Ribbon Kandy WebRTC API

API reference on SwaggerHub

Introduction

The Kandy WebRTC API by Ribbon lets you implement web real-time communication (WebRTC) in your application for safe and stable video calls using the Kandy platform. It provides you with a simple model for connecting 2 parties into a call and simplifies the developer experience with its SDKs.

This API is used to create subscribers on the Kandy platform that can make and receive voice and video calls using the Kandy SDKs.

Conceptual model

Conceptual model

Definitions

Products

You must add products to your account’s product inventory before any of your application’s users can make voice and video calls. At the moment only 1 product is exposed in the KPN API store: KPN-VoiceVideo-C. This product entitles a user of your application to take part in a voice and video call.

You will be charged on a monthly basis according to the peak number of products in your inventory during the month.

Orders

Manage your account’s product inventory by making increment or decrement orders. You can add products to the inventory up to an agreed limit and you can decrement the product inventory if you have less demand.

Subscribers

You must define each of your application’s users as a subscriber on the Kandy platform. The subscriber can make or receive voice and video calls when it is created with a KPN-VoiceVideo-C product. Each subscriber will consume 1 of the products in your account’s available product inventory. A subscriber can make calls to other subscribers using the subscriber identity.

The subscriber's identity, and its authentication credentials, are used to initialize the Kandy SDK for making and receiving calls. When a subscriber is deleted, the product that it was using will be returned to your account’s available product inventory. When a subscriber is deleted, any application using this subscriber will be 'forced out' of the Kandy SDK.

Depending on your use case, a subscriber might be persistent (for example, a customer services agent who regularly uses your application to make and receive calls) or temporary (for example, a customer who uses your application infrequently to the customer services agent).

Kandy SDK

Voice and video calls require 3 elements:

  • A WebRTC engine
  • A subscriber on the Kandy platform
  • The application’s user interface

The Kandy SDK provides coordination of these 3 elements to simplify the task of integrating voice and video into an application. The Kandy SDK for JavaScript relies on a WebRTC engine provided by the browser, whereas the Kandy SDKs for iOS and Android come with their own WebRTC engine.

API workflow

Sequence Diagram

WebRTC workflow

API workflow

Prerequirements

This API allows you to provision subscribers and products in order to use Kandy WebRTC. The actual video solution is provided by Kandy. Depending on your platform, you can use web browsers, such as Google Chrome, Mozilla Firefox and Safari – or Software Development Kits (SDK) for Android, iOS or JavaScript.

Constraints

Security

WebRTC is a technology with security as a high priority. Browser applications that wish to use WebRTC must be operating from secure sources so that the media can be secured between the parties in a call.

Getting started

Authentication

To authenticate you'll need to request an access token. Use your API Store app's credentials (Consumer Key and Consumer Secret) to make an authentication request. The authorization service returns a JSON message that contains the access_token field.

Use 1 of the following 3 options:

cURL

Execute the following cURL command to receive an access token. Replace APP_CONSUMER_KEY and APP_CONSUMER_SECRET with your app's credentials.

curl -X POST \
 'https://api-prd.kpn.com/oauth/client_credential/accesstoken?grant_type=client_credentials' \
 -H 'content-type: application/x-www-form-urlencoded' \
 -d 'client_id=APP_CONSUMER_KEY&client_secret=APP_CONSUMER_SECRET'

If you are using cURL for Windows, please use the following command instead.

curl -X POST "https://api-prd.kpn.com/oauth/client_credential/accesstoken?grant_type=client_credentials" -H "content-type: application/x-www-form-urlencoded" -d "client_id=APP_CONSUMER_KEY&client_secret=APP_CONSUMER_SECRET"

The authentication service returns a JSON message that contains the access token field.

{
    "refresh_token_expires_in": "0",
    "api_product_list": "[xxxxxxx]",
    "api_product_list_json": [
        " xxxxxxx"
    ],
    "organization_name": "kpn",
    "developer_email": "demo123@kpn.com",
    "token_type": "Bearer",
    "issued_at": "1521039195424",
    "client_id": "APP_CONSUMER_KEY",
    "access_token": "haf2SDl07E9N7RluNQ4kJ1TkGgso",
    "application_name": "6e38edxxxxxxxxxxxxxxxx4065d79c",
    "scope": "",
    "expires_in": "3599",
    "refresh_count": "0",
    "status": "approved"
}

SwaggerHub

  1. Click on the Authorize button on the top right.
  2. In the form, fill in client_id and client_secret, using your app's credentials.
  3. Click Authorize.

Postman

When using Postman, you will have to import the Swagger file into a Postman collection as follows:

  1. Open the API reference on SwaggerHub.
  2. On the top right, click Export, click Download API and click 'YAML Unresolved'.
  3. In Postman from the menu click File and click Import... Choose the YAML file you downloaded in the previous step. A new collection will be added.
  4. Select Get Access Token from the collection.
  5. Make sure the right environment is selected, corresponding to the API.
  6. Edit the environment variables client_id and client_secret, using your app's credentials.
  7. Check the response code and message.
  8. Press the Send button to get an access token.

Note: Request variables are no longer linked to an environment, but to the collection.

How to...

Provision products and subscribers

Follow these steps to get provisioned for the Kandy WebRTC API:

  1. POST /order: Order the required number of KPN-VoiceVideo-C products into your account’s product inventory. An order number is returned.
  2. GET /order: Retrieve the order number to verify that the order has been fulfilled. If not, contact us. Orders should be fulfilled automatically up to an agreed total EUR limit for your account’s product inventory.
  3. GET /inventory: Check your account’s product inventory to ensure you have the expected number of products.
  4. POST /subscriber: Create a subscriber. Creating a subscriber consumes 1 KPN-VoiceVideo-C product from your account’s product inventory. An error will occur if you don't have sufficient products in your inventory.
  5. Use the subscriber's credentials in your application.
  6. DELETE /subscriber: Delete subscribers after your users have finished with them.
  7. POST /order: If you need to reduce your product inventory, you can make a decrement order.

Note: You don’t need to immediately decrement the product that had been used by the subscriber from your account’s product inventory. You can keep KPN-VoiceVideo-C products available so that you can create more subscribers when needed. See Step 4.

How does KPN charge you?

You are charged for the peak number of products you have in your account’s product inventory for a month.

Note: There is no need to order a new product every time you create a new subscriber. Products will be returned to your account’s product inventory when a subscriber is deleted. You can keep KPN-VoiceVideo-C products in your account’s product inventory so that they are ready and available when you need to create new subscribers.

Use the Kandy SDKs

For more information on how to use Kandy WebRTC SDKs with your applications, please refer to the latest tutorials and documentation on GitHub:

JavaScript (kandy-link-js-sdk)

Check out the SDK documentation and tutorials that guide through the configurations, how to connect users and how to make video and voice calls:

Android (kandy-link-android-sdk)

Check out the tutorials and the SDK reference:

iOS (kandy-link-ios-sdk)

Check out the tutorials and the SDK reference: