Socket
Book a DemoInstallSign in
Socket

clique-api

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clique-api

Clique API wrapper

1.4.2
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
4
Weekly downloads
 
Created
Source

= Clique Node.js API SDK

== Installing Clique JS Client SDK

Clique Node.js SDK ( "Clique Server" ) is available via npm

npm install --save clique-api-node

Example of usage

import cliqueAPI from 'clique-api-node'

== API Reference

=== getNextRequestApiKey(): String Gets the api key

cliqueAPI.getNextRequestApiKey();

=== newUser(userData) : Promise Creates new user for conference

cliqueAPI.newUser({ display_name: 'yourname', email: 'youraddress@yourdomain.com', });

=== getUserById(userId) : Promise Get user data by id

cliqueAPI.getUserById('74416d26-fe68-4773-8e8f-307eb7eafd22');

=== updateUser(userData) : Promise Updates user

cliqueAPI.updateUser({ uuid: '74416d26-fe68-4773-8e8f-307eb7eafd22', display_name: 'yourname', email: 'youraddress@yourdomain.com', });

=== userToken(userId) : Promise Gets user token by user id

cliqueAPI.userToken('74416d26-fe68-4773-8e8f-307eb7eafd22') : Promise

=== userToken(userId) : Promise Creates new conference

cliqueAPI.createNewConference();

=== getConferenceById(confId) : Promise Gets conference information by id

cliqueAPI.getConferenceById('74416d26-fe68-4773-8e8f-307eb7eafd22');

== Conference API Reference

=== conferencesApi.createConference(confData) : Promise Creates new conference

cliqueAPI.conferencesApi.createConference();

=== conferencesApi.getConferenceById(conf_id) : Promise Gets conference information by id

cliqueAPI.conferencesApi.getConferenceById('74416d26-fe68-4773-8e8f-307eb7eafd22');

=== conferencesApi.getConferenceParticipantsList(conf_id) : Promise Get Conference Participants List

cliqueAPI.conferencesApi.getConferenceParticipantsList('74416d26-fe68-4773-8e8f-307eb7eafd22');

=== conferencesApi.updateConference(conf_id) : Promise Update Conference by id

cliqueAPI.conferencesApi.updateConference({ id: '74416d26-fe68-4773-8e8f-307eb7eafd22', allow_anonymous: true, });

=== conferencesApi.search(searchParams) : Promise Search Conference

cliqueAPI.conferencesApi.search({ phone_number: '123456789', });

== conferencesApi.startConference(conf_id) : Promise Assign phone to conference, assign node domain to conference if it mentioned in conference settings

cliqueAPI.conferencesApi.startConference('74416d26-fe68-4773-8e8f-307eb7eafd22');

== User API Reference

=== userApi.createUser(userData) : Promise Creates new user

cliqueAPI.userApi.createUser({ display_name: 'yourname', email: 'youraddress@yourdomain.com', });

=== userApi.getUserById(user_id) : Promise Gets user by id

cliqueAPI.userApi.getUserById('74416d26-fe68-4773-8e8f-307eb7eafd22');

=== userApi.getUserById(userData) : Promise Updates user by id

cliqueAPI.userApi.updateUser({ uuid: '74416d26-fe68-4773-8e8f-307eb7eafd22', display_name: 'yourname', email: 'youraddress@yourdomain.com', });

=== userApi.getUserToken(userData) : Promise Gets User token

cliqueAPI.userApi.getUserToken('74416d26-fe68-4773-8e8f-307eb7eafd22');

=== userApi.getUserToken(searchParams) : Promise Search user

cliqueAPI.userApi.search({ enabled: true, });

== Recording API Reference

=== userApi.startRecording(conf_id) : Promise Starts recording conference

cliqueAPI.recordingApi.startRecording('74416d26-fe68-4773-8e8f-307eb7eafd22');

=== recordingApi.stopRecording(conf_id) : Promise Stops recording

cliqueAPI.recordingApi.stopRecording('74416d26-fe68-4773-8e8f-307eb7eafd22')

=== recordingApi.conferenceRecording(conf_id) : Promise Get Conference recording information

cliqueAPI.recordingApi.conferenceRecording('74416d26-fe68-4773-8e8f-307eb7eafd22')

=== recordingApi.getRecording(record_uid) : Promise Gets recording by id

cliqueAPI.recordingApi.getRecording('74416d26-fe68-4773-8e8f-307eb7eafd22')

=== recordingApi.deleteRecording(record_uid) : Promise Deletes recording by recording id

cliqueAPI.recordingApi.deleteRecording('74416d26-fe68-4773-8e8f-307eb7eafd22')

== Invite API Reference

=== inviteApi.createInviteTemplate(templateData): Promise Creates Invite Template

cliqueAPI.inviteApi.createInviteTemplate({ name: 'invite timplate', type: 'email', template: 'hi thare, please come to the meeting from {company}, {name}', context_id: '74416d26-fe68-4773-8e8f-307eb7eafd22', });

=== inviteApi.createInviteTemplate(template_name): Promise Gets Invite Template By Template Name

cliqueAPI.inviteApi.getInviteTemplateByName('invite timplate');

=== inviteApi.updateInviteTemplate(templateData) : Promise Updates Invite Template

cliqueAPI.inviteApi.updateInviteTemplate({ name: 'invite timplate', type: 'sms', });

=== inviteApi.deleteInviteTemplate(template_name) : Promise Deletes Invite Template

cliqueAPI.inviteApi.deleteInviteTemplate('invite timplate');

=== inviteApi.sendInvites(conference_id, invitesData) : Promise Sends Invite

cliqueAPI.inviteApi.sendInvites('74416d26-fe68-4773-8e8f-307eb7eafd22', { sms: { template_name: 'invite timplate', template_params: { company: 'My Person call', name: 'John Doe', }, contacts: [ '12345678', '87654321' ], }, });

== Context API Reference

=== contextsApi.createContext(contextData) : Promise Creates Context

cliqueAPI.contextsApi.createContext({ external_id: 'asdac7182-fe68-4773-8e8f-307eb7eafd22', display_name: 'my context', parent_path: 'somepath/to/context', });

=== contextsApi.getContextById(context_id) : Promise Gets Context By Id

cliqueAPI.contextsApi.getContextById('74416d26-fe68-4773-8e8f-307eb7eafd22')

=== contextsApi.updateContext(contextData) : Promise Updates Context

cliqueAPI.contextsApi.updateContext({ id: '74416d26-fe68-4773-8e8f-307eb7eafd22', external_id: 'asdac7182-fe68-4773-8e8f-307eb7eafd22', display_name: 'my context', parent_path: 'somepath/to/context', })

=== contextsApi.search(searchParams) : Promise Search Context

cliqueAPI.contextsApi.search({ display_name: 'my context', });

== Clique Node.js SDK Tutorial

The Clique service lets you add advanced and high quality audio conferencing capabilities to your application.

Quickstart

For a quick start please follow these steps:

  • First, obtain an API key, BASE URL (API_KEY, BASE_URL) from Clique. At this point, Clique technical support will need to provide those to you

  • This tutorial assumes that you use node.js on your server side. At the time of writing node.js v7.10 was used.

  • Init npm project

npm init

  • Install express.js

npm i --save express

  • Set up the server logic (server.js)

const express = require('express'); const route = express.Router(); const app = express();

app .use(route) .use(express.static(__dirname +"/public"));

  • Set up the view template (public/index.html)
-----------------------------------
  • Install Clique API npm package

npm i --save clique-api

  • Add the following dependency to your server code

const cliqueApi = require('clique-api');

  • Create an instance of the Clique API SDK using API_KEY, BASE_URL which you obtained from Clique

const clique = new cliqueApi('<API_KEY>', '<BASE_URL>' + '/api/v2');

  • Next you should create a User object which will be needed to create and join a conference
  • NOTE (if you're using guid from step "2", please set code below inside the block) Add route to get the User data

route .post('/user', (req, res) => { // insert code to get Clique User here });

  • Getting Clique user

clique.newUser({ display_name: 'yourname', email: 'youraddress@yourdomain.com' }) .then(data => { res.json(data); });

  • To access a conference you needs to have its conference ID. This is a way to get it:

route .post('/conference', (req, res) => { clique.createNewConference() .then(data => { res.json(data); }); });

  • Next, you need to install all the client dependencies. You can use the bower package manager or can use npm or just copy-paste
  • NOTE if bower is not initialized, please run this command below:

npm i --save bower ./node_modules/.bin/bower init

  • configure .bowerrc - add this file to the root folder and then set content as shown below:

{ "directory": "public/components" }

  • install client side packages

./node_modules/.bin/bower install --save clique-api-client-js#2.2.3

  • Let's implement the client side code. First, let's take care of html (public/index.html):

Join Conference

Join! Mute Hangup

Info

Your ID

Talking now

-----------------------------------
  • The client script has a dependency from jQuery, socket.io, verto.js and clique.js (part of Clique JS SDK). Please add following code to the end of your page:

<! Clique Client JS SDK -->

  • Next step is to implement the client script handler in the public/js/app.js file

( async ()=>{ // insert your code here })();

  • Get Clique User Info

let data = await fetch("/user", {method: "POST"}); let cliqueSession = await data.json();

  • Get Conference ID

let dataConf = await fetch("/conference", {method: "POST"}); let conf = await dataConf.json();

  • Create an instance of Clique API Client

const client = new CliqueClient({ api_endpoint: '<BASE_URL>' + '/api/v2', websocket_endpoint: '<WS_URL>' + '/', user_token: cliqueSession.token, user_uuid: cliqueSession.uuid, wss_port: 8082, });

  • We are almost done. Next few steps will deal with updating the conference properties
  • Determine the User ID

document.getElementById("id_profile").textContent = cliqueSession.sip_id;

  • Add handler to join the conference

document.getElementById('joinConference') .addEventListener('click', async () => { await client.joinRoom(conf.id); });

  • Add handler to close the conference

document.getElementById('hangup') .addEventListener('click', async () => { await client.closeRoom(conf.id); });

  • Add handler to mute/unmute the microphone

let mute = false; let elMute = document.getElementById("mute"); elMute.addEventListener("click", (e) => { if(!mute) { client.localMute(conf.id); elMute.textContent = 'unmute'; elMute.classList.remove("btn-danger"); elMute.classList.add("btn-success"); mute = true; } else { client.localUnmute(conf.id); elMute.textContent = 'mute' elMute.classList.remove("btn-success"); elMute.classList.add("btn-danger"); mute = false; } });

  • Add start/stop talking events watch, triggered when someone started/stopped talking into the conference

client.on("start-talking", event => { document.getElementById("talking").textContent = event.user_id+" is talking"; });

client.on("stop-talking", event => { document.getElementById("talking").textContent = ""; });

  • That's it, we are done. You can start your server and run your app

node server.js // it will run on localhost:3000

FAQs

Package last updated on 26 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.