API or Application Programming Interface is an interface that other applications can interact with it. It is used when two or more applications want to communicate.
Let's imagine that we have a twitter-like frontend website that wants to show the feed.
The frontend website has to request data from the backend. It will have to connect to the backend through an API that the backend exposes.
Why do we need it? Because frontend and backend are two separate applications.
// Overview Frontend -> Backend // If we zoom in, it will look like this. Frontend -> [Backend API -> Backend] Backend Application