---
# System prepended metadata

title: Zoom API
tags: [ZoomAPI, ' 會議室借用']

---

---
tags: ZoomAPI, 會議室借用
---
# Zoom API

[Zoom APIs](https://marketplace.zoom.us/docs/api-reference/introduction)

## Using JWT

> Register a JWT app in the Zoom App Marketplace. Use the token generated from the JWT app and start making API requests to the Zoom APIs.

## API requests

All API requests must be made over HTTPS.   
The https://api.zoom.us/v2/ URL is the request base URL. The complete URL varies depending on the accessed resource.

## Using Postman to Test Zoom APIs

1. Authorization > Configure New Token

| 欄位名稱 | 內容值 | 說明 |
| -------- | -------- | -------- |
| Token Name | TLC-booking | 和 Oauth APP 名稱一樣  |
| Callback URL | 勾Authorize using browser | 預設URL要貼去Oauth APP 的 redirect url、whitelist url `https://oauth.pstmn.io/v1/callback` |
| Auth URL | `https://zoom.us/oauth/authorize`|   |
| Access Token URL | `https://zoom.us/oauth/token` |   |
| Client ID | Client ID | 和 Oauth APP Client ID一樣  |
| Client Secret | Client Secret | 和 Oauth APP Client Secret一樣  |

2. 點 Get New Access Token，會開出Zoom的授權畫面
3. 授權後會跳回Postman(記得網頁要開啟允許彈出視窗)
4. 選擇Use Token，token會回填Access Token
5. 可以向API請求資料了唷

## Using Python 3rd party package: zoomus

[zoomus GitHub Source](https://github.com/prschmid/zoomus)

Official sample:
```python
import json
from zoomus import ZoomClient

client = ZoomClient('API_KEY', 'API_SECRET')

user_list_response = client.user.list()
user_list = json.loads(user_list_response.content)

for user in user_list['users']:
    user_id = user['id']
    print(json.loads(client.meeting.list(user_id=user_id).content))
```

## API

### List Meeting

> GET meetings/{meetingId}

#### Query Parameters

- type  (string)  
scheduled  
live  
upcoming  
- page_size  (integer)  
- next_page_token  (string)  
- page_number  (page_number)  

#### 說明

1. 使用 type=upcoming 取得現在時間之後的會議，會取得所有時間確定的會議，包含週期性會議(前提是週期會議有確切時間)。
2. 沒有辦法用時間篩選

#### zoomus

```python
client.meeting.list(user_id=xxx, type='upcoming')
```

如果需要時間篩選，大概只能先讀出來然後用filter篩

```python
# 以下篩 20201/12/20 - 2021/12/25
def get_timebounded_mt(mt):
    start = mt['start_time']
    st = dt.strptime(start, '%Y-%m-%dT%H:%M:%SZ')
    bounded_s = dt(2021,12,20,0,0,0)
    bounded_e = dt(2021,12,25,0,0,0)
    if st > bounded_s and st < bounded_e:
        return mt

filtered = filter(get_timebounded_mt, meeting_list)
```

### Get Meeting


> GET user/{userId}/meetings/

#### Query Parameters

- occurrence_id(string)
- show_previous_occurrences(boolean)

#### 說明
.
#### zoomus

```python
client.meeting.get(id=xxx)
```

### Create Meeting

> POST /users/{userId}/meetings

```json
//example

{
    "topic": "topic",
    "type": 8,
    /* 1.instant meeting;
    2.scheduled meeting;
    3.recurring meeting without fixed time;
    4.recurring meeting with fixed time.*/
    "start_time": "2021-12-17T18:00:00",
    /*會是18:00(timezone一定要設定，預設Zoom帳號時區)，如果是2021-12-17T18:00:00Z，則是隔天02:00*/
    "duration": 60,
    "schedule_for": "zoom5@tiongliong.com",
    "timezone": "Asia/Taipei",
    "recurrence": {
        "type": 2,
        /*1. Daily;
        2.Weekly;
        3.Monthly*/
        "repeat_interval": "2",
        "weekly_days": "6",
        /*1.Sun;
        2.Mon;
        3.Tue;
        4.Wed;
        5.Thu;
        6.Fri;
        7.Sat*/
        "end_date_time": "2021-12-31"
        // monthly_week: -1.last week;1.first week;2.second week;3.third week;4.4th week
        // monthly_week_day: same as weekly_days
    }
}
```
#### zoomus

```python
import datetime

payload = {
    "topic": "Meeting from Cmder",
    "start_time": datetime.datetime(2021,12,24,8,0,0), # 實際上是16:00，要記得自己減8
    "duration": 60,
    "agenda": "It's a meeting from cmder, for testing",
    "timezone": "Asial/Taipei",
}

new_meeting = client.meeting.create(id=xxx, **payload)

join_url = json.loads(new_meeting.content).get('join_url')

print(join_url)
>> https://zoom.us/j/96332327403?pwd=QXJZN09rak5PYWRFQlI4b3V1Wk92QT09
```

### Update Meeting

> PATCH meetings/{meetingId}

```json
//example

{
    "topic": "測試TOPIC",
    "start_time": "2021-12-17T18:00:00",
    "duration": 60
}
```

#### zoomus

```python
import datetime

payload = {
    "topic": "Meeting from Cmder",
    "agenda": "It's a meeting from cmder, for testing",
}

updated_meeting = client.meeting.update(id=xxx, **payload)

agenda = json.loads(updated_meeting.content).get('agenda')

print(agenda)
>> It's a meeting from cmder, for testing
```

### Delete Meeting

> DELETE meetings/{meetingId}

#### zoomus

```python

client.meeting.delete(id=96721165058)
```

### Get Meeting Invitation

> GET /meetings/{meetingId}/invitation

#### zoomus
沒有這種東西  
要自己用上面的meeting資料湊  

**週期性會議的邀請**  
> Pei Ying Chang 邀請您參加排程的 Zoom 會議。
>
>主題：資訊週會
>時間：2021年12月27日 15:30 台北
>        每星期的星期一，共 到 2022年1月31日結束，共 6 次會議
>        2021年12月27日 15:30
>        2022年1月3日 15:30
>        2022年1月10日 15:30
>        2022年1月17日 15:30
>        2022年1月24日 15:30
>        2022年1月31日 15:30
>請下載下列 iCalendar（.ics）檔案並匯入到您的日曆系統。
>按週：https://zoom.us/meeting/tJEocuqvrDwsHNUESzIT2c2S0CJpT4JiYaHb/ics?icsToken=98tyKuCtqz4pHdaSth-GRowMGY_4b-3zpmZdgo1ouSz_KhQBYVHFZsFoIoYrOtHp
>
>加入 Zoom 會議
>https://zoom.us/j/95553727661?pwd=TGxTNUhHVUpTNTFaZVZqcmhla1VSdz09
>
>會議 ID：955 5372 7661
>密碼：A7mQr0

**單次會議的邀請**
>Pei Ying Chang 邀請您參加排程的 Zoom 會議。
>
>主題：怕以求
>時間：2021年12月28日 14:00 台北
>
>加入 Zoom 會議
>https://zoom.us/j/93589020490?pwd=c2RhbnhoR0VxNGM3ZkpNdTlhbllVdz09
>
>會議 ID：935 8902 0490
>密碼：b3ZzxL


### Create Meeting Invitation

> POST /meetings/{meetingId}/invite_links

#### zoomus
沒有這種東西

#### Request Body

- ttl(intger)
- attendees(array)
  - name(string)

```json
//example
{
  "ttl": 3600,//default: 7200
  "attendees": [
    {
      "name": "Mike Brown"
    }
  ]
}
```

## 可設定的週期

- 每 X 天  
- 每 X 周 星期 O  
- 每 X 個月 第 O 日  
- 每 X 個月 第 X 周 星期 O

