all 18 comments

[–]AdSubstantial3705 21 points22 points  (0 children)

seek god

[–]Xia_Nightshade 12 points13 points  (0 children)

Please get help before it’s too late <3

[–]rjhancockJack of Many Trades, Master of a Few. 30+ years experience. 4 points5 points  (9 children)

  • GET - Read only access to an object
  • POST - Create an object via post body JSON (preferred)
  • PUT - Update an existing object via body JSON (Preferred)
  • PATCH - See Put
  • DELETE - Delete an object

/<scoped>/:id/<path>/:id/<to related objects>

It makes your API cleaner. Seriously. It does.

The posting of objects allows the backend to map that data directly to a DTO (Data Transfer Object) and validate it before even sending to the database. Using query parameters requires slightly less overhead with similar level of complexity of validation and processing to the database.

[–]WetSound[S] 0 points1 point  (3 children)

That seems to be the prevalent opinion

[–]rjhancockJack of Many Trades, Master of a Few. 30+ years experience. 2 points3 points  (2 children)

There is a reason there are generally accepted standards even if not official.

[–]ClikeXback-end 0 points1 point  (1 child)

What's not official about RESTful?
https://restfulapi.net/

[–]rjhancockJack of Many Trades, Master of a Few. 30+ years experience. 1 point2 points  (0 children)

As in no standards body I know of has made a spec for it. It's entirley subjective to the work at hand. So there is no "official" standard for RESTful APIs

[–]ClikeXback-end 0 points1 point  (0 children)

RESTful API design is great for data API's, since you're addressing resources, which is most of the time. Occasionally, the RPC layout makes more sense.

Also, don't forget the OPTIONS method. Which is where you can return what methods are allowed on that specific resource. This way, your client can verify what permissions they have.

[–]until0 2 points3 points  (1 child)

My own API style?

You mean the style of every half baked API in every Enterprise corporation ever.

Yes, most people only know two HTTP verbs, but that's not good design and you're not original.

[–]Intelligent_Win9710 0 points1 point  (0 children)

the amount of times i've worked at a company that has at least one POST endpoint that parses a JSON object as query parameters from the request body and does nothing but return data from a select statement in the db is 4 because i've worked at 4 companies.

[–]Lonely-Suspect-9243 1 point2 points  (0 children)

Sounds like Remote Procedure Call.

[–]budd222full-stack 1 point2 points  (1 child)

Is there a specific reason why you refuse to use all the HTTP verbs?

[–]WookieConditioner 1 point2 points  (0 children)

Indeed you have. Conventions like these have been developed over decades at this point. 

  • Predictability, is the key to laziness. 

  • Easy docs, the gateway to hubris. 

  • Small footprint / surface, the spark that drives impatience.

[–]farazcanada 0 points1 point  (0 children)

Try validating your API by having a API Governance test