API HTTP Methods

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.

POST

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.

PUT

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.

PATCH

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.

GET

Use when retrieving a collection of resources or a singular resource. Resources can include records from the database or assets such as images.

DELETE

This method is pretty explanatory. You would use this method when you want to delete a resource.

About the Author

Posted by

Categories:

API

Add a Response

Your name, email address, and comment are required. We will not publish your email.

The following HTML tags can be used in the comment field: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>