Not every site has an API. For example Hexlet guides only have a set of static HTML pages with text. The same can be said of many other sites: company websites, information sites, directories, etc. In what case is it necessary to use an HTTP API?
A significant part of mobile applications is just a window of sorts to the server (backend): booking services, transfers, maps, messengers, social networks, business applications. Such applications rarely work without the Internet and almost every action by the user means requests are sent to servers to send or receive data.
When we load any site on the Internet, there are two possible ways in which the appearance of the page in the browser will be formed.
First, HTML pages are generated on the server and sent directly to the browser. Any links are processed directly by the browser and loaded by direct requests to the server, which updates the entire page. In this case, no API is used, all operations 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 page that's loaded contains JavaScript code that monitors and intercepts all events, such as button clicks. The page, in this case, is updated by code that's loaded into the browser and makes requests to the server for the necessary data. This method is needed in places with many forms and where there's complex interaction requiring instant reactions. Booking systems, chat rooms, games, and editors are implemented this way.
What HTTP APIs actually do under the hood is hidden from users. Today's web services interact with many other systems to get the data or features you want. All of this happens on the server, it doesn't reach the user in their browser or mobile app. For example, no one makes the payment systems themselves, the developers use ready-made systems that allow them to take money from users.
The structure of the API itself doesn't depend much on what we use it for. It may well be that the same API is used for the site, the mobile app, and other services.
The Hexlet support team or other students will answer you.
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.
Programming courses for beginners and experienced developers. Start training for free
Our graduates work in companies:
Sign up or sign in
Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.