Server-Server API

From IM Wiki
Revision as of 03:24, 14 July 2024 by Array in a Matrix (talk | contribs) (8 revisions imported: Import original IM Wiki )
Jump to navigation Jump to search

Matrix homeservers use Federation APIs (also known as Server-Server APIs) to communicate with one another. Homeservers use these APIs to post and query various data from other homeservers in real-time to and from one another. These APIs are implementing using HTTP secure (HTTPS) requests between independent nodes implementing the Matrix protocol, these requests are strongly authenticated on the TLS transport layer.

There are main kinds of Federation between the servers:

  • Persistent Data Units (PDUs): These events are broadcast from one HS to another HS to store persistent data (such as room state)
  • Ephemeral Data Units (EDUs): These events are pushed between pairs of homeservers, these events are not persisted on the homeservers (such as typing notification)
  • Queries: These are single request-response interactions between a given pair of servers, they are usually defined by the GET HTTP request and they are not persisted anywhere. They simple request a snapshot of state of the requested resource (such as searching in rooms)

EDUs and PDUs are further wrapped in an envelope called a Transaction, which is transferred from the origin to the destination homeserver using the HTTP PUT request.

These requests are a base of what makes Matrix a decentralized protocol as these APIs make Federation possible. For client-to-server communication read Client-Server API.