{"id":14696,"library":"mattermostwrapper","title":"Mattermost API Wrapper","description":"Mattermostwrapper is a Python library that provides a wrapper for the Mattermost API v4, enabling programmatic interaction with Mattermost servers. The current version is 2.2, with its last release in February 2020. Given its last update, the project appears to be in a maintenance state, supporting core API v4 functionalities without frequent new feature additions or updates.","status":"maintenance","version":"2.2","language":"en","source_language":"en","source_url":"https://github.com/btotharye/mattermostwrapper.git","tags":["mattermost","api","wrapper","chatops"],"install":[{"cmd":"pip install mattermostwrapper","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for making HTTP requests to the Mattermost API. While not explicitly listed in the project's PyPI metadata or README, it is a de facto dependency for most Python HTTP clients and is implied by the library's function.","package":"requests","optional":false}],"imports":[{"symbol":"MattermostAPI","correct":"from mattermostwrapper import MattermostAPI"}],"quickstart":{"code":"import os\nfrom mattermostwrapper import MattermostAPI\n\n# Replace with your Mattermost instance details\nMATTERMOST_URL = os.environ.get('MATTERMOST_URL', 'https://your-mattermost-instance.com/api/v4')\nMATTERMOST_LOGIN = os.environ.get('MATTERMOST_LOGIN', 'your_username')\nMATTERMOST_PASSWORD = os.environ.get('MATTERMOST_PASSWORD', 'your_password')\nMATTERMOST_TEAM_NAME = os.environ.get('MATTERMOST_TEAM_NAME', 'your_team_name')\nMATTERMOST_CHANNEL_ID = os.environ.get('MATTERMOST_CHANNEL_ID', 'your_channel_id') # Optional for direct posts\n\n\ndef main():\n    try:\n        m = MattermostAPI(MATTERMOST_URL, MATTERMOST_TEAM_NAME)\n        m.login(MATTERMOST_LOGIN, MATTERMOST_PASSWORD)\n        print(\"Successfully logged into Mattermost.\")\n\n        # Example: Get teams\n        teams = m.get_teams()\n        print(f\"Teams: {teams}\")\n\n        # Example: Get channel listings for a team\n        if teams:\n            first_team_id = teams[0]['id']\n            # If MATTERMOST_TEAM_NAME is used above, you might need to get team_id dynamically\n            # For simplicity, if MATTERMOST_TEAM_NAME is set to a specific team name during MattermostAPI init,\n            # the internal methods should work with the associated team.\n            # If not, you'd need to find the team ID from 'teams'\n            \n            print(f\"Getting channels for team: {MATTERMOST_TEAM_NAME}\")\n            channel_list = m.get_channel_listing(MATTERMOST_TEAM_NAME)\n            for channel in channel_list:\n                print(f\"  Channel: {channel['display_name']} (ID: {channel['id']})\")\n            \n            # Example: Post a message to a channel (requires channel_id)\n            if MATTERMOST_CHANNEL_ID:\n                message = \"Hello from mattermostwrapper! This is a test message.\"\n                post_response = m.post_channel(MATTERMOST_CHANNEL_ID, message)\n                print(f\"Message posted: {post_response['message']}\")\n            else:\n                print(\"MATTERMOST_CHANNEL_ID not set. Skipping message post.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"Initializes the Mattermost API client, logs in with credentials, retrieves available teams and channels, and demonstrates how to post a message to a specific channel. Ensure Mattermost server URL, login, password, and team name are correctly configured via environment variables for a runnable example."},"warnings":[{"fix":"Thoroughly test with your specific Mattermost server version. Consider migrating to a more actively maintained library like `mattermostdriver` for broader compatibility and feature support if issues arise.","message":"The library's last update was in February 2020 (v2.2). Newer Mattermost server versions (beyond 5.x) may introduce API changes or new features that are not supported or correctly handled by this wrapper, potentially leading to unexpected behavior or missing functionality.","severity":"gotcha","affected_versions":"<=2.2"},{"fix":"Verify Mattermost server's authentication settings. If using newer Mattermost versions, you may need to enable legacy authentication methods or adapt the wrapper if it doesn't support modern token-based authentication directly for your use case.","message":"Authentication methods for Mattermost servers have evolved (e.g., Personal Access Tokens, OAuth2). This library primarily focuses on username/password login. While `login` method is available, ensure your Mattermost server allows basic username/password authentication for bots/integrations.","severity":"breaking","affected_versions":"All versions"},{"fix":"Double-check team and channel names/IDs on your Mattermost instance. Use API calls (e.g., `get_teams()`, `get_channel_listing()`) to programmatically retrieve and verify available names and IDs.","message":"Errors like 'channel not found' or 'team not found' are common if the provided `team_name` or `channel_id` in the API calls do not exactly match those on the Mattermost server. Case sensitivity and exact names are crucial.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify the `MATTERMOST_URL` (ensure it includes `/api/v4`), `MATTERMOST_LOGIN`, `MATTERMOST_PASSWORD`, and `MATTERMOST_TEAM_NAME` variables are correct and the user has permission to access the team. Test credentials manually via web interface.","cause":"Incorrect Mattermost URL, username, password, or the specified team name does not exist or is inaccessible.","error":"mattermostwrapper.exceptions.MattermostAPIError: Login Failed"},{"fix":"Run `pip install mattermostwrapper` to install the library.","cause":"The `mattermostwrapper` package is not installed in the current Python environment.","error":"No module named 'mattermostwrapper'"},{"fix":"Check network connectivity from where the script is run to the Mattermost server. Verify the `MATTERMOST_URL` is correct and accessible (e.g., try `ping` or `curl` from the command line). Check firewall rules.","cause":"The Python environment cannot reach the Mattermost server URL, possibly due to network issues, incorrect URL, or firewall blocking.","error":"requests.exceptions.ConnectionError: HTTPSConnectionPool(...) Failed to establish a new connection"}],"ecosystem":"pypi"}