We're Hiring!

Mattermost, Inc.

Requests for additional APIs

I have compared the API’s provided by the Slack and Mattermost and found that MM only provides the basic API whereas Slack has got the rich number of API’s available.
I was going to create the API for mattermost as well. Is there anyone who can tell me the estimated hour of creating the single API and also the steps which I should follow for creating the same.
Any type of help is highly appreciable!!!

That is quite a broad question. The time would depend heavily on the complexity of the API feature you were implementing.
Looking at the Slack API though, Mattermost’s is, broadly speaking, as complete and “rich” (as you put it). What exactly were you looking at in Slack’s that isn’t implemented in MM?

On comparison with Slack I have found that certain API’s such as “channels.archive, channels.history, channels.invite, channels.rename, channels.unarchive” etc. are missing. I am going to create these API’s. Is there a specific procedure which I should follow for creating the API’s. Also what will be the approx estimated time for that? I know this is a broad question…still any response will be appreciable.

As far as I’m aware, Mattermost has no concept of archiving channels. It’s not in the API because it’s not possible to do. You can delete channels, but I think that’s permanent.

The equivalent API calls for the other ones you mentioned are:

  • channels.history - Mattermost splits this into several different API calls. All of them sit under api/v1/channels/<channel ID>/posts.
  • /<offset>/<limit> simply returns the specified number of posts, where <offset> is the how many posts back in time you want to start from (usually 0) and <limit> is the number of posts to get.
  • /<time> returns all mosts made or modified since the given UNIX timestamp.
  • /<post ID>/before/<offset>/<limit> will return the given number of posts before the one specified in <post ID>
  • /<post ID>/after/<offset>/<limit> will return the given number of posts after the one specified
    The only thing that’s really missing from this is the ability to get all posts between 2 times, but its not impossible to do that with the available API calls.
  • channels.invite - In Mattermost, you don’t really invite, you simply add them. Use api/v1/channels/<channel ID>/add with the ID of the user you want to add in the request payload (as a JSON string of course).
  • channels.rename - Use api/v1/channels/update. The request payload for this should contain the entire channel JSON string with the display_name field modified.

Thanks @limey98 for your response and it is really very helpful. I am trying to simplify the “channels.history” API.

That probably wouldn’t be too difficult. Depending on your level of competence with Go, it shouldn’t take than a few hours to a couple of days. Most of the code you need is already in api/post.go.

Hi @limey98,

I have installed and configured mattermost and is working around with the API’s provided by MM. I am getting the proper response for the GET commands, but getting the issue for the post commands. For creating the channel I am using below command:

curl -X POST -H “Authorization: Bearer ###########” -d ‘{“create_at”:“1459589056740”,“update_at”:“1459589056740”,“team_id”“gxab7sa1u3bkbptpen79auty3h”,“type”:“O”,“display_name”:“TestChannelviaCu”,“name”:“testAJchannel”,“purpose”:“checkcurl”,“creator_id”“4oq6zik6d3rppd6gxk5hretb7o”,“last_post_at”:0,“total_msg_count”:0,“user_id”:“4oq6zik6d3rppd6gxk5hretb7o”}’ http://mydomain.co/api/v1/channels/create_direct

and getting this response
{“id”:“api.context.invalid_param.app_error”,“message”:“Invalid user_id parameter”,“detailed_error”:"",“request_id”:“s4tmksfbgj86zm14dyj4cmo1cw”,“status_code”:400,“is_oauth”:false}

Is there any format which I can use to create channel? I have digged out most of the docs provided by MM but didn’t found any POST command which I can modify to create channel.

I’ve not used that particular API call before, but it looks like it only expects 1 parameter in the payload:
{user_id: "zmxxqixkz38yukywqfggxfnsye"} which is the ID of the user you are created the channel with (not your own). I doubt the extra parameters would cause the error, so my best guess is that the user_id is not a valid ID for a user registered on the server. It could also be that the direct channel to that user has already been created.

Hello @limey98, I have been working on file.delete API(currently not available in MM). My first query is that there is a single column present in Posts table where full path of file get stored. So how can I delete a full record only by the filename as there is not any specific id present. To be much clear, what parameters should I pass in my API to delete the full record for particular file.
My second query is that all the files get saved in S3 but there is no credentials mentioned as where they are getting saved. So after deleting the record from table how would I remove file from S3 bucket.
These are my two concerns…Any help regarding this will be helpful. Thanks