🚀 RESTful API Interactive Tutorial

Interactive demonstration of REST API concepts and HTTP methods

📚 REST API Concepts

What is REST?

REST (Representational State Transfer) is an architectural style for designing networked applications. It uses standard HTTP methods and is stateless, meaning each request contains all information needed to process it.

HTTP Methods

GET: Retrieve data
POST: Create new data
PUT: Update existing data
DELETE: Remove data

Status Codes

200: Success
201: Created
404: Not Found
500: Server Error

🛠️ Interactive API Demo

Try out different HTTP methods with our mock API. This simulates real API behavior!

GET /api/users - Get all users
GET /api/users/{id} - Get user by ID
POST /api/users - Create new user
PUT /api/users/{id} - Update user
DELETE /api/users/{id} - Delete user

💻 Code Examples

JavaScript Fetch API:

// GET request fetch('/api/users') .then(response => response.json()) .then(data => console.log(data)); // POST request fetch('/api/users', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: 'John', email: 'john@example.com' }) }) .then(response => response.json()) .then(data => console.log(data));

cURL Examples:

# GET all users curl -X GET https://api.example.com/users # POST new user curl -X POST https://api.example.com/users \ -H "Content-Type: application/json" \ -d '{"name":"John","email":"john@example.com"}' # PUT update user curl -X PUT https://api.example.com/users/1 \ -H "Content-Type: application/json" \ -d '{"name":"John Updated"}' # DELETE user curl -X DELETE https://api.example.com/users/1
📱 API Response Monitor
👆 Click any "Try" button above to see API responses here! Ready to test REST API calls...