Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Mattermost API bindings

Project description

Mattermost API bindings

In productive use on a 4k+ users E10 instance at

  • Used to manage channels, users and everything.
  • Not all api-endpoints handled (yet).
  • E20-only endpoints are out of scope.
  • We dont consider bot accounts stable yet. Therefore out of scope for now.
  • Beware: I love to rebase git.


pip3 install --user --upgrade mattermost


import mattermost

# login
mm = mattermost.MMApi("")
mm.login("my-username", "my-pw")

# do stuff (print info about your user)
import pprint

# custom endpoint call (get server config)
cfg = mm._get("/v4/config")

# do something (enable plugins)
cfg["PluginSettings"]["Enable"] = True

# custom endpoint call (put server config)
mm._put("/v4/config", cfg)

# logout

Websocket usage

import mattermost

# login
mm = mattermost.MMApi("")
mm.login("my-username", "my-pw")

# define a websocket handler
def webs_handler(mmws, event_data):
    import pprint

# connect to websocket and start processing events
mmws =, mm, "wss://")

To close the websocket connection - there is no way to restart, create a new instance of MMws:

  • mmws.close_websocket()

Manually calling the API

Some endpoints are not handled (yet). You can manually call these endpoints. Available private functions:

  • _get(endpoint)
  • _put(endpoint, data)
  • _post(endpoint, data)
  • _delete(endpoint)


Ordered by

  • login(login_id, password)
  • get_user_sessions(user_id=None)
  • revoke_user_session(user_id=None, session_id=None)
  • get_users()
  • get_user_by_username(username)
  • get_user(user_id=None)
  • patch_user(user_id, props={})
  • get_teams()
  • get_team(team_id)
  • get_team_members(team_id)
  • add_user_to_team(team_id, user_id)
  • get_team_member(team_id, user_id)
  • update_team_members_scheme_roles(team_id, user_id, props)
  • get_team_channels(team_id)
  • create_channel(team_id, name, display_name, purpose="", header="", type="O")
  • create_dm_channel_with(other_user_id)
  • get_channel(channel_id)
  • update_channel(channel_id, props)
  • patch_channel(channel_id, props)
  • get_channel_posts_pinned(channel_id)
  • search_channel(team_id, term)
  • get_channel_by_name(team_id, channel_name)
  • get_channel_members(channel_id)
  • get_channel_member(channel_id, user_id)
  • add_user_to_channel(channel_id, user_id)
  • remove_user_from_channel(channel_id, user_id)
  • get_channel_members_for_user(user_id, team_id)
  • get_channels_for_user(user_id, team_id)
  • update_channel_members_scheme_roles(channel_id, user_id, props)
  • create_post(channel_id, message, props={"from_webhook":"true"}, filenames=[], root_id=None)
  • get_post(post_id)
  • delete_post(post_id)
  • get_posts_for_channel(channel_id)
  • create_reaction(user_id, post_id, emoji_name)
  • create_outgoing_hook(team_id, channel_id, description="", display_name="", trigger_words=[], trigger_when=0, callback_urls=[])
  • list_outgoing_hooks(team_id, channel_id)
  • delete_outgoing_hook(hook_id)
  • create_slash_command(team_id, command, url)
  • list_custom_slash_commands_per_team(team_id)
  • update_slash_command(data)
  • delete_slash_command(command_id)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mattermost, version 5.16.20191106
Filename, size File type Python version Upload date Hashes
Filename, size mattermost-5.16.20191106.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page