← Back to context

Comment by calvinmorrison

3 days ago

REST means, generally, HTTP requests with json as a result.

It also means they made some effort to use appropriate http verbs instead of GET/POST for everything, and they made an effort to organize their urls into patterns like `/things/:id/child/:child_id`.

It was probably an organic response to the complexity of SOAP/WSDL at the time, so people harping on how it's not HATEOAS kinda miss the historical context; people didn't want another WSDL.

  • > It also means they made some effort to use appropriate http verbs instead of GET/POST for everything, and they made an effort to organize their urls into patterns like `/things/:id`.

    No not really. A lot of people don't understand REST to be anything other than JSON over HTTP. Sometimes, the HTTP verbs thing is done as part of CRUD but actually CRUD doesn't necessarily have to do with the HTTP verbs at all and there can just be different endpoints for each operation. It's a whole mess.

  • >> /things/:id/child/:child_id

    It seems that nesting isn't super common in my experience. Maybe two levels if completely composite but they tend to be fairly flat.

    • Generally only /companies/:companyId/buildings

      And then you get a list of all buildings for this company.

      Every building has a url like: /buildings/:buildingId

      So you constantly get back to the root.

      Only exception is generally a tenant id which goes upfront for all requests for security/scoping purposes.

      1 reply →

    • I see both.

      E.g. GitHub /repos/:owner/:repo/pulls/comments/:comment_id

      But flat is better than nested, esp if globally unique IDs are used already (and they often are).

      2 replies →

  • > instead of GET/POST for everything

    Sometimes that's a pragmatic choice too. I've worked with HTTP clients that only supported GET and POST. It's been a while but not that long ago.

    • Not even just clients, but servers too would block anything not GET/POST/HEAD. And I believe PHP still to this day only has $_GET and $_POST as out of the box superglobals to conveniently get data params. I recall some "REST" APIs would let you use POST for PUT/DELETE requests if you added a special var or header specifying.