0% found this document useful (0 votes)
4 views1 page

It Topic Rest API

REST (Representational State Transfer) is an architectural style for designing networked applications using stateless, client-server communication over HTTP. Key principles include statelessness, resource-based URLs, standard HTTP methods, and a uniform interface. Best practices involve using plural nouns for resources, versioning APIs, supporting pagination, and returning meaningful error messages in JSON format.

Uploaded by

Huy Nguyễn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

It Topic Rest API

REST (Representational State Transfer) is an architectural style for designing networked applications using stateless, client-server communication over HTTP. Key principles include statelessness, resource-based URLs, standard HTTP methods, and a uniform interface. Best practices involve using plural nouns for resources, versioning APIs, supporting pagination, and returning meaningful error messages in JSON format.

Uploaded by

Huy Nguyễn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

REST API Design Principles

What is REST?
REST (Representational State Transfer) is an architectural style for designing networked applic
It relies on stateless, client-server communication over HTTP.

Core Principles:
- Stateless: Each request contains all information needed to process it
- Resource-based: URLs represent resources, not actions
- HTTP Methods: Use standard methods (GET, POST, PUT, DELETE, PATCH)
- Uniform Interface: Consistent URL patterns and response formats

HTTP Methods:
GET /users # List all users
GET /users/123 # Get specific user
POST /users # Create new user
PUT /users/123 # Replace user entirely
PATCH /users/123 # Update user partially
DELETE /users/123 # Delete user

Status Codes:
200 OK - Successful request
201 Created - Resource created successfully
400 Bad Request - Invalid request from client
401 Unauthorized - Authentication required
404 Not Found - Resource does not exist
500 Internal Error - Server-side error

Best Practices:
- Use plural nouns for resource names (/users, not /user)
- Version your API (/v1/users)
- Support pagination for list endpoints
- Return meaningful error messages with proper status codes
- Use JSON as the default response format

You might also like