REST API and Common HTTP Methods
REST APIs are everywhere — from web apps to mobile apps and microservices.
If you’re learning backend or frontend development, understanding REST APIs and HTTP methods is essential.
In this guide, we’ll use real, publicly accessible APIs so you can try requests live — some using dog data 🐶!
Real APIs Used in This Article
- Dog API (No key) – Real dog breeds and images
https://dog.ceo/api
- ReqRes API (Mock API) – For POST, PUT, PATCH, DELETE examples
https://reqres.in/api
Both APIs return JSON and require no authentication.
Key Principles of REST
A RESTful API usually follows these principles:
- Stateless – Each request is independent
- Client–Server separation – Frontend and backend are independent
- Uniform interface – Uses standard HTTP methods
- Resource‑based – Everything is treated as a resource
Common HTTP Methods in REST APIs
HTTP methods define what action you want to perform on a resource.
1. GET – Read Data (Dog API)
Used to fetch data from the server.
Example: Get a random dog image
GET https://dog.ceo/api/breeds/image/random
✔ Retrieves a random dog image
✔ Does not modify server data
Example: List all dog breeds
GET https://dog.ceo/api/breeds/list/all
✔ Returns a JSON object with all dog breeds
2. POST – Create a Resource (ReqRes API)
Used to create something new.
Example: Create a user
POST https://reqres.in/api/users
Request Body:
{
"name": "Dog Lover",
"role": "Trainer"
}
✔ Creates a new user
✔ Returns a user object with an ID
3. PUT – Update Entire Resource (ReqRes API)
Used to replace an existing resource completely.
Example:
PUT https://reqres.in/api/users/2
Request Body:
{
"name": "Dog Expert",
"role": "Veterinarian"
}
✔ Replaces all fields of the resource
4. PATCH – Update Partial Resource (ReqRes API)
Used to update specific fields of a resource.
Example:
PATCH https://reqres.in/api/users/2
Request Body:
{
"role": "Dog Therapist"
}
✔ Updates only the role field
✔ More efficient than PUT
5. DELETE – Remove Resource (ReqRes API)
Used to delete a resource.
Example:
DELETE https://reqres.in/api/users/2
✔ Deletes the user with ID 2
✔ Returns a 204 No Content status
Common HTTP Status Codes
Status codes tell the client what happened:
- 200 OK – Request successful
- 201 Created – New resource created
- 204 No Content – Delete successful
- 400 Bad Request – Invalid input
- 401 Unauthorized – Authentication needed
- 404 Not Found – Resource not found
- 500 Internal Server Error – Server problem
Why REST APIs Are So Popular
- Easy to understand and implement
- Language and platform independent
- Uses lightweight JSON format
- Scales well for large systems
- Supported by all modern frameworks
Final Thoughts
REST APIs power real‑world applications — even fun ones like dog image apps 🐶!
Using real endpoints like the Dog API lets you experiment with GET requests directly, while mock APIs like ReqRes help you practice full CRUD methods.
Try these endpoints in your browser, Postman, or code — and you’ll learn REST the right way 🚀
Happy coding!