Comments (5)
So the correct implementation of an api should be:
POST > full json payloads (adds an item to the list).. (!not updating data!)
PUT > full json payload, updates items (!not adding new data!)
PATCH > partial json payload, updates items (!not adding new data!)
DELETE > deletes an item from the api
more info here:
https://jsonplaceholder.typicode.com/
from wlanthermo_esp32_software.
Thanks for your idea. But, what should the benefit be? The settings are not edited constantly and the traffic is already very low. In addition, POST is universal.
from wlanthermo_esp32_software.
"what should the benefit be?"
When you build an api, your building for the future benefits. Other developers that are going to consume your api and work with your data. You can't know whats needed in the future or not, so thats why there are standard definitions for building api's.
For example, I'm now looking into integrating this api into Domoticz, and I found that to set the pitmaster mode, the documentation tells me to upload the full json object, but I dont want to retrieve the latest json, just to update one value (pitmaster mode).
Also if you have the standard protocols in place, i would never look at POST for updating values.. I would always use PUT or PATCH to update full or partial. Developers are always quick, and always take too few time in reading documentation. So building stuff that's standard eases the use and speed of development.
I'm actually most of the times on the consumer side of an api, and I know that using correct api principles are going to be a benefit for the long run.
from wlanthermo_esp32_software.
Im not complaining btw, its just a though of me on how to improve on the api setup
from wlanthermo_esp32_software.
"Im not complaining btw, its just a though of me on how to improve on the api setup"
Don't worry, I just wanted to know the background.
"For example, I'm now looking into integrating this api into Domoticz, and I found that to set the pitmaster mode, the documentation tells me to upload the full json object, but I dont want to retrieve the latest json, just to update one value (pitmaster mode)."
There's a point behind it: it is not intended that single pitmaster values are changed. The Pitmaster is a unit and is only changed in one piece. PATCH would not be available here anyway, only PUT (instead of POST, with same JSON body).
Similar to the channel settings: a channel setting is always transferred at least with the channel number. This would leave only PUT with the transfer of a complete embedded channel object in order to remain in the API standard.
With SYSTEM or IOT parameters, PATCH would be possible.
"and I know that using correct api principles are going to be a benefit for the long run."
I basically agree with you, so thanks very much for the hint. Adding PUT/PATCH next to POST as request method wouldn't be the problem, but it would not change the current internal processing of requests. They are provided as specified in the documentation. This would also be the case with PUT/PATCH.
from wlanthermo_esp32_software.
Related Issues (20)
- Temp Max als Kerntemperatur kennzeichnen
- Bluetooth deactivate HOT 1
- Schreibfehler im Menupunkt System HOT 2
- Selection of a different WLAN in Menu WLAN HOT 2
- Schreibfehler HOT 1
- Use password field for MQTT password HOT 1
- possibility to connect to hidden wifi HOT 1
- Broken handling of cloud graph when switching between Celsius/Fahrenheit during ongoing measurement HOT 1
- Telegram Chat ID disappears after saving in Push Notifications when ID value is a negative number HOT 1
- /data API should have a settings independent temperature value HOT 1
- Pitmaster `set` temperature does not get updated when switching system unit between C/F
- [Documentation] Compiling Instructions HOT 1
- Set retain flag on MQTT #/status/settings message?
- Revision of mqtt settings in API
- Suggestion: Enable own (local) Cloud Service HOT 1
- Suggestion: Eigene Notizen Seite im Mini Menรผ
- Bug SSID scan list
- Integration Presets
- Benachrichtungsdienst Pushover kein User Device setzbar
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wlanthermo_esp32_software.