API Model for Comment Service
Design the API model for a comment service.
In this lesson, we will focus on the API design for a comment service that directs the request and response between clients and servers. We’ll also discuss different API calls using HTTP methods that fulfill our functional requirements, which we discussed in the Requirements of the Comment API lesson. Furthermore, as discussed in the previous lesson, we will adopt the REST API style for the communication between a client and an API gateway. Let's start with the base URL of our API
Base URL and API endpoints
We can consider the following base URL for the comment service, which we will use in the following sections.
Here, api.comment.com
represents the domain and {version}
shows the API version. In our design, we will assume v1.0
as the first version of our API. The comments
field indicates the type of service for which we aim to design an API. Since we will perform operations on the given URL via HTTP methods, it will be a part of our discussion in the following sections.
Point to Ponder
In the base URL, why don’t we add functions like create, get, update, and delete comments to make it user friendly and readable?
As shown in the figure below, we consider the following endpoints and the methods used to perform various operations on these endpoints.
The message format for API endpoints
This section presents data entities, requests, and response structures for each functional requirement. Let's start our discussion with the data entities as given below.
Comment data entities
A comment has the following essential parameters that must be ...