3 ms·
> authorization Hmm. Is authorization maybe very app specific? Did you mean authentication?: Basic Authentication and API keys and HTTPS seems popular. E.g. S
by KajMagnus 8y ago
> authorization
Hmm. Is authorization maybe very app specific? Did you mean authentication?:
Basic Authentication and API keys and HTTPS seems popular. E.g. Stripe: https://stripe.com/docs/connect/authentication#api-keys https://stripe.com/docs/connect/authentication#api-keys, and Chargebee (they deal with tons of money).
I like this article: https://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api https://www.vinaysahni.com/best-practices-for-a-pragmatic-re... — except that I use only POST and GET, never PUT, DELETE etc. And name the endpoints like:
POST /-/create-page controllers.PageController.createPage
POST /-/pin-page controllers.PageController.pinPage
POST /-/unpin-page controllers.PageController.unpinPage
POST /-/reply controllers.ReplyController.handleReply
GET /-/load-draft-and-guidelines controllers.EditController.loadDraftAndGuidelines
GET /-/load-draft-and-text controllers.EditController.loadDraftAndText
POST /-/edit controllers.EditController.edit
then one knows what and endpoint does, by just looking at the URL path. Won't also need to ask: "But which method?"
Also, most people that actually design APIs, seem to put the API version in the URL, like `/api/v1/...`.
- wkoszek 8y agoI'm wondering whether what you showed here is REST. I maybe meets some indempotent guidelines, but it should be something more standard like: ``` /pages/ POST create a page /pages/{id} PUT update a page /pages/{id} GET get a page ``` as looking at some standard JS code, if you stick to this theme, you will some functionality for free, like getting an array of items after GET is done for you etc.
- KajMagnus 8y agoHmm yes right now I'm not sure if it's strictly REST or not :- ) I keep forgetting exactly what REST means. The web app is happy and the ones who use it too, even if ... maybe not strictly REST. :- )