APPLICATION PROGRAMMING INTERFACE (APIs)

Using a life scenario to explain the existence of APIs is the best way to communicate with someone that needs an extensive understanding of APIs.

Taking a standard restaurant as an example.We have the waiter, kitchen, client, and menu.

As the client(interface), you make an order(request) from the menu on your table, the waiter(API) comes around to pick your order and send it to the kitchen(database) to prepare and return your order(response). APIs are the intermediary between frontend and backend and the main purpose is for sending requests and receiving responses.

THE ANATOMY OF URL(Uniform resources locator)

Understanding the anatomy of URL is the key to know how HTTPS, domains, APIs, endpoints, and query parameters work.

api.themoviedb.org/3/movie/upcoming?api_key..

Using the above URL for explanation :

  • HTTPS is a secured protocol and the security of this protocol can be identified by a padlock icon that is locked while HTTP is an unsecured protocol.

  • api.themoviedb.org is the domain name

  • movie is the API that has an endpoint "/upcoming/" (an example of endpoint/path you wish to collect data from)

  • ?api_key=229c849a6b383c4b10bad6a2aa48ab90 In some cases, we have query parameters. A query parameter is a key value pair of query name and query value . It comes after the endpoint and starts with ?, they're displayed like this (? query name = query value).We can have as many query parameters as possible. The way to add query parameter is by appending an hand operator.

Documentation is the only way to have enough understanding on how to access other web server APIs endpoint.