— 4 min read
Image credits: marketplace.zoom.us
So here we will discuss how can we integrate ZOOM.US in any application to create and schedule video meetings. Just like any other application, Zoom is also following RESTful architecture and has exposed its APIs that are accessible via HTTP at specified URLs for specified resources. Here we will be covering 2 resources :
Let’s take an example to understand it better. If you have a use case in which various teachers want to conduct classrooms at the same time then you need to have multiple users in your accounts and those users will act as hosts for meetings. This resource is available at this URL: https://api.zoom.us/v2/users
2. Meetings: This is the resource of interest here. Zoom allows one to schedule meetings on behalf of different hosts.
This resource is available at this URL: https://api.zoom.us/v2/user/{userId}/meetings. We will learn more about the param {userId} later in this article.
Before going further, it would be great if you can get your hands on official Postman collection available on this link :
[https://marketplace.zoom.us/docs/guides/tools-resources/postman/using-postman-to-test-zoom-apis](http://Using Postman to Test Zoom APIs)
This collection is having many APIs exposed for various resources provided by Zoom.
For using the APIs, one needs to create a JWT application in Zoom Market place. So, What is JWT or JSON web token?
JSON Web Tokens are an open, industry-standard RFC 7519 method for representing claims securely between two parties. — JWT.io
This is a bit technical but apt. In simple terms, JWTs are base64 encoded strings that are passed via headers in an HTTP call be it POST, GET, PUT, etc. It allows authentication/authorization of the user who is trying to access the resources from some other application server. In this case, it will be Zoom servers where they are maintaining the data related to meetings and users, and many other resources.
To create a JWT application in the market place, please follow this detailed article from Zoom. https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-jwt-app
After creating the application, you will have access to the Secret key and API key with which you will generate tokens and pass in your API requests.
Note: It is highly recommended to set the exp timestamp for a short period, i.e. a matter of seconds. This way, if a token is intercepted or shared, the token will only be valid for a short period. — Zoom
Here is the code snippet for generating the tokens in Node.js :
1const jwt **\=** require('jsonwebtoken'); // npm package link [here](https://www.npmjs.com/package/jsonwebtoken)const token **\=** jwt.sign({ 2 "iss": process.env.ZOOM\_API\_KEY, 3 "exp": 1496091964000 4}, process.env.ZOOM\_SECRET);
I prefer passing the Secret key and API key as env variables. You can use any other secure way as well for eg. Azure Key vault. Remember to keep your token lifespan as short as possible. This will make the implementation more secure.
Since we have generated the token, we are ready to use it for making API calls. Here are the steps :
To create such users, we will make a POST API call to https://api.zoom.us/v2/users with the following body :
1{ 2 "action": "custCreate", 3 "user\_info": { 4 "email": "james@bond.com", 5 "type": 1, 6 "first\_name": "James", 7 "last\_name": "Bond" 8 } 9}
Follow this detailed article from Zoom for more info: https://marketplace.zoom.us/docs/api-reference/zoom-api/users/usercreate.
We are using a field “action” with the value of “custCreate” in our payload.
Users created via this option do not have passwords and will not have the ability to log into the Zoom Web Portal or the Zoom Client. — Zoom API docs
Here is the code snippet we can use to call this API in Node.js
1const request = require("request");const options = { 2 method: 'POST', 3 url: 'https://api.zoom.us/v2/users', 4 headers: {'content-type': 'application/json', authorization: \`Bearer ${token}\`}, 5 body: { 6 "action": "custCreate", 7 "user\_info": { 8 "email": "james@bond.com", 9 "type": 1, 10 "first\_name": "James", 11 "last\_name": "Bond" 12 } 13}, 14 json: true 15};request(options, function (error, response, body) { 16 if (error) throw new Error(error); 17 console.log(body); 18});
Note: We are passing the generated token in the “Authorization Header” of the request.
The response which you get after the success of this API call will have a field “id” that you have to keep handy (better store it in your database) to schedule meetings on behalf of James Bond. Let’s assume the response is this
1{ 2 “id”: “wAdE5hVfRUy3k305kAjBmA”, 3 “first\_name”: “James”, 4 “last\_name”: “Bond”, 5 “email”: “[james@bond.com](mailto:james@bond.com)”, 6 “type”: 1 7}
This id will be used as {userId} param while calling Meeting API.
Note: Zoom provides GET API to fetch user related information. Follow the docs.
2. Create meetings: Since we have both the token and “id” of the user, we can start scheduling the meetings for James Bond.
For this, we will make a POST API call to https://api.zoom.us/v2/users/{userId}/meetings.
You need to replace {userId} with the id of James Bond which is “wAdE5hVfRUy3k305kAjBmA”. Now the URL becomes
https://api.zoom.us/v2/users/wAdE5hVfRUy3k305kAjBmA/meetings.
Send this data in the post request :
1{ 2 "topic": "Demo Meeting 1", 3 "type": 2, 4 "start\_time": "2020-05-05 12:00:00", 5 "password": "Hey123", 6 "agenda": "This is the meeting description", 7 "settings": { 8 "host\_video": false, 9 "participant\_video": false, 10 "join\_before\_host": false, 11 "mute\_upon\_entry": true, 12 "use\_pmi": false, 13 "approval\_type": 0 14 } 15}
Follow this detailed article from Zoom for more info:
https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate.
Here is the code snippet we can use to call this API in Node.js
1const request = require("request");const options = { 2 method: 'POST', 3 url: 'https://api.zoom.us/v2/users/wAdE5hVfRUy3k305kAjBmA/meetings', 4 headers: {'content-type': 'application/json', authorization: \`Bearer ${token}'}, 5 body: { 6 topic: 'Demo Meeting 1', 7 type: 2, 8 start\_time: '2020-05-05 12:00:00', 9 password: 'Hey123', 10 agenda: 'This is the meeting description', 11 settings: { 12 host\_video: false, 13 participant\_video: false, 14 join\_before\_host: false, 15 mute\_upon\_entry: true, 16 use\_pmi: false, 17 approval\_type: 0 18 } 19 }, 20 json: true 21};request(options, function (error, response, body) { 22 if (error) throw new Error(error);console.log(body); 23});
Note: We are again passing the generated token in the “Authorization Header” of the request.
Let’s assume the response of this API call is this
1{ 2 “uuid”: “AoHcLp0rRF6i1rjALIK8Pg==”, 3 “id”: 8766521755, 4 “host\_id”: “wAdE5hVfRUy3k305kAjBmQ”, 5 “topic”: “Demo Meeting 1”, 6 “type”: 2, 7 “status”: “waiting”, 8 “start\_time”: “2020-05-05 12:00:00”, 9 “timezone”: “America/Los\_Angeles”, 10 “created\_at”: “2020–05–01T20:23:25Z”, 11 “start\_url”: “https://zoom.us/s/98256521755?zak=eyJ6bV9za20iOiJ6bV9vMm0iLCJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjbGllbnQiLHZEdxNER1TEFnIiwiY2lkIjoiIn0.\_v772e7BPedl\_P4Gb5wFPx3qKqtVF4bQkUrjnzUeZwE", 12 “join\_url”: “https://zoom.us/j/8766521755", 13 “settings”: { 14 host\_video: false, 15 participant\_video: false, 16 join\_before\_host: false, 17 mute\_upon\_entry: true, 18 use\_pmi: false, 19 approval\_type: 0 20 } 21}
Ta-da! We have successfully scheduled a zoom meeting via Zoom APIs for James Bond.
Note: Zoom provides GET API to fetch meeting related information. Follow the docs.
Store this information in your database according to your Database design. I would prefer to use my database for fetching all the meetings scheduled via API rather than calling Zoom APIs each time I want the data because making API calls from your servers to the Zoom servers for various resources will always add latency to your systems. So store the responses received from the API calls in your database for faster access.
That’s all folks! Let me know in case of any issues.
Zoom API documentation is quite clean and efficient. Follow it here :