Mastodon
  • 什么是 Mastodon?
  • 使用 Mastodon
    • 注册帐户
    • 设置你的个人资料
    • 在你的账户发布内容
    • 使用网络功能
    • 处理不想看到的内容
    • 推广你和他人
    • 进行偏好设置
    • 更多设置
    • 在站点外使用 Mastodon
    • 迁移或离开账户
    • 运行你自己的站点
  • 运营 Mastodon
    • 准备你的服务器
    • 从源代码安装
    • 配置你的环境
    • 安装可选功能
      • 对象存储
      • 洋葱服务
      • 验证码
      • 单点登录
    • 配置全文搜索
    • 设置你的新实例
    • 使用管理 CLI
    • 升级到新版本
    • 备份你的服务器
    • 迁移到新机器
    • 扩大你的站点规模
    • 审核操作
    • 故障排除
      • 数据库索引损坏
    • 用户组
  • 开发 Mastodon 应用
    • API 入门指南
    • 使用公开数据
    • 获取客户端应用访问权限
    • 使用帐户登录
    • 库与实现
  • 向 Mastodon 项目做贡献
    • 技术概览
    • 设置开发环境
    • 代码结构
    • 路由
    • 漏洞赏金与责任披露
  • 遵循的标准
    • ActivityPub
    • WebFinger
    • 安全性
    • Microformats
    • OAuth
    • Bearcaps
  • REST API
    • Datetime 格式
    • 指南与最佳实践
    • OAuth 令牌
    • OAuth 作用域
    • 速率限制
  • API 方法
    • apps
      • oauth
      • emails
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • followed_tags
      • suggestions
      • tags
    • profile
    • statuses
      • media
      • polls
      • scheduled_statuses
    • timelines
      • conversations
      • lists
      • markers
      • streaming
    • grouped notifications
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
      • announcements
    • admin
      • accounts
      • canonical_email_blocks
      • dimensions
      • domain_allows
      • domain_blocks
      • email_domain_blocks
      • ip_blocks
      • measures
      • reports
      • retention
      • trends
    • proofs
    • oembed
  • API 实体
    • Account
    • AccountWarning
    • Admin::Account
    • Admin::CanonicalEmailBlock
    • Admin::Cohort
    • Admin::Dimension
    • Admin::DomainAllow
    • Admin::DomainBlock
    • Admin::EmailDomainBlock
    • Admin::Ip
    • Admin::IpBlock
    • Admin::Measure
    • Admin::Report
    • Announcement
    • Appeal
    • Application
    • Context
    • Conversation
    • CustomEmoji
    • DomainBlock
    • Error
    • ExtendedDescription
    • FamiliarFollowers
    • FeaturedTag
    • Filter
    • FilterKeyword
    • FilterResult
    • FilterStatus
    • IdentityProof
    • Instance
    • List
    • Marker
    • MediaAttachment
    • Notification
    • NotificationPolicy
    • NotificationRequest
    • Poll
    • Preferences
    • PreviewCard
    • PreviewCardAuthor
    • PrivacyPolicy
    • Reaction
    • Relationship
    • RelationshipSeveranceEvent
    • Report
    • Role
    • Rule
    • ScheduledStatus
    • Search
    • Status
    • StatusEdit
    • StatusSource
    • Suggestion
    • Tag
    • TermsOfService
    • Token
    • Translation
    • V1::Filter
    • V1::Instance
    • V1::NotificationPolicy
    • WebPushSubscription

conversations API 方法

与其他参与者直接进行的会话。(目前仅包含具有“直接”可见性的嘟文的主题。)

    • 查看所有会话
    • 删除一个会话
    • 标记会话为已读
    • 另请参考

查看所有会话

GET /api/v1/conversations HTTP/1.1

返回: Conversations 数组
OAuth: 用户令牌 + read:statuses
版本历史:
2.6.0 - 添加
3.3.0 - 现在可以同时使用 min_id 和 max_id

请求

标头
Authorization
必需 提供此标头,并使用 Bearer <user_token> 来获得对此 API 方法的访问授权。
查询参数
max_id
内部参数。 使用 HTTP Link 标头进行分页。
since_id
内部参数。 使用 HTTP Link 标头进行分页。
min_id
内部参数。 使用 HTTP Link 标头进行分页。
limit
整数。要返回的最大结果数。默认为 20 个会话。最多 40 个会话。

响应

200: OK

使用 limit=2 截断结果的 API 调用结果示例如下:

[
  {
    "id": "418450",
    "unread": true,
    "accounts": [
      {
        "id": "482403",
        "username": "amic",
        "acct": "amic@nulled.red",
        // ...
      }
    ],
    "last_status": {
      "id": "103196583826321184",
      "created_at": "2019-11-25T04:08:24.000Z",
      "in_reply_to_id": "103196540587943467",
      "in_reply_to_account_id": "14715",
      // ...
    }
  },
  {
    "id": "418374",
    "unread": false,
    "accounts": [
      {
        "id": "464472",
        "username": "freon",
        "acct": "freon@letsalllovela.in",
        // ...
      }
    ],
    "last_status": {
      "id": "103195253010396431",
      "created_at": "2019-11-24T22:29:56.331Z",
      "in_reply_to_id": "103195239650546339",
      "in_reply_to_account_id": "14715",
      // ...
    }
  }
]

由于通常不会通过任何 API 响应公开 AccountConversation ID,因此你必须解析 HTTP Link 标头才能加载较旧或较新的结果。 有关更多信息,请参见通过 API 响应进行分页。

Link: <https://mastodon.example/api/v1/conversations?limit=2&max_id=108835003356700379>; rel="next", <https://mastodon.example/api/v1/conversations?limit=2&min_id=108888782724768580>; rel="prev"
401: Unauthorized

无效或缺失的 Authorization 标头。

{
  "error": "The access token is invalid"
}

删除一个会话

DELETE /api/v1/conversations/:id HTTP/1.1

从你的会话列表中删除一个会话。

返回: 空白
OAuth: 用户令牌 + write:conversations
版本历史:
2.6.0 - 添加

请求

路径参数
:id
必需 字符串。数据库中会话的 ID。
标头
Authorization
必需 提供此标头,并使用 Bearer <user_token> 来获得对此 API 方法的访问授权。

响应

200: OK
{}
401: Unauthorized

无效或缺失的 Authorization 标头。

{
  "error": "The access token is invalid"
}
404: Not found

该会话不存在,或者不属于你。

{
  "error": "Record not found"
}

标记会话为已读

POST /api/v1/conversations/:id/read HTTP/1.1

返回: Conversations
OAuth: 用户令牌 + write:conversations
版本历史:
2.6.0 - 添加

请求

路径参数
:id
必需 字符串。数据库中会话的 ID。
标头
Authorization
必需 提供此标头,并使用 Bearer <user_token> 来获得对此 API 方法的访问授权。

响应

200: OK

unread 的值已更改为 false。

{
  "id": "418450",
  "unread": false,
  "accounts": [
    {
      "id": "482403",
      // ...
    }
  ],
  "last_status": {
    "id": "103196583826321184",
    // ...
  }
}
401: Unauthorized

无效或缺失的 Authorization 标头。

{
  "error": "The access token is invalid"
}
404: Not found

该会话不存在,或者不属于你。

{
  "error": "Record not found"
}

另请参考

app/controllers/api/v1/conversations_controller.rb

翻译状态: 本文是英文页面 conversations API methods 的翻译,最后翻译时间:2025-04-21,点击这里可以查看翻译后页面的改动。

最后更新于 April 21, 2025 · 改进此页面
也可在此找到: English

赞助商

Dotcom-Monitor LoadView Stephen Tures Swayable SponsorMotion

加入Mastodon · 博客 ·

查看源代码 · CC BY-SA 4.0 · 版权信息