API routing patterns - AWS Prescriptive Guidance

API routing patterns

In agile development environments, autonomous teams (for example squads and tribes) own one or more services that include many microservices. The teams expose these services as APIs to allow their consumers to interact with their group of services and actions.

There are three major methods for exposing HTTP APIs to upstream consumers by using hostnames and paths:

Method

Description

Example

Hostname routing

Expose each service as a hostname.

billing.api.example.com

Path routing

Expose each service as a path.

api.example.com/billing

Header-based routing

Expose each service as an HTTP header.

x-example-action: something

This section outlines typical use cases for these three routing methods and their trade-offs to help you decide which method best fits your requirements and organizational structure.