Comment by naasking

3 days ago

HATEOAS adds lots of practical value if you care about discoverability and longevity.

Discoverability by whom, exactly? Like if it's for developer humans, then good docs are better. If it's for robots, then _maybe_ there's some value... But in reality, it's not for robots.

HATEOAS solves a problem that doesn't exist in practice. Can you imagine an API provider being like, "hey, we can go ahead and change our interface...should be fine as long as our users are using proper clients that automatically discover endpoints and programmatically adapt accordingly"? Or can you imagine an API consumer going, "well, this HTTP request delivers the data we need, but let's make sure not to hit it directly -- instead, let's recursively traverse a graph of requests each time to make sure this is still the way to do it!"

  • You have got it wrong. Let's say I build some API with different user roles. Some users can delete an object, others can only read it. The UI knows about the semantics of the operations and logical names of it, so when UI gets the object from server it can simply check, if certain operations are available, instead of encoding the permission checking on the client side. This is the discoverability. It does not imply generated interfaces, UI may know something about the data in advance.

    • > You have got it wrong. Let's say I build some API with different user roles. Some users can delete an object, others can only read it. The UI knows about the semantics of the operations and logical names of it, so when UI gets the object from server it can simply check, if certain operations are available, instead of encoding the permission checking on the client side.

      Have you ever heard of HTTP's OPTIONS verb?

      https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/...

      Follow-up trick question: how come you never heard of it and still managed quite well to live without it?

      1 reply →

    • This is actually what we do at [DAYJOB] and it's been working well for over 12 years. Like any other kind of interface indirection it adds the overhead of indirection for the benefit of being able to change the producer's side of the implementation without having to change all of the consumers at the same time.

  • > If it's for robots, then _maybe_ there's some value...

    Nah, machine readable docs beat HATEOAS in basically any application.

    The person that created HATEOAS was really not designing an API protocol. It's a general use content delivery platform and not very useful for software development.

For most APIs that doesn’t deliver any value which can’t be gained from API docs, so it’s hard to justify. However, these days it could be very useful if you want an AI to be able to navigate your API. But MCP has the spotlight now.

  • And that's fine, but then you're doing RPC instead of REST and we should all be clear and honest about that.

    • I think you throw away a useful description of an API by lumping them all under RPC. If you tell me your API is RPC instead of REST then I'll assume that:

      * If the API is available over HTTP then the only verb used is POST.

      * The API is exposed on a single URL and the `method` is encoded in the body of the request.

      3 replies →

LLMs also appear to have an easier time consuming it (not surprisingly.)