Mastodon
  • Mastodonの使い方
    • Signing up for an account
    • Setting up your profile
    • Posting toots
    • Using the network features
    • Dealing with unwanted content
    • Promoting yourself and others
    • Set your preferences
    • その他の設定
    • Using Mastodon externally
    • Moving or leaving accounts
  • Mastodonの構築
    • マシンの準備
    • ソースからインストール
    • 環境設定
    • オプションのインストール
      • 全文検索
      • 秘匿サービス
      • シングルサインオン
    • セットアップを完了する
    • 開発者向けコマンドラインを利用する
    • 新しいバージョンへアップグレード
    • サーバのバックアップ
    • 新しいマシンへの移行
    • サーバーのスケールアップ
    • モデレーション
    • トラブルシューティング
  • アプリケーションの開発
    • Getting started with the API
    • Playing with public data
    • Obtaining client app access
    • ログイン
    • ガイドラインとベストプラクティス
    • ライブラリ等
  • コントリビューション
    • 技術的情報
    • 開発環境のセットアップ
    • ソースコードの構造
    • ルーティング
  • スペック
    • ActivityPub
    • WebFinger
    • Security
    • Microformats
    • OAuth
  • REST API
    • OAuthスコープ
  • API一覧
    • apps
      • oauth
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • suggestions
    • statuses
      • media
      • polls
      • scheduled_statuses
      • streaming
    • timelines
      • conversations
      • lists
      • markers
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
    • admin
    • proofs
    • oembed
  • APIエンティティ
    • Account
    • Activity
    • Admin::Account
    • Admin::Report
    • Application
    • Attachment
    • Card
    • Context
    • Conversation
    • Emoji
    • Error
    • FeaturedTag
    • Field
    • Filter
    • History
    • IdentityProof
    • Instance
    • List
    • Marker
    • Mention
    • Notification
    • Poll
    • Preferences
    • PushSubscription
    • Relationship
    • Report
    • Results
    • ScheduledStatus
    • Source
    • Status
    • Tag
    • Token

push

Subscribe to and receive push notifications when a server-side notification is received, via the Web Push API

Web Push API

Mastodon natively supports the Web Push API. You can utilize the same mechanisms for your native app. It requires running a proxy server that connects to Android’s and Apple’s proprietary notification gateways. However, the proxy server does not have access to the contents of the notifications. For a reference, see Mozilla’s web push server, or more practically, see:

  • toot-relay
  • PushToFCM

post
Subscribe to push notifications

https://mastodon.example/api/v1/push/subscription

Add a Web Push API subscription to receive notifications. Each access token can have one push subscription. If you create a new subscription, the old subscription is deleted.

戻り値: PushSubscription
OAuth: User token + push
実装履歴:

  • 2.4.0 - 追加

リクエスト

ヘッダ
Authorization
必須
string
Bearer <user token>
フォームのパラメータ
subscription[endpoint]
必須
string
Endpoint URL that is called when a notification event occurs.
subscription[keys][p256dh]
必須
string
User agent public key. Base64 encoded string of public key of ECDH key using prime256v1 curve.
subscription[keys][auth]
必須
string
Auth secret. Base64 encoded string of 16 bytes of random data.
data[alerts][follow]
任意
boolean
Receive follow notifications?
data[alerts][favourite]
任意
boolean
Receive favourite notifications?
data[alerts][reblog]
任意
boolean
Receive reblog notifications?
data[alerts][mention]
任意
boolean
Receive mention notifications?
data[alerts][poll]
任意
boolean
Receive poll notifications?

レスポンス

200: Success

A new PushSubscription has been generated, which will send the requested alerts to your endpoint.

{
  "id": 328183,
  "endpoint": "https://yourdomain.example/listener",
  "alerts": {
    "follow": true,
    "favourite": true,
    "reblog": true,
    "mention": true,
    "poll": true
  },
  "server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}

get
Get current subscription

https://mastodon.example/api/v1/push/subscription

View the PushSubscription currently associated with this access token.

戻り値: PushSubscription
OAuth: User token + push
実装履歴:

  • 2.4.0 - 追加

リクエスト

ヘッダ
Authorization
必須
string
Bearer <user token>

レスポンス

200: Success

{
  "id": 328183,
  "endpoint": "https://yourdomain.example/listener",
  "alerts": {
    "follow": true,
    "favourite": true,
    "reblog": true,
    "mention": true,
    "poll": true
  },
  "server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}

404: Not Found

A PushSubscription does not exist for this token.

{
  "error": "Record not found"
}

put
Change types of notifications

https://mastodon.example/api/v1/push/subscription

Updates the current push subscription. Only the data part can be updated. To change fundamentals, a new subscription must be created instead.

戻り値: PushSubscription
OAuth: User token + push
実装履歴:

  • 2.4.0 - 追加

リクエスト

ヘッダ
Authorization
必須
string
Bearer <user token>
フォームのパラメータ
data[alerts][follow]
任意
boolean
Receive follow notifications?
data[alerts][favourite]
任意
boolean
Receive favourite notifications?
data[alerts][reblog]
任意
boolean
Receive reblog notifications?
data[alerts][mention]
任意
boolean
Receive mention notifications?
data[alerts][poll]
任意
boolean
Receive poll notifications?

レスポンス

200: Success

Updating a PushSubscription to only receive mention alerts

{
  "id": 328183,
  "endpoint": "https://yourdomain.example/listener",
  "alerts": {
    "follow": false,
    "favourite": false,
    "reblog": false,
    "mention": true,
    "poll": false
  },
  "server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}

404: Not Found

No existing PushSubscription for this token

{
  "error": "Record not found"
}

delete
Remove current subscription

https://mastodon.example/api/v1/push/subscription

Removes the current Web Push API subscription.

戻り値: none
OAuth: User token + push
実装履歴:

  • 2.4.0 - 追加

リクエスト

ヘッダ
Authorization
必須
string
Bearer <user token>

レスポンス

200: Success

PushSubscription successfully deleted or did not exist previously

{}

最終更新 May 17, 2020 · このページを改善する
他の言語: English

Merch

Tシャツとステッカー(英語)

Mastodonに参加しよう · ブログ · ·

ソースコード · CC BY-SA 4.0 · インプリント