6

I am thinking about how to implement a REST API endpoint for searching. As I see it, I have four options for how to implement search options, each with pros and cons:

  1. Use a GET endpoint with querystring params
  2. Use a GET endpoint with a payload (for example, a JSON payload)
  3. Use a POST endpoint with a payload
  4. Use a SEARCH endpoint with a payload

For completeness, here are the pros and cons I am thinking of:

  • GET endpoint with querystring params
    • Pro - Accurate verb, standards compliant
    • Con - Limited option structure (key/values only), and URL size limit
  • GET endpoint with a payload (for example, a JSON payload)
    • Pro - Accurate verb, no size limit
    • Con - HTTP specs say GET requests do not have meaningful payloads, and some frameworks may not support it (relevant question)
  • POST endpoint with a payload
    • Pro - Standards compliant, no size limit
    • Con - Searching is idempotent, while POSTing is not. Basically, it's the wrong verb.
  • SEARCH endpoint with a payload
    • Pro - Accurate verb, no size limit
    • Con - Is an obscure (non-standard?) HTTP verb

A lengthy, nuanced, and opinionated discussion could be had as to which of these is best, but that discussion is not the purpose of this question. Instead I ask: Is the SEARCH verb merely obscure and rarely used but still an official method, or is it non-standard?

I found this draft for the method, but not many more official documents about it. The draft echoed some of the points of the quadrilemma I posed above. It appears to me that the method is still merely a draft and can't be called "standard", though I am not overly familiar with how to read those documents.

Functionally, I guess my question is: Can I rely on self-touted standards compliant software to handle the SEARCH method? And if they don't handle it, can I appeal to their claim of standards compliance to force them into handling it? Boiled down even further, is it a reliable verb?

tschwab
  • 986
  • 1
  • 10
  • 24

1 Answers1

2

SEARCH is defined on the IETF Standards Track in RFC 5323. That said, it currently is only applicable to WebDAV, and few servers support it.

Community
  • 1
  • 1
Julian Reschke
  • 37,619
  • 8
  • 86
  • 92
  • 1
    Gotcha. As a follow up, if it is defined in a "Standards Track", does this mean that it is essentially a draft? It is moving towards being a standard, but is not one yet? I am not familiar with what that term means. – tschwab Aug 05 '20 at 19:59
  • 1
    IETF terminology can be confusing. Let's just say that it has the same status as the HTTP specs. – Julian Reschke Aug 06 '20 at 04:23