Python Mattermost v4 API Wrapper
This will be a api v4 wrapper for mattermost. The plan is to use this for bots, etc.
Usage
- Clone the project and import it into your new script and add the following code to your python file, replace the url, login, and pw to match your settings for your server as well as your team name you want to interact with:
m = MattermostAPI("your mattermost url", "team_name")
m.login("login", "password")
# Test showing the teams
print(m.get_teams())
Get channel listing example code:
from mattermost_wrapper import wrapper
m = wrapper.MattermostAPI("https://yoururlhere/api/v4")
m.login("username", "password")
channel_list = m.get_channel_listing('team_name')
for channel in channel_list:
print(channel['display_name'])
This will login and print out channel listings for your team.
You can also do the following to post a test message to the channel off-topic using the wrapper:
from mattermost_wrapper import wrapper
m = wrapper.MattermostAPI("https://yoururlhere/api/v4")
m.login("username", "password")
channel_name = 'off-topic'
message = 'This is a test message'
post_message = m.post_channel(channel_name, message)
print(post_message)