API Model for Search Service
Explore how to model a search API to meet key functional requirements, including endpoint definitions, HTTP methods, and data structures for client-server communication. Understand private API interactions with recommendation and ads services, plus error handling for a scalable search system.
In this lesson, we model the search API to meet the functional requirements we identified in the first lesson. We also focus on essential data entities to be exchanged in the request and response while targeting various endpoints.
Let's start the discussion by defining the base URL for our search API.
Base URL and API endpoints
The base URL can be defined as the common prefix for all the endpoints of API. We defined the following base URL for the search API:
The following illustration represents the URLs and their HTTP methods used by the search service.
The details of query string parameters that we mentioned in the URLs above are given below:
Search: The search keywords are passed as a
queryparameter along with the base URL.Sort: The
orderdefines the sequence of the records (such as descending or ascending). Additionally, thesortparameter sorts the results based on the field provided in the query parameter—for example, ...