Mattermost API bindings
In productive use on a 6k+ users E10 instance at https://mattermost.fsinf.at
- Used to manage channels, users and everything.
- Some api-endpoints are #UNTESTED.
- Some are not handled/#NOT_IMPLEMENTED (yet).
- Some dont seem to make any sense to ever implement at all. Why do they even exist?
- Others may be out of scope (I cannot test E20-stuff)
- Some are not handled/#NOT_IMPLEMENTED (yet).
- Beware: I love to rebase git. :)
If you use this or find this stuff useful, consider paying me a beer/club-mate :)
btc: bc1q9vxqzd58683ky9c2yaddaxx3wrxakggfa0dmdteth: 0x839326860d74cf61f03719c5c63db3ae5d2b443fbch: qqxpm8py3flkaqdt4ehatzvx250634fuvgsgvft6z4doge: DLeQq2u7gdnidaNwEtj9fYrstUaU4banNgxmr: 47WwuQssrZRHLXYBRoEPmqhyG8e4PxorwWn1Xvyg6QShKAjZ83UHWJmYd9PFkpH6vPQFgNbnKvaRz1EzoQHSeeQvEGQ6ihA
Setup
pip3 install --user --upgrade mattermost
Usage
import mattermost
# login
mm = mattermost.MMApi("https://mattermost.example.com/api")
mm.login("user@example.com", "my-pw")
# alternatively use a personal-access-token/bot-token.
# mm.login(bearer="my-personal-access-token")
# do stuff (print info about your user)
import pprint
pprint.pprint(mm.get_user())
# do other stuff (print info about an not-existing user)
try:
pprint.pprint(mm.get_user("not-existing-user-id", exc=True))
except mattermost.ApiException as e:
print(e)
# 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", data=cfg)
# logout
mm.revoke_user_session()
Websocket usage
import mattermost
import mattermost.ws
# login
mm = mattermost.MMApi("https://mattermost.example.com/api")
mm.login("user@example.com", "my-pw")
# define a websocket handler
def webs_handler(mmws, event_data):
import pprint
pprint.pprint(mmws)
pprint.pprint(event_data)
# connect to websocket and start processing events
mmws = mattermost.ws.MMws(webs_handler, mm, "wss://mattermost.example.com/api/v4/websocket")
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, raw=False, exc=False)_put(endpoint, data=None, exc=False)_post(endpoint, data=None, multipart_formdata=None, exc=False)_delete(endpoint, data=None, exc=False)
stdin2channel
You can pipe STDIN to a channel:
echo "message" | python3 -m mattermost.stdin2channel https://localhost:8065/api 'user@example.com' 'my-pw' 'channel_id'This leaks your credentials to everyone on your system! Only use this in trusted dev-envs.
Endpoints
Ordered by https://api.mattermost.com/
- LOGIN/LOGOUT
login (login_id=None, password=None, token=None, bearer=None)logout (**kwargs)
- USERS
create_user() #NOT_IMPLEMENTEDget_users (in_team=None, not_in_team=None, in_channel=None, not_in_channel=None, group_constrained=None, without_team=None, sort=None, **kwargs)get_users_by_ids_list (user_ids_list, **kwargs) #UNTESTEDget_users_by_group_channel_ids_list (group_channel_ids_list, **kwargs) #UNTESTEDget_users_by_usernames_list (usernames_list, **kwargs)search_users() #NOT_IMPLEMENTEDautocomplete_users() #NOT_IMPLEMENTEDget_user_ids_of_known_users() #NOT_IMPLEMENTEDget_total_count_of_users_in_system() #NOT_IMPLEMENTEDget_user (user_id=None, **kwargs)update_user() #NOT_IMPLEMENTED: # use patch_userdeactivate_user() #NOT_IMPLEMENTEDpatch_user (user_id, props=None, **kwargs)update_user_roles() #NOT_IMPLEMENTEDupdate_user_active_status() #NOT_IMPLEMENTEDget_user_profile_image() #NOT_IMPLEMENTEDset_user_profile_image() #NOT_IMPLEMENTEDdelete_user_profile_image() #NOT_IMPLEMENTEDget_user_default_profile_image() #NOT_IMPLEMENTEDget_user_by_username (username, **kwargs)reset_user_password() #NOT_IMPLEMENTEDupdate_user_mfa() #NOT_IMPLEMENTEDgenerate_user_mfa_secret() #NOT_IMPLEMENTEDdemote_a_user (user_id, **kwargs)promote_a_guest (user_id, **kwargs)check_user_mfa() #NOT_IMPLEMENTEDupdate_user_password() #NOT_IMPLEMENTEDsend_user_password_reset_mail() #NOT_IMPLEMENTEDget_user_by_email() #NOT_IMPLEMENTEDget_user_sessions (user_id=None, **kwargs)revoke_user_session (user_id=None, session_id=None, **kwargs)revoke_all_user_sessions() #NOT_IMPLEMENTEDattach_mobile_device_to_user_session() #NOT_IMPLEMENTEDget_user_audit() #NOT_IMPLEMENTEDadmin_verify_user_email_() #NOT_IMPLEMENTEDverify_user_email_() #NOT_IMPLEMENTEDsend_user_email_verification() #NOT_IMPLEMENTEDswitch_user_login_method() #NOT_IMPLEMENTEDcreate_user_access_token() #NOT_IMPLEMENTEDget_user_access_tokens() #NOT_IMPLEMENTEDrevoke_user_access_token() #NOT_IMPLEMENTEDget_user_access_token() #NOT_IMPLEMENTEDdisable_user_access_token() #NOT_IMPLEMENTEDenable_user_access_token() #NOT_IMPLEMENTEDsearch_user_access_tokens() #NOT_IMPLEMENTEDupdate_user_auth_method() #NOT_IMPLEMENTEDrecord_user_action_custom_tos() #NOT_IMPLEMENTEDfetch_user_latest_accepted_custom_tos() #NOT_IMPLEMENTEDrevoke_all_users_all_sessions() #NOT_IMPLEMENTED #MM, ARE YOU INSANE?!
- BOTS #NOT_IMPLEMENTED
- TEAMS
create_team() #NOT_IMPLEMENTEDget_teams (include_total_count=None, **kwargs)get_team (team_id, **kwargs)update_team() #NOT_IMPLEMENTEDdelete_team() #NOT_IMPLEMENTEDpatch_team() #NOT_IMPLEMENTEDupdate_team_privacy() #NOT_IMPLEMENTEDrestore_team() #NOT_IMPLEMENTEDget_team_by_name() #NOT_IMPLEMENTEDsearch_teams() #NOT_IMPLEMENTEDexists_team() #NOT_IMPLEMENTEDget_teams_for_user() #NOT_IMPLEMENTEDget_team_members (team_id, **kwargs)add_user_to_team (team_id, user_id, **kwargs)add_user_to_team_from_invite() #NOT_IMPLEMENTEDadd_multiple_users_to_team() #NOT_IMPLEMENTED WHY?!get_team_members_for_a_user() #NOT_IMPLEMENTED WHY NOT NAMING STUFF USEFULLY?!get_team_member (team_id, user_id, **kwargs)remove_user_from_team (team_id, user_id, **kwargs)get_team_members_by_id() #NOT_IMPLEMENTEDget_team_stats() #NOT_IMPLEMENTEDregenerate_team_invite_id() #NOT_IMPLEMENTEDget_team_icon() #NOT_IMPLEMENTEDset_team_icon() #NOT_IMPLEMENTEDremove_team_icon() #NOT_IMPLEMENTEDupdate_team_members_roles() #NOT_IMPLEMENTEDupdate_team_members_scheme_roles (team_id, user_id, props, **kwargs)get_team_unreads_for_user() #NOT_IMPLEMENTEDget_team_unreads() #NOT_IMPLEMENTEDinvite_users_to_team_by_email() #NOT_IMPLEMENTEDinvite_guests_to_team_by_email (team_id, guest_email, channels, message, **kwargs)invalidate_invites_to_team_by_email() #NOT_IMPLEMENTEDimport_team() #NOT_IMPLEMENTEDget_team_invite_info() #NOT_IMPLEMENTEDset_team_scheme() #NOT_IMPLEMENTEDget_team_members_minus_group_members() #NOT_IMPLEMENTEDget_team_channels (team_id, **kwargs) #This belongs here, not to channels!
- CHANNELS
get_all_channels() #NOT_IMPLEMENTED NOT USEFUL AT ALL!create_channel (team_id, name, display_name, purpose=None, header=None, chan_type="O", **kwargs)create_dm_channel_with (other_user_id, **kwargs)create_group_channel_with (other_user_ids_list, **kwargs) #UNTESTEDsearch_all_private_and_public_channels() #NOT_IMPLEMENTEDsearch_all_users_group_channels() #NOT_IMPLEMENTEDget_team_channels_by_id() #NOT_IMPLEMENTEDget_timezones_of_users_in_channel() #NOT_IMPLEMENTEDget_channel (channel_id, **kwargs)update_channel (channel_id, props, **kwargs)patch_channel (channel_id, props, **kwargs)get_channel_posts_pinned (channel_id, **kwargs)search_channel (team_id, term, **kwargs)get_channel_by_name (team_id, channel_name, include_deleted=None, **kwargs)get_channel_members (channel_id, **kwargs)add_user_to_channel (channel_id, user_id, **kwargs)get_channel_member (channel_id, user_id, **kwargs)remove_user_from_channel (channel_id, user_id, **kwargs)update_channel_members_scheme_roles (channel_id, user_id, props, **kwargs)get_channel_memberships_for_user (user_id, team_id, **kwargs)get_channels_for_user (user_id, team_id, **kwargs)
- POSTS
create_post (channel_id, message, props=None, filepaths=None, root_id=None, **kwargs)create_ephemeral_post (channel_id, message, user_id, **kwargs)get_post (post_id, **kwargs)delete_post (post_id, **kwargs)patch_post (post_id, message=None, is_pinned=None, props=None, **kwargs)get_posts_for_channel (channel_id, **kwargs)
- FILES
upload_file (channel_id, filepath, **kwargs)get_file (file_id, **kwargs)
- PREFERENCES #NOT_IMPLEMENTED
- STATUS #NOT_IMPLEMENTED
- EMOJI #NOT_IMPLEMENTED
- REACTIONS
create_reaction (user_id, post_id, emoji_name, **kwargs)
- WEBHOOKS
create_outgoing_hook (team_id, display_name, trigger_words, callback_urls, channel_id=None, description=None, trigger_when=0, **kwargs)list_outgoing_hooks (team_id, channel_id=None, **kwargs)delete_outgoing_hook (hook_id, **kwargs)
- COMMANDS
create_slash_command (team_id, trigger, url, **kwargs)list_custom_slash_commands_for_team (team_id, **kwargs)update_slash_command (data, **kwargs)delete_slash_command (command_id, **kwargs)
- OPENGRAPH #NOT_IMPLEMENTED
- SYSTEM #NOT_IMPLEMENTED
- BRAND #NOT_IMPLEMENTED
- OAUTH #NOT_IMPLEMENTED
- SAML #NOT_IMPLEMENTED
- LDAP #NOT_IMPLEMENTED
- GROUPS #NOT_IMPLEMENTED
- COMPLIANCE #NOT_IMPLEMENTED
- CLUSTER #NOT_IMPLEMENTED
- ELASTICSEARCH #NOT_IMPLEMENTED
- BLEVE #NOT_IMPLEMENTED
- DATARETENTION #NOT_IMPLEMENTED
- JOBS #NOT_IMPLEMENTED
- PLUGINS #NOT_IMPLEMENTED
- ROLES #NOT_IMPLEMENTED
- SCHEMES #NOT_IMPLEMENTED
- INTEGRATION_ACTIONS
open_dialog (trigger_id, response_url, dialog, **kwargs)
- TERMS_OF_SERVICE #NOT_IMPLEMENTED
Metadata
Release files for mattermost 10.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mattermost-10.11.0.tar.gz | 18.1 kB | Without provenance | Details for mattermost-10.11.0.tar.gz |
Release files / mattermost-10.11.0.tar.gz
| Download URL | mattermost-10.11.0.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f189d4637ff2dd9a3c5b5260d01a3a53eba47b14159282fac972490c0835f880
|
|
BLAKE2b-256 checksum How to use checksums |
137e089fc3086003bdf43185651e698274ad0fd65936ec7c07ce5a14227eb388
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for mattermost 10.11.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.