Search code examples
api-gatewayrest

What is the difference between a REST API and an API gateway?


I understand as REST API as a server that listens to endpoints that are filtered by HTTP verbs like POST, GET, DELETE, etc. Googling for differences didn't return useful resources. But I read that an API Gateway is used with microservices. Are these things actually the same, or maybe one is a subset of the other?


Solution

  • Am writing this response based on the architectures for few projects those I have seen and worked on too.

    In microservices, API Gateway is the first layer that an HTTP request goes through and tasks of decoding the JWT token, then finding the user privileges, then checking for the incoming route/URI and to which backend service it shall connect to, is done using API Gateway.

    It carries info about all other services those are supposed to do a work.

    Let's say -

    www.xyz.com/api/{route} is the URL that takes call to API Gateway and at API Gateway layer this {route} is then mapped to a serivce , like if info about a product has to be obtained then this will route the URI to that.

    Also it leverages us to keep those services free from any additional security layers, just API Gateway will take care of all those security related things and backend services will do the job for those they are made.

    And this is all being done via API calls, written using REST , built over HTTP.

    I hope this answers your question to some extent.