API Functions

The below table lists the different available APIs:

API Name Description Post Parameters Success Response Failure Response
createuser Create a new user for your website, username and password are mandatory, others fields can be kept blank {
action:”createuser”,
api-key:”API_KEY”,
username:”USER_NAME”,
password: “PASSWORD”,
link: “PROFILE_LINK”,
avatar:”AVATAR_LINK”,
displayname:”DISPLAY_NAME”
}
{“success”: {“status”:”1000″, “message”:”User created successfully!”}} {“failed”: {“status”:”1001″, “message”:”username already exists”}}
OR
{“failed”: {“status”:”1007″, “message”:”Invalid Username.”}}
OR
{“failed”: {“status”:”1009″, “message”:”Invalid Password.”}}
removeuser Remove a user from your website by using ID or username of a user {
action:”removeuser”,
api-key:”API_KEY”,
userid:USER_ID
}
{“success”: {“status”:”1000″, “message”:”User removed successfully!”}} {“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}
updateuser Update your profile information. You can update your password, display name, status, status message, avatar and profile link. {
action:”updateuser”,
api-key:”API_KEY”,
userid:”USER_ID”,
newpassword:”NEW_PASSWORD”,
username:”USER_NAME”,
displayname:”DISPLAY_NAME”,
avatar:”AVATAR_LINK”,
link: “PROFILE_LINK”,
}
{“success”: {“status”:”1000″, “message”:”Details updated successfully!”}} {“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}
OR
{“failed”: {“status”:”1014″, “message”:”Failed to update username. Invalid username or username already exists.”}}
OR
{“failed”: {“status”:”1016″, “message”:”Failed to update details.”}}
addfriend Make a user your friend. Pass json array containing the ID of user {
api-key:”API_KEY”,
userid:”USER_ID”,
friends:2
}
OR
{
api-key:”API_KEY”,
userid:”USER_ID”,
friends:1,2,3
}
OR
{
api-key:”API_KEY”,
userid:”USER_ID”,
friends:jsonarray of ids
}
{“success”: {“status”:”1000″, “message”:”Friends added successfully!”, “data”:{“userid”:”2,3″}}} {“failed”: {“status”:”1005″, “message”:”Invalid input”}}
OR
{“failed”: {“status”:”1006″, “message”:”Failed to add friend.”}}
OR
{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}
removefriend Unfriend a user from your friend list. Pass json array containing the ID of user {
api-key:”API_KEY”,
userid:”USER_ID”,
friends:2
}
OR
{
api-key:”API_KEY”,
userid:”USER_ID”,
friends:1,2,3
}
OR
{
api-key:”API_KEY”,
userid:”USER_ID”,
friends:jsonarray of ids
}
{“success”: {“status”:”1000″, “message”:”Friends removed successfully!”, “data”:{“id”:”2″}}} {“failed”: {“status”:”1005″, “message”:”Invalid input”}}
OR
{“failed”: {“status”:”1002″, “message”:”Failed to remove friends!”}}
OR
{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

Not finding what you need?

The CometChat team is here to help!