VSTS Python Client (deprecated, use azure-devops)

raw JSON →
0.1.25 verified Fri May 01 auth: no python deprecated

The `vsts` library was the original Python wrapper for Visual Studio Team Services (now Azure DevOps) APIs. As of version 0.1.25, it is deprecated and no longer maintained. Microsoft recommends migrating to the `azure-devops` library, which follows the Azure SDK guidelines and supports new API versions. The latest azure-devops release is 7.1.0b4.

pip install vsts==0.1.25
error ModuleNotFoundError: No module named 'vsts.vss_connection'
cause Incorrect import path (e.g., using 'from vsts import vss_connection' or wrong module name).
fix
Use 'from vsts.vss_connection import VssConnection'
error ImportError: cannot import name 'WorkItemTrackingClient' from 'vsts.work_item_tracking'
cause Missing version subpackage in import path.
fix
Use 'from vsts.work_item_tracking.v4_1.work_item_tracking_client import WorkItemTrackingClient'
error AttributeError: 'VssConnection' object has no attribute 'get_client'
cause Incorrect argument type for get_client; must be a string with full class path.
fix
Use: connection.get_client('vsts.work_item_tracking.v4_1.work_item_tracking_client.WorkItemTrackingClient')
error msrest.exceptions.AuthenticationError: 'Bearer'
cause Invalid or missing Personal Access Token. Using wrong authentication class.
fix
Ensure PAT is valid and pass as: BasicAuthentication('', pat)
deprecated The vsts library is deprecated and no longer maintained. Use azure-devops instead.
fix Replace vsts with azure-devops. See https://github.com/microsoft/azure-devops-python-api
breaking vsts 0.1.25 is incompatible with Python 3.12 due to missing dependencies (e.g., 'collections' module removed).
fix Upgrade to azure-devops 7.1.0b4 or later which supports Python 3.12.
gotcha Import paths in vsts are deeply nested and version-specific (e.g., vsts.work_item_tracking.v4_1). Many online examples omit the version subpackage.
fix Always include the full import path with version, e.g., from vsts.work_item_tracking.v4_1.work_item_tracking_client import WorkItemTrackingClient
gotcha Authentication requires 'msrest' library's BasicAuthentication. Using Personal Access Token requires empty username.
fix Use: from msrest.authentication import BasicAuthentication; credentials = BasicAuthentication('', pat)

Connect to Azure DevOps (formerly VSTS) using a PAT. Note: This library is deprecated; prefer 'azure-devops'.

from vsts.vss_connection import VssConnection
from msrest.authentication import BasicAuthentication

personal_access_token = os.environ.get('AZURE_DEVOPS_PAT', '')
organization_url = 'https://dev.azure.com/myorg'
credentials = BasicAuthentication('', personal_access_token)
connection = VssConnection(base_url=organization_url, creds=credentials)
wit_client = connection.get_client('vsts.work_item_tracking.v4_1.work_item_tracking_client.WorkItemTrackingClient')
print(wit_client.get_work_item(1))