REST stands for Representational State Transfer — it’s an architectural style used to design networked applications.
It defines a set of principles for how clients and servers should communicate over HTTP.
1. Client–Server architecture
The client (e.g., web app, mobile app) and server (API) are separate.
2. Statelessness
Each request contains all information needed — the server doesn’t remember previous requests.
3. Uniform Interface
Standard HTTP methods:
GET - Read data
POST - Create data
PUT / PATCH - Update data
DELETE - Delete data
4. Resource-based
Everything is treated as a resource, accessed via a URL (endpoint).
Example:
/api/employees → Get all employees
/api/employees/5 → Get employee with ID 5
5. Use of standard HTTP response codes
200 OK, 201 Created, 400 Bad Request, 404 Not Found, etc.
Example REST API in .NET Core
public class MaterialService : IMaterialService
{
[ApiController]
[Route("api/[controller]")]
public class EmployeesController : ControllerBase
{
[HttpGet]
public IActionResult GetAll()
{
return Ok(new[] { "John", "Jane" });
}
[HttpGet("{id}")]
public IActionResult GetById(int id)
{
return Ok($"Employee {id}");
}
[HttpPost]
public IActionResult Create([FromBody] string name)
{
return Created("", $"Employee {name} created");
}
}
}