<?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-ietf-httpapi-api-catalog-00" ipr="trust200902"  obsoletes="" updates="" submissionType="IETF" xml:lang="en" version="3" consensus="true">
    <front>
        <title abbrev="api-catalog">api-catalog: A well-known URI to help discovery of APIs</title>
        <seriesInfo name="Internet-Draft" value="draft-ietf-httpapi-api-catalog-00"/>
        <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="September" day="12"/>
        <!-- https://authors.ietf.org/en/rfcxml-vocabulary#date -->
        <area>Applications and Real-Time</area>
        <workgroup>HTTPAPI</workgroup>
        <keyword>Internet-Draft</keyword>
        <abstract>
            <t>This document defines the "api-catalog" well-known URI. It is intended to facilitate automated discovery and usage 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, their purpose, any policies for usage, and the endpoints to interact with the APIs. To faciliate automated discovery of this information, and automated usage of the APIs, this document proposes a well-known URI, 'api-catalog', as a location where a Web host's API endpoints are described in an API catalog document.</t>
            <section anchor="goals">
                <name>Goals and non-goals</name>
                <t>The primary goal is to facilitate the automated discovery of a Web Host's public API endpoints, along with metadata that describes the purpose and usage of each API, by specifying a well-known URI <xref target="RFC8615"/> that returns an API catalog document. The API catalog document is primarily machine-readable to enable automated discovery and usage of APIs, and it 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). This document does not mandate a specific format for the API catalog document, although it does suggest some existing formats and general guidance regarding the content.</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 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" /></li>
            </ul>
        </section>
        <section anchor="API-CATALOG">
            <name>The API Catalog</name>
            <t>There is no mandated format for the API Catalog document. The Web Host is free to choose any format that supports the automated discovery, and machine (and human) usage of their APIs. The Web Host may choose to include useful metadata, including API version information, usage policies etc. - and is recommended to support link relations to support machine discovery and usage of APIs. Some example formats/contents include:</t> 
            <ul>
                <li>A linkset <xref target="RFC9264"/> of API endpoints</li>
                <li>API bookmarks that represent an API entry-point and may be followed to discover purpose and usage</li>
                <li>Links to the OpenAPI Specification <xref target="OAS"/> definitions for each API</li>
                <li>A RESTDesc semantic description for hypermedia APIs <xref target="RESTdesc"/></li>
                <li>An APIs.json document <xref target="APIs.json"/></li>
                <li>A Hypertext Application Language document <xref target="HAL"/></li>
                <li>Any other format decided by the Web Host</li>
            </ul>
            <t>Appendix A includes  some example API Catalog documents based on the linkset and 'bookmark' formats.</t>   
        </section>
        <section anchor="LINK-RELATION">
            <name>Link relations</name>
            <t>"api-catalog" . Refers to an API catalog documenting the Web Host's API.</t>     
        </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-ietf-httpapi-api-catalog-00</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"/>
                </t>
                <t> Relation Name:  api-catalog</t>
                <t> Description:  Identifies a catalog of APIs published by the context Web host.</t>
                <t> Reference:  draft-ietf-httpapi-api-catalog-00</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>
                <reference anchor="OAS" target="https://spec.openapis.org/oas/latest.html">
                    <!-- Manually added reference -->
                    <front>
                        <title>OpenAPI Specification</title>
                        <author initials="D." surname="Miller" fullname="Darrel Miller"/>
                        <author initials="J." surname="Whitlock" fullname="Jeremy Whitlock"/>
                        <author initials="M." surname="Gardiner" fullname="Marsh Gardiner"/>
                        <author initials="M." surname="Ralphson" fullname="Mike Ralphson"/>
                        <author initials="R." surname="Ratovsky" fullname="Ron Ratovsky"/>
                        <author initials="U." surname="Sarid" fullname="Uri Sarid"/>
                        <date year="2021" month="February"/>
                        <abstract>
                            <t>The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic.</t>
                        </abstract>
                    </front>
                </reference>
                <reference anchor="HAL" target="https://stateless.co/hal_specification.html">
                    <!-- Manually added reference -->
                    <front>
                        <title>Hypertext Application Language</title>
                        <author initials="M." surname="Kelly" fullname="Mike Kelly">
                            <organization>stateless.co</organization>
                        </author>
                        <date year="2013" month="September"/>
                        <abstract>
                            <t>HAL is a simple format that gives a consistent and easy way to hyperlink between resources in your API.</t>
                        </abstract>
                    </front>
                </reference>
                <reference anchor="APIs.json" target="http://apisjson.org/format/apisjson_0.16.txt">
                    <!-- Manually added reference -->
                    <front>
                        <title>APIs.json</title>
                        <author initials="K." surname="Lane" fullname="Kin Lane"/>
                        <author initials="S." surname="Willmott" fullname="Steve Willmott"/>
                        <date year="2020" month="September"/>
                        <abstract>
                            <t>APIs.json is a machine readable specification that API providers can use to describe their API operations.</t>
                        </abstract>
                    </front>
                </reference>
                <reference anchor="RESTdesc" target="https://restdesc.org/">
                    <!-- Manually added reference -->
                    <front>
                        <title>RESTdesc</title>
                        <author initials="R." surname="Verborgh" fullname="Ruben Verborgh"/>
                        <author initials="E." surname="Mannens" fullname="Erik Mannens"/>
                        <author initials="R." surname="Van de Walle" fullname="Rick Van de Walle"/>
                        <author initials="T." surname="Steiner" fullname="Thomas Steiner"/>
                        <date year="2023" month="September"/>
                        <abstract>
                            <t>Semantic descriptions for hypermedia APIs.</t>
                        </abstract>
                    </front>
                </reference>
            </references>
        </references>
        <section>
            <name>Example API catalog documents</name>
            <t>This section is informative, and non-exhaustive. It presents some example API catalog document formats (other formats may be used).</t>
            <section>
                <name>Using Linkset with RFC8615 relations</name>
                <t>This example uses the linkset format <xref target="RFC9264"/>, and the following link relations defined in <xref target="RFC8631"/>:</t>
                <ul>
                    <li>"service-desc",used to link to a description of the API that is primarily intended for machine consumption.</li>
                    <li>"service-doc", used to link to API documentation that is primarily intended for human consumption.</li>
                    <li>"service-meta", used to link to additional metadata about the API, and is primarily intended for machine consumption.</li>
                    <li>"status", used to link to the API status (e.g.API "health" indication etc.) for machine and/or human consumption.</li>  
                </ul>
                <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>Using Linkset with bookmarks</name>
                <t>This example also uses the linkset format <xref target="RFC9264"/>, listing the API endpoints in an array of bookmarks. The intent is that by following a bookmark link, a machine-client can discover the purpose and usage of each API, hence the document targeted by the bookmark link must support this.</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://example.com/,
    "api-bookmarks": [{
        "href": https://developer.example.com/apis/foo_api
    }, {
        "href": https://developer.example.com/apis/bar_api
    }, {
        "href": https://developer.example.com/apis/cantona_api
    }
    ]
}]
}
]]>
</sourcecode>
            </figure>       
        </section>      
        <section anchor="Acknowledgements" numbered="false">
            <!-- an Acknowledgements section is optional -->
            <name>Acknowledgements</name>
            <t>TODO</t>
        </section>
    </section>
    </back>
</rfc>