Communicating between services through APIs
A central component in microservice architectures is the use of APIs. An API is a part that allows you to connect two microservices (or other pieces of code) together.
APIs are much like websites. Just like a website, an API is built behind a website-like link or an IP address. When you go to a website, the server of the website sends you the code that represents the website. Your internet browser then interprets this code and shows you a web page.
When you call an API, the API will receive your request. The request triggers your code to be run on the server and generates a response that is sent back to you. If something goes wrong (maybe your request was not as expected or an error occurs), you may not receive any response, or receive an error code such as request not authorized
or internal server error
.
The following figure shows a flow chart that covers this. A computer or user sends an HTTP request, and the API server sends back...