Mastodon
  • What is Mastodon?
  • Using 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
    • More settings
    • Using Mastodon externally
    • Moving or leaving accounts
    • Running your own server
  • Running Mastodon
    • Preparing your machine
    • Installing from source
    • Configuring your environment
    • Installing optional features
      • Full-text search
      • Hidden services
      • Single Sign On
    • Setting up your new instance
    • Using the admin CLI
    • Upgrading to a new release
    • Backing up your server
    • Migrating to a new machine
    • Scaling up your server
    • Moderation actions
    • Troubleshooting errors
      • Database index corruption
  • Developing Mastodon apps
    • Getting started with the API
    • Playing with public data
    • Obtaining client app access
    • Logging in with an account
    • Guidelines and best practices
    • Libraries and implementations
  • Contributing to Mastodon
    • Technical overview
    • Setting up a dev environment
    • Code structure
    • Routes
    • Bug bounties and responsible disclosure
  • Spec compliance
    • ActivityPub
    • WebFinger
    • Security
    • Microformats
    • OAuth
    • Bearcaps
  • REST API
    • OAuth Scopes
    • Rate limits
  • API Methods
    • apps
      • oauth
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • suggestions
    • statuses
      • media
      • polls
      • scheduled_statuses
    • timelines
      • conversations
      • lists
      • markers
      • streaming
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
    • admin
    • announcements
    • proofs
    • oembed
  • API Entities
    • Account
    • Activity
    • Admin::Account
    • Admin::Report
    • Announcement
    • AnnouncementReaction
    • 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

streaming

Subscribe to server-sent events for real-time updates via a long-lived HTTP connection or via WebSocket.

    • Server-sent events (HTTP)
    • WebSocket
    • Event types

Your application can use a server-sent events endpoint to receive updates in real-time. Server-sent events is an incredibly simple transport method that relies entirely on chunked-encoding transfer, i.e. the HTTP connection is kept open and receives new data periodically.

Alternatively, a WebSocket connection can also be established.

Server-sent events (HTTP)

Endpoints

GET /api/v1/streaming/health

Returns OK when streaming service is fine. Added in 2.5.0

GET /api/v1/streaming/user

Returns events that are relevant to the authorized user, i.e. home timeline and notifications

GET /api/v1/streaming/public

Returns all public statuses

GET /api/v1/streaming/public/local

Returns all local statuses

GET /api/v1/streaming/hashtag?tag=:hashtag

Returns all public statuses for a particular hashtag

GET /api/v1/streaming/hashtag/local?tag=:hashtag

Returns all local statuses for a particular hashtag

GET /api/v1/streaming/list?list=:list_id

Returns statuses for a list

GET /api/v1/streaming/direct

Returns all direct messages

Stream contents

The stream will contain events as well as heartbeat comments. Lines that begin with a colon (:) can be ignored by parsers, they are simply there to keep the connection open. Events have this structure:

event: name
data: payload

WebSocket

For WebSockets, there is only one URL path (/api/v1/streaming). The access token as well as the endpoint you are interested in must be provided with query params, respectively access_token and stream. Query params list and tag are likewise supported for relevant endpoints.

Possible stream values:

  • user
  • public
  • public:local
  • hashtag
  • hashtag:local
  • list
  • direct

Event types

Event Description What’s in the payload
update A new status has appeared Status
notification A new notification has appeared Notification
delete A status has been deleted ID of the deleted status
filters_changed Keyword filters have been changed

The payload is JSON-encoded.

In case of filters_changed event, payload is not defined.

Last updated May 6, 2020 · Improve this page

Sponsored by

Dotcom-Monitor LoadView Stephen Tures Swayable

Join Mastodon · Blog · ·

View source · CC BY-SA 4.0 · Imprint