Closed OriPekelman closed 3 weeks ago
1-1 makes sense for sure - any examples in a current spec? The spec allows for things not to be in the root but then they wont be authoritative. Yes if it takes off, servers will be pinged with people looking for their APIs but I think that'll be true with whatever mechanism you use.
I disagree with 2-1: that's actually rarely true for large companies + normally there are many different API endpoints + you get no meta-data that way. You need a map. Lastly the conventions "developer.XYZ.com" and "api.XYZ.com" are generally only good enough to get a human developer there -> but the point is to enable bots.
No problem with #3 but it implies we need something like apis.json :)
In order for a client to discover APIs linked with an FQDN (for example example.com)
I. Parse FQDN
A. if the FQDN starts with www replace with api B. if the FQDN starts with [api,developers] replace keep as sucj C. if the FQDN starts with anything else add api.
Request A record for API.EXAMPLE.COM if OK proceed if nothing go for II Request TXT record for API.EXAMPLE.COM VALIDATE response (must be json, must contain JSON-API version element or something)
If no TXT record continue:
Do an HTTPS request for https://API.EXAMPLE.COM/ with content-type application/json+api VALIDATE response (must be json, must contain JSON-API version element or something) if OK proceed if invalid go for II
II. Make HTTPS request on FQDN (https://API.EXAMPLE.COM/) with content-type text/html parse resposne if found header link ... with rel-type "apis" ...
If fails Make HTTP request on FQDN (http://API.EXAMPLE.COM/)
if Fails go for III
III. fallback to http://api.example.com/apis.json
Well something like this is robust, future proof, and still allows people to implment the thing with just a simple text file on the root. Still "Conforming clients" will be much more robust. We can support an api that is not forcefully HTTP Centric .. etc.
Some other elements that could be considered: