News for hackers. Stuff that matters.
Re:How to (and how not to) design REST APIs by rswail on Thursday November 02, 2023 @01:56AM (#38109485)
If I use turning a lamp on and off, I'd do GET /lamp and in the response there should be an href with a rel of "on" that I can follow (in JSON land).

In HTML, I might have a FORM that does a POST of the lamp's switch to /lamp/switch.

Because the switch is the resource that you're trying to manipulate when turning a lamp on/off, not the lamp itself.

Re:How to (and how not to) design REST APIs by 3cats-in-a-coat on Thursday November 02, 2023 @08:10AM (#38112385)
POST /lamp/switch is not any better than POST /lamp as neither communicates what you're doing.