The basic idea of a REST API is to provide an abstraction of implementation details and logic of, in your case, domain information. Under this point of view the abstraction could fit because you retrieve domain information from domains in your portfolio and from domains not in your portfolio.
But there is also some difference in retrieving domain information, for example retrieving domain information about domains not in your portfolio is slow, or at least slower than retrieving information for domains in your portfolio. Another difference is that for REST APIs often some bulk capabilities for retrieving more than one resource information are provided like this GET /domains/example.com,anotherexample.com,localhost.com/
. You will/might not want such functionality to be accessible when retrieving information about domains that are not in your portfolio.
Another reason why you might split the resources is that you could implement a call that retrieves all information about domains in your portfolio:
GET /domains/
This request could obviously only return information about domains in your portfolio, so your abstraction would break in that case.
When you model your REST API to retrieve domain availability I would suggest to use a resource like
PUT /availabilities/example.com
to create a domain availability check. This resource could create a sub resource example.com
that can be then used to retrieve information about this availability check, or used to cache domain availability check results via:
GET /availabilities/example.com
Taking all these arguments together I'd favor splitting resources, because:
- In case an API user is interested in detailed domain information of domains in your portfolio the API user could check the
/domains
resource
- To get information if a domain is in your portfolio the user would also use the
/domains/example.com
resource
- API users that are only interested in a domain availability check can use the
availabilities
resource to perform this check.