Registry / http-networking / mattermostwrapper

mattermostwrapper

JSON →
library2.2pypiunverified

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.

pip install mattermostwrapper
INSTALL
IMPORT
SIG · MATTERMOSTWRAPPER
M
mattermostwrapper
http-networkingenv2.2
Install
3.1s avg
Import
616ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.645s · 22.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.1s · import 0.586s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MattermostAPI
from mattermostwrapper import MattermostAPI

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.

import os from mattermostwrapper import MattermostAPI # Replace with your Mattermost instance details MATTERMOST_URL = os.environ.get('MATTERMOST_URL', 'https://your-mattermost-instance.com/api/v4') MATTERMOST_LOGIN = os.environ.get('MATTERMOST_LOGIN', 'your_username') MATTERMOST_PASSWORD = os.environ.get('MATTERMOST_PASSWORD', 'your_password') MATTERMOST_TEAM_NAME = os.environ.get('MATTERMOST_TEAM_NAME', 'your_team_name') MATTERMOST_CHANNEL_ID = os.environ.get('MATTERMOST_CHANNEL_ID', 'your_channel_id') # Optional for direct posts def main(): try: m = MattermostAPI(MATTERMOST_URL, MATTERMOST_TEAM_NAME) m.login(MATTERMOST_LOGIN, MATTERMOST_PASSWORD) print("Successfully logged into Mattermost.") # Example: Get teams teams = m.get_teams() print(f"Teams: {teams}") # Example: Get channel listings for a team if teams: first_team_id = teams[0]['id'] # If MATTERMOST_TEAM_NAME is used above, you might need to get team_id dynamically # For simplicity, if MATTERMOST_TEAM_NAME is set to a specific team name during MattermostAPI init, # the internal methods should work with the associated team. # If not, you'd need to find the team ID from 'teams' print(f"Getting channels for team: {MATTERMOST_TEAM_NAME}") channel_list = m.get_channel_listing(MATTERMOST_TEAM_NAME) for channel in channel_list: print(f" Channel: {channel['display_name']} (ID: {channel['id']})") # Example: Post a message to a channel (requires channel_id) if MATTERMOST_CHANNEL_ID: message = "Hello from mattermostwrapper! This is a test message." post_response = m.post_channel(MATTERMOST_CHANNEL_ID, message) print(f"Message posted: {post_response['message']}") else: print("MATTERMOST_CHANNEL_ID not set. Skipping message post.") except Exception as e: print(f"An error occurred: {e}") if __name__ == '__main__': main()
Debug
Known issues
gotchaThe 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.
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.
affects: <=2.2
breakingAuthentication 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.
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.
affects: All versions
gotchaErrors 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.
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.
affects: All versions
Errors
Common errors & fixes
mattermostwrapper.exceptions.MattermostAPIError: Login Failed
Incorrect Mattermost URL, username, password, or the specified team name does not exist or is inaccessible.
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.
No module named 'mattermostwrapper'
The `mattermostwrapper` package is not installed in the current Python environment.
fix
Run `pip install mattermostwrapper` to install the library.
requests.exceptions.ConnectionError: HTTPSConnectionPool(...) Failed to establish a new connection
The Python environment cannot reach the Mattermost server URL, possibly due to network issues, incorrect URL, or firewall blocking.
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.
Upgrade
Version history
2.2latest on PyPI · released Feb 17, 2020
Audit
Dependencies
requestsrequiredUsed 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.
Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources

No resource links recorded.

mattermostwrapper — pip install mattermostwrapper · libregistry