An application programming interface (API) is a piece of software that provides a means of sending and receiving data, to and from a database.
An external application may connect to an API and request data, at which point the API will process the request and extract the required data from the database before sending it back to the external application.
An API provides a protective layer to a database that can check the authenticity of requests and their frequency. If the source of the request is unauthorised, or has sent too many requests in a given period, the API can reject the request and no data is sent.
APIs can also accept incoming data and make changes to the database, based on this data. An external application may request a new user account be created, for example. The user data would be sent to the API for approval before being stored in the database.
APIs allow developers to focus on creating front-end displays which simply organise the data received from the API into a human-readable format. Many different applications can connect to the same API, and an application can connect to many different APIs to access different information.
An example of a popular API is OpenWeatherMap which provides weather data. An external application may send a request to this API, which might include specific region and time data, and the API will respond with relevant weather information. That information can then be presented in the form of graphs or tables by the external application.