Not every site has an API. For example, Hexlet guides only have several static HTML pages with text. We can say the same about many other sites: company websites, information sites, directories, etc. In what case is it necessary to use an HTTP API?
Mobile applications
A significant part of mobile applications is just a window to the server (backend): booking services, transfers, maps, messengers, social networks, and business applications. Such applications rarely work without the Internet. Almost every action by the user means requests are sent to servers to send or receive data.
JavaScript frontend
When we load any site on the Internet, there are two possible ways of how the page's appearance in the browser will form.
First, HTML pages are generated on the server and sent directly to the browser. After that, the browser processes links and sends direct requests to the server to update the page. In other words, we use no API in that case. Every operation with data and HTML occurs on the server. This method works well where there's little user interaction and many pages of text, such as with Wikipedia or Google.
Secondly, the loaded page contains JavaScript code that monitors and intercepts all events. Such pages update with the code, which loads into the browser and requests the server for the necessary data.
This method helps in places with many forms and complex interactions requiring instant reactions. For example, booking systems, chat rooms, games, and editors implement this way.
Services for Services
What HTTP APIs do under the hood is hidden from users. Web services interact with many other systems to get the data you want. It happens on the server, so it doesn't reach the user in their browser or mobile app. For example, no one makes the payment systems themselves. Developers use ready-made platforms that allow them to take money from users.
Let's look at the big picture
The API structure doesn't depend much on what we use it for. We can use the same API for the site, the mobile app, and other services.
Are there any more questions? Ask them in the Discussion section.
The Hexlet support team or other students will answer you.
For full access to the course you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.