REST API
Beginner
1 min read
What is REST?
Example
# REST Constraints illustrated:
# 1. Uniform Interface — resources identified by URL
# GET /articles -> collection
# GET /articles/42 -> single resource
# POST /articles -> create
# PUT /articles/42 -> full replace
# PATCH /articles/42 -> partial update
# DELETE /articles/42 -> delete
# 2. Stateless — server holds no client session state
# Every request must contain all auth info:
# Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...
# 3. Cacheable — use HTTP cache headers
# Cache-Control: max-age=3600
# ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
# 4. Client-Server — frontend and backend are decoupled
# The same API can serve a web app, mobile app, and IoT device
# 5. Layered — client can't tell if it talks to origin or proxy
# Reverse proxies, CDNs, load balancers are transparent
# Example resource representation (JSON):
# {
# "id": 42,
# "title": "Understanding REST",
# "author": { "id": 7, "name": "Alice" },
# "tags": ["api", "rest"],
# "createdAt": "2024-03-01T12:00:00Z",
# "_links": {
# "self": "/articles/42",
# "author": "/users/7"
# }
# }
Related Resources
REST API Reference
Complete tag & property list
REST API How-To Guides
Step-by-step practical guides
REST API Exercises
Practice what you've learned
More in REST API