目录

参数列表

Variable Meanings
$appId 小米开放平台申请的AppId
$token 查询方的token(使用user.getToken()获取)
$account 查询方在APP系统内唯一ID
$fromAccount 消息发送方在APP帐号系统内唯一ID
$toAccount 消息接收方在APP帐号系统内唯一ID
$topicId 表示群ID
$utcFromTime 表示查询开始时间,UTC时间,单位毫秒
$utcToTime 表示查询结束时间,UTC时间,单位毫秒
$startSeq 表示查询开始序列号
$stopSeq 表示查询结束序列号
$count 表示查询的消息条数
$row 表示返回的消息条数
$timestamp 表示返回的消息中最早的时间戳
$messages 表示返回的消息集合
$sequence sequence主要用来做消息的排序和去重,全局唯一
$payload 表示经过Base64编码的消息体,app端需要进行Base64解码
$ts 表示消息时间戳
$bizType 可用于表示消息类型扩展字段(可选)
$extra 可用于表示消息扩展字段(可选)

保存多久

API名称 保存时间
拉取指定时间单聊消息记录 6个月
拉取指定数目单聊消息记录 6个月
拉取指定序列号单聊消息记录 7天
拉取指定时间群聊消息记录 6个月
拉取指定数目群聊消息记录 6个月
拉取指定序列号群聊消息记录 7天

拉取指定时间单聊消息记录

指的是拉取[utcFromTime, utcToTime)的时间范围内的A与B之间的聊天记录,单聊是相对于群聊而言的一对一聊天。
  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2p/query/ -XPOST
  -d '{"toAccount":$toAccount,"fromAccount":$fromAccount,"utcFromTime":$utcFromTime,"utcToTime":$utcToTime,"bizType":$bizType,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
curl https://mimc.chat.xiaomi.net/api/msg/p2p/queryOnTime -XPOST
  -d '{"toAccount":$toAccount,"fromAccount":$fromAccount,"utcFromTime":$utcFromTime,"utcToTime":$utcToTime,"bizType":$bizType,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
  • JSON结果示例
{
     "code": 200,
     "message": "success",
     "data": {
         "appId": $appId,
         "messages": [
             {
                 "sequence": $sequence,
                 "payload": $payload,
                 "ts": $ts,
                 "fromAccount":$fromAccount,
                 "toAccount": $toAccount,
                 "bizType":$bizType,
                 "extra":$extra
             }
         ],
         "row": $row
     }
 }

备注

utcFromTime和utcToTime的时间间隔不能超过24小时,查询状态为[utcFromTime,utcToTime);
timestamp字段在这个请求的响应中没有意义。

拉取指定数目单聊消息记录

指的是拉取从指定的时间戳utcToTime(不包含utcToTime)向前count条的A与B之间的聊天记录。
  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2p/queryOnCount/ -XPOST
  -d '{"toAccount":$toAccount,"fromAccount":$fromAccount,"utcToTime":$utcToTime,"count":$count,"bizType":$bizType,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
  • JSON结果示例
{
     "code": 200,
     "message": "success",
     "data": {
         "appId": $appId,
         "messages": [
             {
                 "sequence": $sequence,
                 "payload": $payload,
                 "ts": $ts,
                 "fromAccount":$fromAccount,
                 "toAccount": $toAccount,
                 "bizType":$bizType,
                 "extra":$extra
             }
         ],
         "row": $row,
         "timestamp":$timestamp
     }
 }

备注

timestamp字段在这个请求的响应中表示当前的聊天记录最早的时间戳(单位:毫秒)。

拉取指定序列号单聊消息记录

指的是拉取从[startSeq, stopSeq)之间的A与B之间的聊天记录。
  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2p/queryOnSequence/ -XPOST
  -d '{"toAccount":$toAccount,"fromAccount":$fromAccount,"startSeq":$startSeq,"stopSeq":$stopSeq}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
  • JSON结果示例
{
     "code": 200,
     "message": "success",
     "data": {
         "appId": $appId,
         "messages": [
             {
                 "sequence": $sequence,
                 "payload": $payload,
                 "ts": $ts,
                 "fromAccount":$fromAccount,
                 "toAccount": $toAccount,
                 "bizType":$bizType,
                 "extra":$extra
             }
         ],
         "row": $row,
         "timestamp":$timestamp
     }
 }

备注

timestamp字段表示当前的聊天记录最早的时间戳(单位:毫秒)。

拉取指定时间群聊消息记录

  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2t/query/ -XPOST
  -d '{"account":$account,"topicId":$topicId,"utcFromTime":$utcFromTime,"utcToTime":$utcToTime,"bizType":$bizType,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
curl https://mimc.chat.xiaomi.net/api/msg/p2t/queryOnTime/ -XPOST
  -d '{"account":$account,"topicId":$topicId,"utcFromTime":$utcFromTime,"utcToTime":$utcToTime,"bizType":$bizType,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
PS:URL中的$account与$token需要相匹配(即$token应该是$account用户的token信息)。
  • JSON结果示例
{
     "code": 200,
     "message": "success",
     "data": {
         "appId": $appId,
         "topicId": $topicId,
         "row": $row,
         "timestamp":$timestamp,
         "messages": [
             {
                 "sequence": $sequence,
                 "fromAccount": $fromAccount,
                 "payload": $payload,
                 "ts": $ts,
                 "bizType":$bizType,
                 "extra":$extra
             },
             {
                 "sequence": $sequence,
                 "fromAccount": $fromAccount,
                 "payload": $payload,
                 "ts": $ts,
                 "bizType":$bizType,
                 "extra":$extra
             }
         ]
     }
 }

备注

timestamp字段在这个请求的响应中表示当前的聊天记录最早的时间戳(单位:毫秒)。。

拉取指定数目群聊消息记录

指的是拉取从指定的时间戳utcToTime(不包含utcToTime)向前count条的指定的topicId的群聊天记录。
  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2t/queryOnCount/ -XPOST
  -d '{"account":$account,"topicId":$topicId,"utcToTime":$utcToTime,"count":$count,"bizType":$bizType,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
PS:URL中的$account与$token需要相匹配(即$token应该是$account用户的token信息)。
  • JSON结果示例
    {
       "code": 200,
       "message": "success",
       "data": {
           "appId": $appId,
           "topicId": $topicId,
           "row": $row,
           "timestamp":$timestamp,
           "messages": [
               {
                   "sequence": $sequence,
                   "payload": $payload,
                   "ts": $ts,
                   "fromAccount":$fromAccount,
                   "bizType":$bizType,
                   "extra":$extra
               }
           ]
       }
    }
    

    备注

    timestamp字段在这个请求的响应中表示当前的聊天记录最早的时间戳(单位:毫秒)。
    

拉取指定序列号群聊消息记录

指的是拉取[startSeq, stopSeq)的指定的topicId的群聊天记录。

如下为拉取[startSeq, stopSeq)的群聊消息记录

  • HTTPS请求(POST)

    curl https://mimc.chat.xiaomi.net/api/msg/p2t/queryOnSequence/ -XPOST
    -d '{"account":$account,"topicId":$topicId,"startSeq":$startSeq,"stopSeq":$stopSeq}'
    -H "Content-Type: application/json;charset=UTF-8"
    -H "Accept:application/json;charset=UTF-8"
    -H "token:$token"
    
    PS:URL中的$account与$token需要相匹配(即$token应该是$account用户的token信息)。
    
  • JSON结果示例

    {
       "code": 200,
       "message": "success",
       "data": {
           "appId": $appId,
           "topicId": $topicId,
           "row": $row,
           "timestamp":$timestamp,
           "messages": [
               {
                   "sequence": $sequence,
                   "payload": $payload,
                   "ts": $ts,
                   "fromAccount":$fromAccount,
                   "bizType":$bizType,
                   "extra":$extra
               }
           ]
       }
    }
    

备注

timestamp字段表示当前的聊天记录最早的时间戳(单位:毫秒)。

拉取指定时间超级大群聊消息记录

  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2u/queryOnTime/ -XPOST
  -d '{"account":$account,"topicId":$topicId,"utcFromTime":$utcFromTime,"utcToTime":$utcToTime,"bizType":$bizType,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
PS:URL中的$account与$token需要相匹配(即$token应该是$account用户的token信息)。
  • JSON结果示例
{
     "code": 200,
     "message": "success",
     "data": {
         "appId": $appId,
         "topicId": $topicId,
         "row": $row,
         "timestamp":$timestamp,
         "messages": [
             {
                 "fromAccount": $fromAccount,
                 "payload": $payload,
                 "ts": $ts,
                 "bizType":$bizType,
                 "extra":$extra
             },
             {
                 "fromAccount": $fromAccount,
                 "payload": $payload,
                 "ts": $ts,
                 "bizType":$bizType,
                 "extra":$extra
             }
         ]
     }
 }

备注

timestamp字段在这个请求的响应中表示当前的聊天记录最早的时间戳(单位:毫秒)。

拉取指定数目超级大群聊消息记录

指的是拉取从指定的时间戳utcToTime(不包含utcToTime)向前count条的指定的topicId的群聊天记录。
  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2u/queryOnCount/ -XPOST
  -d '{"account":$account,"topicId":$topicId,"utcToTime":$utcToTime,"count":$count,"bizType":$bizType,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
PS:URL中的$account与$token需要相匹配(即$token应该是$account用户的token信息)。
  • JSON结果示例
    {
       "code": 200,
       "message": "success",
       "data": {
           "appId": $appId,
           "messages": [
               {
                   "payload": $payload,
                   "ts": $ts,
                   "fromAccount":$fromAccount,
                   "bizType":$bizType,
                   "extra":$extra
               }
           ],
           "row": $row,
           "timestamp":$timestamp
       }
    }
    

    备注

    timestamp字段在这个请求的响应中表示当前的聊天记录最早的时间戳(单位:毫秒)。
    

更新单聊消息扩展extra

更新指定sequence的某条单聊消息的消息扩展属性extra
  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2p/extra/update -XPOST
  -d '{"fromAccount":$fromAccount,"toAccount":$toAccount,"sequence":$sequence,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
  • JSON结果示例
    {
      "code": 200, 
      "message": "success", 
      "data": {
          "fromAccount": $fromAccount, 
          "toAccount": $toAccount, 
          "sequence": $sequence, 
          "extra": $extra
      }
    }
    

更新群聊消息扩展extra

更新指定sequence的某条群聊消息的消息扩展属性extra
  • HTTPS请求(POST)
curl https://mimc.chat.xiaomi.net/api/msg/p2t/extra/update -XPOST
  -d '{"account":$account,"topicId":$topicId,"sequence":$sequence,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
curl https://mimc.chat.xiaomi.net/api/msg/p2u/extra/update -XPOST
  -d '{"account":$account,"topicId":$topicId,"sequence":$sequence,"extra":$extra}'
  -H "Content-Type: application/json;charset=UTF-8"
  -H "Accept:application/json;charset=UTF-8"
  -H "token:$token"
  • JSON结果示例
    {
      "code": 200, 
      "message": "success", 
      "data": {
          "topicId": $topicId, 
          "sequence": $sequence, 
          "extra": $extra
      }
    }
    

results matching ""

    No results matching ""