<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="rfc7991bis.rnc"?>
<!-- <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?> -->
<!DOCTYPE rfc [
<!ENTITY nbsp   "&#160;">
<!ENTITY zwsp   "&#8203;">
<!ENTITY nbhy   "&#8209;">
<!ENTITY wj     "&#8288;">
]>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="std" docName="draft-smith-api-catalog-03" ipr="trust200902"  obsoletes="" updates="" submissionType="IETF" xml:lang="en" version="3">
	<front>
		<title abbrev="api-catalog">api-catalog: A well-known URI to help discovery of APIs</title>
		<seriesInfo name="Internet-Draft" value="draft-smith-api-catalog-03"/>
		<author fullname="Kevin Smith" initials="K" role="editor" surname="Smith">
			<organization>Vodafone</organization>
			<address>
				<postal>
					<street>One Kingdom Street</street>
					<city>London</city>
					<code>W2 6BY</code>
					<country>GB</country>
				</postal>
				<email>kevin.smith@vodafone.com</email>
				<uri>www.vodafone.com</uri>
			</address>
		</author>
		<date year="2023" month="" day=""/>
		<!-- https://authors.ietf.org/en/rfcxml-vocabulary#date -->
		<area>General</area>
		<workgroup>Internet Engineering Task Force</workgroup>
		<keyword>well-known</keyword>
		<keyword>API</keyword>
		<abstract>
			<t>This document defines the "api-catalog" well-known URI. It is intended to facilitate discovery of the APIs published by a Web host.</t>
		</abstract>
	</front>
	<middle>
		<section>
			<!-- The default attributes for <section> are numbered="true" and toc="default" -->
			<name>Introduction</name>
			<t>A Web host may publish Application Programming Interfaces (APIs) to encourage requests for interaction from external parties. Such APIs must be discovered before they may be used - i.e., the external party needs to know what APIs a given Web host exposes, including their purpose, any policies for usage, and the endpoints to interact with the APIs. To faciliate discovery of this information, this document proposes a well-known URI, 'api-catalog', as a location where a Web host's API endpoints are listed and described.</t>
			<section anchor="goals">
				<name>Goals and non-goals</name>
				<t>The primary goal is to facilitate the discovery of a Web Host's public API endpoints, along with metadata that describes the purpose and usage of each API. The api-catalog is primarily machine-readable to enable automated discovery and usage of APIs. The api-catalog may also include links to human-readable documentation.</t>
				<t>Non-goals: this document does not mandate paths for API endpoints. i.e., it does not mandate that my_example_api should be available at example.com/.well-known/api-catalog/my_example_api (although it is not forbidden to do so).</t>
			</section>
			<section anchor="requirements">
				<name>Requirements Language</name>
				<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 
					<xref target="RFC2119"/> when, and only when, they appear in all capitals, as shown here.
				</t>
			</section>
		</section>
		<section>
			<name>Using the 'api-catalog' well-known URI</name>
			<t>The api-catalog well-known URI is intended for HTTP(S) servers that publish APIs and wish to facilitate their discovery and usage. Since the purpose of the api-catalog well-known URI is to facilitate API discovery with minimal prior knowledge, it is recommended that /.well-known/api-catalog be hosted at a predictable hostname, e.g. www.example.com . It may also be hosted at other hostnames, e.g. api.example.com, developer.example.com etc.</t>
			<t>A Web host (example.com) supporting this URI:</t>
			<ul>
				<li>SHALL resolve an HTTP(S) GET request to /.well-known/api-catalog and return an api-catalog linkset as defined in this document</li>
				<li>SHOULD resolve an HTTP(S) HEAD request to /.well-known/api-catalog with a response including a Link header with the relation(s) defined in <xref target="LINK-RELATION" /> (Editor's note: TODO, add a section for this).</li>
			</ul>
		</section>
		<section anchor="LINK-RELATION">
			<name>Link relations</name>
			<t>"api-catalog" . Links to an api-catalog as defined in this document.</t>		
			<t>"service-desc" . Defined in <xref target="RFC8615" />, used to link to a description of the API that
   is primarily intended for machine consumption.</t>	
			<t>"service-doc" . Defined in <xref target="RFC8615" />, used to link to API documentation that
   is primarily intended for human consumption.</t>	
			<t>"service-meta" . Defined in <xref target="RFC8615" />, used to link to additional metadata about the API, and is primarily intended for machine consumption.</t>
			<t>"status" . Defined in <xref target="RFC8615" />, used to link to the API status (e.g. API "health" indication etc.) for machine and/or human consumption.</t>			
		</section>
		<section anchor="MEDIA-TYPE">
			<name>Associated Media type: the api-catalog linkset </name>
			<t>A GET request to the api-catalog well-known URI SHALL return a linkset <xref target="RFC9264"/> containing an array of linkset context objects. Each linkset context object MUST include an anchor with a URI reference for an API endpoint, and a "service-desc" link relation. The link relations for "status", "service-doc", "service-meta" MAY be included.</t>		
			<t>Example request:</t>
			<figure>
				<name>api-catalog linkset example</name>
<sourcecode name="api-catalog-linkset" type="JSON">
<![CDATA[
GET .well-know/api-catalog HTTP/1.1
Host: example.com
Accept: application/linkset+json

HTTP/1.1 200 OK
Date: Mon, 01 Jun 2023 00:00:01 GMT
Server: Apache-Coyote/1.1
Content-Type: application/linkset+json

{
  "linkset": [
    {
      "anchor": "https://developer.example.com/apis/foo_api",
      "service-desc": [
        {
          "href": "https://developer.example.com/apis/foo_api/spec",
          "type": "text/n3"
        }
      ],
      "status": [
        {
          "href": "https://developer.example.com/apis/foo_api/status",
          "type": "application/json"
        }
      ],	  
      "service-doc": [
        {
          "href": "https://developer.example.com/apis/foo_api/doc",
          "type": "text/html"
        }
      ],	  
      "service-meta": [
        {
          "href": "https://developer.example.com/apis/foo_api/policies",
          "type": "text/xml"
        }
      ]
    },
	
    {
      "anchor": "https://developer.example.com/apis/bar_api",
      "service-desc": [
        {
          "href": "https://developer.example.com/apis/bar_api/spec",
          "type": "application/json"
        }
      ],
      "status": [
        {
          "href": "https://developer.example.com/apis/bar_api/status",
          "type": "application/json"
        }
      ],	  
      "service-doc": [
        {
          "href": "https://developer.example.com/apis/bar_api/doc",
          "type": "text/plain"
        }
      ]
    },
    {
      "anchor": "https://developer.example.com/apis/cantona_api",
      "service-desc": [
        {
          "href": "https://developer.example.com/apis/cantona_api/spec",
          "type": "text/n3"
        }
      ],
      "service-doc": [
        {
          "href": "https://developer.example.com/apis/cantona_api/doc",
          "type": "text/html"
        }
      ]
    }
  ]
}]]>
</sourcecode>
			</figure>
		</section>

		<section>
			<name>Conformance to RFC8615</name>
			<t>The requirements in section 3 of <xref target="RFC8615" /> for defining Well-Known Uniform Resource Identifiers are met as follows:</t>
			<section>
				<name>Path prefix</name>
				<t>The api-catalog URI SHALL be appended to the /.well-known/ path-prefix for "well-known locations".
				</t>
			</section>
			<section>
				<name>Supported URI schemes</name>
				<t>The api-catalog well-known URI may be used with the HTTP and HTTPS URI schemes.</t>
			</section>
			<section>
				<name>Registration of the api-catalog well-known URI</name>
				<t>See 
					<xref target="IANA"/> considerations below.
				</t>
			</section>
		</section>
		<section anchor="IANA">
			<name>IANA Considerations</name>
			<section>
				<name>The api-catalog well-known URI</name>
				<t> This specification registers the "api-catalog" well-known URI in the Well-Known URI Registry as defined by 
					<xref target="RFC6415"/> .
				</t>
				<t>URI suffix: api-catalog</t>
				<t>Specification document(s):  draft-smith-api-catalog-03</t>
				<t>Related information:  The "api-catalog" documents obtained from the same host using the HTTP and HTTPS protocols (using default ports) MUST be identical.</t>
			</section>
			<section>
				<name>The api-catalog link relation</name>
				<t> This specification registers the "api-catalog" link relation by following the procedures per section 4.2.2 of 
					<xref target="RFC8288"/>  (Editor's note: IANA registrations are TODO).
				</t>
				<t> Relation Name:  api-catalog</t>
				<t> Description:  Identifies a catalog of APIs published by the context Web host.</t>
				<t> Reference:  draft-smith-api-catalog-03</t>
			</section>
		</section>
		<section anchor="Security">
			<!-- All drafts are required to have a security considerations section. See RFC 3552 for a guide. -->
			<name>Security Considerations</name>
			<t>TBD</t>
		</section>
	</middle>
	<back>
		<references>
			<name>References</name>
			<references>
				<name>Normative References</name>
				<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6415.xml"/>
				<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8288.xml"/>				
				<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8615.xml"/>				
				<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9264.xml"/>
				<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8631.xml"/>				
			</references>
			<references>
				<name>Informative References</name>
				<reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
					<!-- Manually added reference -->
					<front>
						<title>Key words for use in RFCs to Indicate Requirement Levels</title>
						<author initials="S." surname="Bradner" fullname="S. Bradner">
							<organization/>
						</author>
						<date year="1997" month="March"/>
						<abstract>
							<t>In many standards track documents several words are used to signify the requirements in the specification. 
							These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. 
							This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.
              </t>
						</abstract>
					</front>
					<seriesInfo name="BCP" value="14"/>
					<seriesInfo name="RFC" value="2119"/>
					<seriesInfo name="DOI" value="10.17487/RFC2119"/>
				</reference>
			</references>
		</references>
		<section anchor="Acknowledgements" numbered="false">
			<!-- an Acknowledgements section is optional -->
			<name>Acknowledgements</name>
			<t>TODO</t>
		</section>
	</back>
</rfc>