Skip to main content

How to create a Virtual Situation Room with Python

Creating a virtual situation room with Python is straightforward using the Eyeson API. By leveraging Python's requests library, you can quickly set up a secure video meeting environment that mimics a traditional situation room.

First, you'll need to import the necessary libraries for making HTTP requests, handling JSON data, and opening the meeting in a web browser. Then, configure the API endpoint and your authentication credentials. The room can be customized with specific options like widescreen mode and disabling SFU mode so you can use the advanced features of the MCU even if alone in the call.

import requests
import json
import webbrowser

base_url = 'https://api.eyeson.team'
api_key = input("Enter your API key: ")
headers = {
'Authorization': api_key,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
payload = {
'id': '1Meeting',
'user': {'name': 'John Doe'},
'options': {
'sfu_mode': 'disabled',
'widescreen': True
}
}

try:
response = requests.post(base_url + '/rooms', headers=headers, json=payload, timeout=100)
response.raise_for_status() # Raises an HTTPError for bad responses

try:
data = response.json()

except json.JSONDecodeError as e:
print("Failed to decode JSON response:", e)
print("Raw response:", response.text)

except requests.exceptions.RequestException as e:
print("Request failed:", e)

# open a browser to actively join the meeting
#
# If you need a guest link to distribute this is also very easy from this point
# guest_link = data['links']['guest']

webbrowser.open(data['links']['gui'])
# In further steps you might need the access_key
access_key=data['access_key']