<p>Our application is based on an API first architecture and is currently based on a single domain / service:</p>

<p><code>api.todos.com</code></p>

<p>Consumers of the API are :</p>

<ul>
<li>Our web-frontend</li>
<li>Our mobile-apps</li>
<li>Other business / public</li>
</ul>

<p>We will be building new <em>micro-services</em> written in different languages for the same application. For example we might develop API services for:</p>

<ul>
<li>Statistics</li>
<li>Blog / Content</li>
<li>RSS Feed</li>
<li>Search</li>
</ul>

<p>My question is around dealing with domains. Would it be best to split each service into a different subdomain e.g.</p>

<ul>
<li><code>api.todos.com</code></li>
<li><code>stats.todos.com</code></li>
<li><code>content.todos.com</code></li>
<li><code>rss.todos.com</code></li>
<li><code>search.todos.com</code></li>
</ul>

<p>Or is it better to have a single unified API domain where we do HTTP (layer 7) routing to reach our endpoints. e.g.</p>

<ul>
<li><code>api.todos.com/todos</code></li>
<li><code>api.todos.com/stats</code></li>
<li><code>api.todos.com/content</code></li>
<li><code>api.todos.com/rss</code></li>
<li><code>api.todos.com/search</code></li>
</ul>

<p>Not sure which is preferable for a public API? It would be easier to have multiple sub-domains and not have to deal with an intermediate routing layer / proxy.</p>

<p>As System Architect I think <code>it is better to have a single unified API domain where we do HTTP (layer 7) routing to reach our endpoints</code>. You can make your system more flexible without any changes for your clients. For example you have a microservice with routes:</p>

<ul>
<li>api.todos.com/route1</li>
<li>api.todos.com/route2</li>
</ul>

<p>In future you can split the microservice by this routes.</p>

<p>But mostly, it depends on what API Gateway will you use. API gateway is single entry point in your system, what proxy request to correct microservice. Also it make auth and cache. More about this microservice's pattern you can read <a href="http://microservices.io/patterns/apigateway.html" rel="nofollow noreferrer">here</a>.</p>
