YouTip LogoYouTip

Restful Api Res

# RESTful API Request and Response Format ## JSON Format Modern RESTful APIs mainly use JSON (JavaScript Object Notation) format to transmit data. JSON is like a "universal language" for data, simple and easy to read. ### JSON Basic Syntax ```json { "name": "Zhang San", "age": 25, "email": "zhangsan@example.com", "hobbies": ["Reading", "Swimming", "Programming"], "address": { "city": "Beijing", "district": "Chaoyang District" }, "isActive": true } ### Request Format **GET Request Example:** ```http // Request GET /api/users/123 Accept: application/json // Response { "id": 123, "name": "Zhang San", "email": "zhangsan@example.com", "createdAt": "2024-01-15T08:30:00Z" } **POST Request Example:** ```http // Request POST /api/users Content-Type: application/json { "name": "Li Si", "email": "lisi@example.com", "password": "securePassword123" } // Response { "id": 124, "name": "Li Si", "email": "lisi@example.com", "createdAt": "2024-01-15T09:00:00Z", "message": "User created successfully" } * * * ## Response Structure Design ### Unified Response Format ```json { "success": true, "data": { "id": 123, "name": "Zhang San" }, "message": "Operation successful", "timestamp": "2024-01-15T08:30:00Z" } ### Error Response Format ```json { "success": false, "error": { "code": "VALIDATION_ERROR", "message":
← Restful Api PracticesRestful Api Http Method β†’