|
| 1 | +# API Methods |
| 2 | + |
| 3 | +| Method | Summary | CRUD | Accepts Request Body | Idempotent | Safe | Response Body | |
| 4 | +|---------|----------------------------------------------------------|--------|-----------------------|------------|------|---------------| |
| 5 | +| GET | To fetch a single resource or group of resources | Read | No | Yes | Yes | Yes | |
| 6 | +| PUT | To update an entire resource in one go | Update | Yes | Yes | No | Yes | |
| 7 | +| POST | To create a new resource | Create | Yes | No | No | Yes | |
| 8 | +| PATCH | To partially update a resource | Update | Yes | No | No | Yes | |
| 9 | +| DELETE | To delete a resource | Delete | No | Yes | No | No | |
| 10 | +| OPTIONS | To get information on permitted operations | Read | No | Yes | Yes | Yes | |
| 11 | +| HEAD | To get metadata of the endpoint | Read | No | Yes | Yes | No | |
| 12 | +| TRACE | For diagnosing purposes | Read | No | Yes | Yes | No | |
| 13 | +| CONNECT | To make the two-way connection between the client and the resource | - | No | No | No | No | |
| 14 | + |
| 15 | +## Method Details: |
| 16 | + |
| 17 | +- **GET**: |
| 18 | + - The GET method is used to retrieve data from a specified resource. It does not typically alter the state of the resource and is safe and idempotent. It can accept query parameters in the URL to filter or sort the results. A response body is returned with the requested data. |
| 19 | + |
| 20 | +- **POST**: |
| 21 | + - The POST method is used to submit data to be processed to a specified resource. It is commonly used for creating new resources, and it may or may not require a request body containing the data to be created. It is not idempotent nor safe. A response body is returned with the newly created resource's details. |
| 22 | + |
| 23 | +- **PUT**: |
| 24 | + - The PUT method is used to update a specified resource with new data. It typically requires a request body containing the complete representation of the resource to be updated. It is idempotent and not safe. A response body is returned with the updated resource's details. |
| 25 | + |
| 26 | +- **PATCH**: |
| 27 | + - The PATCH method is used to apply partial modifications to a resource. It typically requires a request body containing the specific changes to be made. It is not idempotent nor safe. A response body is returned with the updated resource's details. |
| 28 | + |
| 29 | +- **DELETE**: |
| 30 | + - The DELETE method is used to delete a specified resource. It does not typically require a request body, as the resource to be deleted is identified in the request URI. It is idempotent but not safe. No response body is returned. |
| 31 | + |
| 32 | +- **OPTIONS**: |
| 33 | + - The OPTIONS method is used to describe the communication options for the target resource. It does not typically require a request body and is safe and idempotent. A response body is returned with information about the supported HTTP methods and other metadata. |
| 34 | + |
| 35 | +- **HEAD**: |
| 36 | + - The HEAD method is similar to the GET method, but it only retrieves the headers of the response without the body. It does not typically require a request body and is safe and idempotent. |
| 37 | + |
| 38 | +- **TRACE**: |
| 39 | + - The TRACE method is used to test the connectivity between the client and the server. It does not typically require a request body and is safe and idempotent. |
| 40 | + |
| 41 | +- **CONNECT**: |
| 42 | + - The CONNECT method is used to establish a tunnel to the server using a proxy. It does not typically require a request body and is neither safe nor idempotent. |
| 43 | + |
| 44 | +### Definitions: |
| 45 | + |
| 46 | +- **CRUD**: |
| 47 | + - CRUD stands for Create, Read, Update, and Delete, representing the four basic functions of persistent storage. These operations are commonly used in database and RESTful API designs. |
| 48 | + |
| 49 | +- **Accepts Request Body**: |
| 50 | + - Indicates whether the HTTP method typically accepts a request body containing data to be processed or modified. If yes, the method may require the client to include data in the request body. |
| 51 | + |
| 52 | +- **Idempotent**: |
| 53 | + - An idempotent operation means that making the same request multiple times will produce the same result as making it once. In the context of HTTP methods, an idempotent method does not change the server state after multiple identical requests. |
| 54 | + |
| 55 | +- **Safe**: |
| 56 | + - A safe operation does not modify the state of the server or its resources. It only retrieves data without causing any side effects. Safe methods are typically used for read-only operations. |
0 commit comments