Webex Teams SDK
The `webexteamssdk` is a community-developed Python SDK for interacting with the Webex Teams (now Webex App) APIs. While it achieved its last official release at v1.7, the project has been superseded by `webexpythonsdk` since October 2022, which is now the actively maintained version. Users are strongly encouraged to migrate to `webexpythonsdk` for new projects and ongoing development.
Warnings
- breaking `webexteamssdk` is officially deprecated. The maintainers have replaced it with `webexpythonsdk` (available via `pip install webexpythonsdk`). While functionally similar, `webexpythonsdk` requires Python 3.10+ and uses a different package name.
- gotcha The original GitHub repository `CiscoDevNet/webexteamssdk` is no longer actively maintained. All new development and bug fixes are happening in the `WebexCommunity/WebexPythonSDK` repository, which corresponds to the `webexpythonsdk` package.
- gotcha API access requires an access token. The SDK primarily expects it via the `WEBEX_TEAMS_ACCESS_TOKEN` environment variable. Misconfiguration often leads to `401 Unauthorized` errors.
- gotcha Webex APIs are rate-limited. While `webexteamssdk` has some retry mechanisms, intensive use might hit limits. Malformed `Retry-After` headers from the API could historically cause crashes (fixed in `webexpythonsdk` v2.0.5).
Install
-
pip install webexteamssdk
Imports
- WebexTeamsAPI
from webexpythonsdk import WebexTeamsAPI
from webexteamssdk import WebexTeamsAPI
Quickstart
import os
from webexteamssdk import WebexTeamsAPI
# Initialize the API connection
# By default, the SDK looks for a WEBEX_TEAMS_ACCESS_TOKEN environment variable.
# Ensure your Webex access token is set in your environment.
access_token = os.environ.get('WEBEX_TEAMS_ACCESS_TOKEN', '')
if not access_token:
print("Error: WEBEX_TEAMS_ACCESS_TOKEN environment variable not set.")
print("Please get a token from developer.webex.com/my-apps and set it.")
else:
try:
api = WebexTeamsAPI(access_token=access_token)
# Get details about the authenticated user
me = api.people.me()
print(f"Authenticated as: {me.displayName} (ID: {me.id})")
# List up to 5 rooms (spaces)
print("\nMy Spaces (max 5):")
for room in api.rooms.list(max=5):
print(f"- {room.title} (ID: {room.id})")
except Exception as e:
print(f"An error occurred: {e}")
if "401 Unauthorized" in str(e) or "access token" in str(e):
print("Please verify your WEBEX_TEAMS_ACCESS_TOKEN is valid and not expired.")