Joshua T Kalis (he/him/his)
I build great teams and excellent software.
REST Is Easy!
Resource Modeling
And by "REST is Easy!" I really mean "resource modeling is easy". Which becomes completely immaterial once hypermedia is fully embraced.
Warning, opinions ahead.
Rules
- Everything is a Resource.
- Resources are either: Entities and Entity Collections.
- Entities are the business concepts the API attempts to solve for.
- Collections contain many Entities.
- Don't leak your data relationships in your API.
- There is an exception to every rule (also a rule for life).
REST Resource Patterns
- Root Resource (
/
) - Enterprise Entities and Sub-entities (
/books/{ISBN}
) - Entity Collections (
/books
) - Calculation (
/calculators/LTV
) - Ephemeral (
/searches/{SearchId}
)
Anti-pattern
Avoid
GET|PUT /resource/{ID}/subResource/{subResourceID}/subSubResource/{SSRID}
Better
GET|PUT /resource/{ID}
GET|PUT /subResource/{subResourceID}
GET|PUT /subSubResource/{SSRID}