-
Notifications
You must be signed in to change notification settings - Fork 0
API Comparisons
Nikolina Djekic edited this page Feb 9, 2025
·
1 revision
| Feature | GET Method | POST Method |
|---|---|---|
| Purpose | Retrieve data from a specified resource. | Submit data to be processed to a specified resource. |
| Data Location | Appended to the URL as query parameters. | Included in the body of the request. |
| Visibility | Visible in the URL. | Not visible in the URL. |
| Cacheable | Yes, responses can be cached. | No, responses are not typically cached. |
| Idempotent | Yes, multiple identical requests have the same effect. | No, multiple identical requests may have different effects. |
| Safe | Yes, does not modify resources. | No, modifies resources. |
| Data Length | Limited by the URL length. | Not limited by the URL length. |
| Use Cases | Fetching data, search queries, retrieving resources. | Submitting forms, uploading files, creating resources. |
| Has Body | No | Yes |
| Parameters | URL (query parameters) | Body (form data, JSON, etc.) |
| Feature | PUT Method | PATCH Method |
|---|---|---|
| Purpose | Update a current resource with new data. | Apply partial modifications to a resource. |
| Data Location | Included in the body of the request. | Included in the body of the request. |
| Idempotent | Yes, multiple identical requests have the same effect. | No, multiple identical requests may have different effects. |
| Safe | No, modifies resources. | No, modifies resources. |
| Data Length | Not limited by the URL length. | Not limited by the URL length. |
| Use Cases | Replacing an entire resource. | Updating specific fields of a resource. |
| Has Body | Yes | Yes |
| Parameters | Body (form data, JSON, etc.) | Body (form data, JSON, etc.) |
| Feature | Headers | Query Parameters | Path Variables |
|---|---|---|---|
| Purpose | Provide additional information about the request or response. | Pass additional information to the server in the URL. | Identify specific resources in the URL path. |
| Location | Included in the request or response headers. | Appended to the URL after a question mark (?). |
Included in the URL path, enclosed in curly braces ({}). |
| Visibility | Not visible in the URL. | Visible in the URL. | Visible in the URL. |
| Usage | Used for authentication, content type, caching, etc. | Used for filtering, sorting, and pagination. | Used for identifying specific resources. |
| Data Length | Not limited by the URL length. | Limited by the URL length. | Limited by the URL length. |
| Example | Authorization: Bearer your_token |
GET /users?name=JohnDoe&age=30 |
GET /users/{userId} |
| Postman Display | Added in the Headers tab. | Added in the Params tab. | Displayed with a colon (:) in front of them. |
Written by Ninna94