Zesty.io is thrilled to announce that we have implemented PATCH API endpoints across links, content items, headtags, redirects, fields and envsettings. This update represents a major step forward in our continuous effort to improve the flexibility, efficiency, and overall experience for our developer users. It aligns with our commitment to providing tools that streamline the content management process, making updates simpler and safer.
Why PATCH API?
Until now, Zesty.io has utilized the PUT method for updating data. While effective, the PUT method updates an entire entity, requiring all key-value pairs to be included in the payload. The introduction of PATCH API offers a more nuanced approach, allowing for the update of single fields within an entity without altering others.
Adhering to Industry Best Practices: PATCH API Use Cases in Zesty.io
Inspired by feedback and the evolving needs of our community, Zesty.io recognized the demand for a more efficient way to make partial updates to data. Companies like HubSpot, Autodesk, and Reddit use PATCH in ways that align with our vision for simplicity and efficiency, guiding our approach to implementing PATCH API in our system. By learning from industry standards yet avoiding unnecessary complexities, Zesty.io ensures our platform remains user-friendly and agile.
Some key benefits of PATCH API implementation in Zesty.io:
1) Minimized Overhead for Data Updates:
The introduction of PATCH API in Zesty.io significantly reduces the overhead associated with updating content entities. Unlike the PUT method, which requires clients to send a complete set of an entity's attributes, PATCH allows for the submission of only those attributes that need to be updated.
2) Precision and Error Reduction:
The implementation of PATCH API significantly lowers the risk of unintended data modifications, such as the nullification of fields or the complete loss of an entity. This precision in updating specific fields without affecting others ensures data integrity and stability across our platform.
3) An Optimized Content Update Cycle:
With PATCH API, Zesty.io enables a more agile content management process. Marketers and content managers can swiftly modify content to respond to market trends or correct errors, significantly accelerating the content update cycle.
4) A Better Developer Experience:
The design and functionality of PATCH API are meticulously crafted to align with developers' expectations around HTTP methods. Recognizing the importance of developer workflows, Zesty.io has ensured that the PATCH API integrates into existing processes, facilitating a straightforward update mechanism.
Technical Insights and Implementation
Our approach to implementing PATCH API is mindful of our ecosystem's complexity and our users' diverse needs. We've designed the API to be intuitive and compatible with our existing system, to ensure a smooth transition for all users. We're utilizing Map Interface for JSON payload parsing, simplifying the process for developers by requiring only the necessary keys for updates.
Design
Implementing PATCH to our endpoints does not break any existing endpoints we have. It only adds a couple of underlying handlers and methods to logically process the new requests.
PATCH API has a payload that’s basically the same with our PUT http verb. The only difference from PUT is that, with PATCH, developers will not be required to know all the properties an entity has and doesn’t have to add all the required fields an entity requires. Endpoints are also the same as what our PUT currently has as well as the Content-type.
Example:
const sdk = require("@zesty-io/sdk");
(async function main() {
const zesty = new sdk(ZESTY_INSTANCE_ZUID, ZESTY_INSTANCE_TOKEN);
try {
const res = await zesty.instance.patchItem(MODEL_ZUID, ITEM_ZUID, {
web: {
"pathPart": "new-path", // Change this to your item fields
},
});
} catch (err) {
console.trace(err);
}
})();
For more information and detailed examples of how PATCH works on content items, please refer to our Documentation.
Functionality (Technical)
We considered the scope of the design implementation by determining the layers that will be affected and updated.
server.go: This is where all the endpoints. So this is where we will add the new PATCH API endpoints for each entity.
handlers: This is where the initial handling of every endpoints like parsing any queries and params.
services: This is where everything is processed based on what service and what http verb is used. Most of the time, this is also where the DB querying happens.
Through this, we didn’t need any additional third-party packages – avoiding the risk of having to maintain and update external packages that could potentially affect our existing codebase.
Why use reflections?
Since we are using Map Interface, it is more flexible and more accurate to use reflection in order to check the data integrity of the keys and values provided on the payload.
All of the new PATCH endpoints are still utilizing the existing Update function when updating the database. Some also retain the same logic for validating the fields.
Endpoints
We also need to determine whether a service would require a PATCH http verb or not. Here are a draft list of the endpoints that will require PATCH: (list might get updated)
instances-api
content/links
content/models/fields
content/models/items
web/redirects
web/stylesheets/variables
web/scripts
web/headtags
env/settings
env/nav
releases
releases/members
A couple of endpoints doesn’t need adding PATCH but might need in the future. There are:
content/models
web/views
web/stylesheets
env/langs
Ensuring Quality and Reliability
Zesty.io's testing framework and dedication to quality assurance means that every aspect of the PATCH API has been rigorously evaluated. Our automated tests, complemented by manual testing scenarios, ensure that this new feature integrates smoothly with our platform, maintaining the reliability you've come to expect from Zesty.io.
Limits and Testing
Our system is equipped with automated testing provided by Go Language. Every additional feature has its corresponding test that should coincide with the existing test process. Therefore, we carefully add new test methods for every possible request a developer might have. You can distinguish a test file by its filename. They have a ‘_test’ suffix which is mandatory in Go.
Manual testing can be done using Postman. You can refer to the following API References:
instances-api: Instances API (zesty.org)
accounts-api: Accounts API (zesty.org)
Get Started with PATCH API
For a more detailed dive into the specifics of APIs in Zesty.io, including examples, please refer to our Documentation.
Read Zesty.io API Documentation
As always, our team is here to support you in integrating these new capabilities into your workflows. Please don’t hesitate to reach out.
Book a personalized demo here.
Learn more about Zesty.io for Developers with the video below:
Learn more about Zesty.io features for Developer teams here.
Looking Ahead: Continued Improvement
Incorporating PATCH API into Zesty.io reflects our commitment to adopting best practices and providing advanced tools that meet the demands of modern web development. By offering a method to update content that is both efficient and error-resistant, we hope to empower our users to manage digital content with improved control and flexibility.
We're excited about the possibilities PATCH API opens up for our users and look forward to supporting your success with more innovative features in the future.