Search⌘ K
AI Features

Requirements of the Messenger API

Understand the key functional needs and non-functional constraints required for designing a Messenger API. Learn how features like message delivery, media sharing, and security impact API architecture to support real-time, secure, and highly available messaging services.

Introduction to Messenger

Instant messaging applications, such as Messenger, WhatsApp, and Telegram, connect millions of people who share billions of messages daily. These applications utilize the latest technologies to efficiently handle a large number of users and messages via their extensive API. To understand the working of these APIs, let's design an API for Facebook Messenger. We need to determine what services the Messenger API utilizes and how the interaction occurs between them to assist real-time chat. Before we dive deep into the design of the Messenger API, we will identify requirements and focus on the workflow that takes place via the interacting entities.

We’ll start our discussion by identifying the important requirements for the Messenger API.

Requirements

To design API for Messenger, we will focus on the following functional and non-functional requirements:

Functional requirements

  • Conversation: The Messenger API should allow users to send one-to-one messages, as well as group messages.

  • Sharing of media files: The API should allow the sharing of media files, including audio, images, and videos.

  • Message status: The API should allow users to check the status of a message, such as sent, failed, delivered, and read.

  • A paginated list of chats: The Messenger API should provide a paginated list of messages from a chat. These messages should be able to be viewed without an internet connection, so they should be stored locally on the client side.

Non-functional requirements

  • Consistency: Messages should be delivered in the order they were sent by the user, and the API should provide similar message history across different clients/devices.

  • Availability: The API should be highly available to provide smooth services to users.

  • Security: The communication between users and the API should be secure and end-to-end encrypted.

  • Latency: Because it is an instant messaging application, the API should deliver messages with the minimum possible latency.

Prerequisites

Before embarking on the design of the Messenger API, we need to have an in-depth understanding of the following concepts:

  • API for file upload service: This chapter describes the design of API for one of the functional requirements of Messenger, which is the sharing of media files.
  • Security mechanisms: We also need different security mechanisms to make the communication secure between the client and server. This chapter discusses various techniques that make communication secure.
  • Event-driven protocols: The chat application is governed by different event-driven protocols that are discussed in this chapter.

How will we design the Messenger API?

We have divided the rest of the chapter into the following lessons:

  1. Messenger API Design Decisions: his lesson will focus on some technical aspects that govern the design of the Messenger API.

  2. API Model for Messenger: Here, we will present the design of the Messenger API based on the architectural and technical assumptions we decided on in the previous lesson.

  3. Messenger API Design Evaluation and Latency Budget: In this lesson, we will discuss various optimization strategies, tradeoffs, and response times of the Messenger API.

Quiz

We now want to design the API for Facebook Messenger. You’re tasked with deciding the architectural styles for the API between:

  1. Client to API gateway

  2. API gateway to back-end services

Provide your answer in the widget below.

API design for Facebook Messenger
API design for Facebook Messenger
Architectural style for Messenger API

Let's start with the design decisions for Messenger API.