When building an API there are 5 main HTTP verbs/methods that you will run into, these include the usual GET, POST and DELETE but there are 2 you may not have heard of… PUT and PATCH. This post briefly describes each of these along with simple use-cases for utilisation in a RESTful API.
If you do not know the URL of the resource you are creating. For example, creating a new article where the URLs are generated from an auto-incrementing integer.
Unlike POST, PUT can be used for both creating and updating resources. But it can only be used when you know the full url of the resource. Some use cases include uploading a file to a specified URL, or updating an entire resources content.
This method is used for partial updating resources. The body of a PATCH request only contains fields where the content has been updated, this means that the request is smaller making the API more responsive.
Use when retrieving a collection of resources or a singular resource. Resources can include records from the database or assets such as images.
This method is pretty explanatory. You would use this method when you want to delete a resource.