ESB is traditional middleware used in SOA solutions for routing, message transformation, protocol bridging, among other things. A new category of middleware solutions called API Gateway are now offered by several vendors. These solutions are commonly described as the central point to access the REST and SOAP services offered publicly by an organization. However, API Gateway solutions seem to offer a subset of typical ESB features.
So, what are the differences between ESB and API Gateway? When should I use one or the other?