API (or docs) not in conformity with RESTful

According Structured Data docs, new SDs are created with PUT and updates are made with POST:

safe_core calls PUT to store a new structured data on the SAFE Network and POST to update an existing structured data. When a structured data is created for the first time, the app should call the PUT endpoint and when updating an existing structured data, the app should call the POST endpoint.

Is this right? In a RESTful way, it should be the inverse (POST = create, PUT = update).

1 Like

Or maybe I’m just ignorant about it :smiley:

Just did some research and it seems that some people prefer to use PUT to create and POST to update. Rails, Laravel, Wordpress and many other frameworks enforce the PUT=update / POST=create idea. Maybe it’s a CRUD thing, so I thought the API was wrong.

2 Likes

Structured data will be replaced by Mutable data. Better read the RFC about it.

Other RFC you must read is:

and

2 Likes

My understanding of REST is

  • PUT /thing/:new_id to create
  • PUT /thing/:existing_id to update
  • POST /things to create
  • POST /thing/:existing_id to update
  • PATCH /thing/:id to update part of the resource

More info When to use PUT or POST and When to use the PATCH method. As far as I can tell, there’s no exact ‘standard’.

On the topic of the safe network API methods, as @digipl says there are changes coming to the way it works. I have also been frustrated by the inconsistency between PUT and POST as implement by safe but I’m confident it will be simplified before being set in stone :wink:

as @ben explains at the start of January regarding the API:

we is a very verbose and not clearly defined API and requires a lot of very similar terms in your head, which can make it very confusing. Which is why we are intending of replacing this with a much cleaner approach

4 Likes