APIs are a way to enable the application to get data from a database. It acts like some sort of middleware.

graph TD

  Application--> API
  API--> Application
  API--> DATABASE
  DATABASE--> API

Rather than having the application communicate directly with the database, the application communicates with the api and then to the database. This simplifies the data retrieval process.

Example of an API

Say that from the database fruits_nutrition which includes nutrition info on fruits, you want to display calories of fruits.

Normally, to query this database you could do

SELECT * FROM fruits_nutrition

But what if you wanted to filter to only apple and grapes. You could manually query

SELECT apple, grapes from fruits_nutrition

but it would be very inconvenient if you want to change the queries often for filtering.

What you could do is make an API that changes the query based on the filter that you’ve chosen.

API Requests and responses

  1. API clients
  1. API requests