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

announcements API 方法

用于管理设置的公告。

    • 查看所有公告
    • 忽略公告
    • 向公告添加回应
    • 从公告中删除回应
    • 另请参考

查看所有公告

GET /api/v1/announcements HTTP/1.1

查看管理员设置的所有当前生效的公告。

返回: Announcement 数组
OAuth: 用户令牌
版本历史:
3.1.0 - 添加

请求

标头
Authorization
必需 提供此标头,其中包含 Bearer <user_token> 以获得对此 API 方法的访问授权。

响应

200: OK

当前生效的公告

[
  {
    "id": "8",
    "content": "<p>Looks like there was an issue processing audio attachments without embedded art since yesterday due to an experimental new feature. That issue has now been fixed, so you may see older posts with audio from other servers pop up in your feeds now as they are being finally properly processed. Sorry!</p>",
    "starts_at": null,
    "ends_at": null,
    "all_day": false,
    "published_at": "2020-07-03T01:27:38.726Z",
    "updated_at": "2020-07-03T01:27:38.752Z",
    "read": true,
    "mentions": [],
    "statuses": [],
    "tags": [],
    "emojis": [],
    "reactions": [
      {
        "name": "bongoCat",
        "count": 9,
        "me": false,
        "url": "https://files.mastodon.social/custom_emojis/images/000/067/715/original/fdba57dff7576d53.png",
        "static_url": "https://files.mastodon.social/custom_emojis/images/000/067/715/static/fdba57dff7576d53.png"
      },
      {
        "name": "thonking",
        "count": 1,
        "me": false,
        "url": "https://files.mastodon.social/custom_emojis/images/000/098/690/original/a8d36edc4a7032e8.png",
        "static_url": "https://files.mastodon.social/custom_emojis/images/000/098/690/static/a8d36edc4a7032e8.png"
      },
      {
        "name": "AAAAAA",
        "count": 1,
        "me": false,
        "url": "https://files.mastodon.social/custom_emojis/images/000/071/387/original/AAAAAA.png",
        "static_url": "https://files.mastodon.social/custom_emojis/images/000/071/387/static/AAAAAA.png"
      },
      {
        "name": "🤔",
        "count": 1,
        "me": true
      }
    ]
  }
]
401: Unauthorized

Authorization 标头缺失或无效。

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

忽略公告

POST /api/v1/announcements/:id/dismiss HTTP/1.1

允许用户将公告标记为已读。

返回: 空
OAuth: 用户令牌 + write:accounts
版本历史:
3.1.0 - 添加

请求

路径参数
:id
必需 字符串。 数据库中公告的 ID。
标头
Authorization
必需 提供此标头,其中包含 Bearer <user_token> 以获得对此 API 方法的访问授权。

响应

200: OK
{}
401: Unauthorized

Authorization 标头缺失或无效。

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

具有给定iID的公告不存在

{
  "error": "Record not found"
}

向公告添加回应

PUT /api/v1/announcements/:id/reactions/:name HTTP/1.1

使用表情对公告做出回应。

返回: 空
OAuth: 用户令牌 + write:favourites
版本历史:
3.1.0 - 添加

请求

路径参数
:id
必需 字符串。 数据库中公告的ID。
:name
必需 字符串。 Unicode 表情,或自定义表情的短代码。
标头
Authorization
必需 提供此标头,其中包含 Bearer <user_token> 以获得对此 API 方法的访问授权。

响应

200: OK
{}
401: Unauthorized

Authorization 标头缺失或无效。

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

具有给定ID的公告不存在

{
  "error": "Record not found"
}
422: Unprocessable entity
{
  "error": "Validation failed: Name is not a recognized emoji"
}

从公告中删除回应

DELETE /api/v1/announcements/:id/reactions/:name HTTP/1.1

撤消对公告的表情回应。

返回: 空
OAuth: 用户令牌 + write:favourites
版本历史:
3.1.0 - 添加

请求

路径参数
:id
必需 字符串。 数据库中公告的 ID。
:name
必需 字符串。 Unicode 表情,或自定义表情的短代码。
标头
Authorization
必需 提供此标头,其中包含 Bearer <user_token> 以获得对此 API 方法的访问授权。

响应

200: OK
{}
401: Unauthorized

Authorization 标头缺失或无效。

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

具有给定 ID 的公告不存在

{
  "error": "Record not found"
}
422: Unprocessable entity
{
  "error": "Validation failed: Name is not a recognized emoji"
}

另请参考

app/controllers/api/v1/announcements_controller.rb
app/controllers/api/v1/announcements/reactions_controller.rb

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

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

赞助商

Dotcom-Monitor LoadView Stephen Tures Swayable SponsorMotion

加入Mastodon · 博客 ·

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