mayank ahuja
REST APIs Common
Misconceptions
Swipe for more
mayank ahuja
REST Requires HTTP
Truth -
1. REST is an architectural style independent of any
protocol.
2. HTTP is a common implementation choice because
it aligns well with REST principles.
3. REST can be implemented over any protocol that
supports its constraints.
REST = Architectural Style
HTTP = Popular Implementation Protocol
mayank ahuja
REST APIs Must Be JSON/XML
Truth -
1. REST is protocol and format agnostic.
2. Content negotiation determines the format.
3. Server and client agree on representation format.
Accept: application/json
Accept: application/xml
Accept: application/[Link]+json
mayank ahuja
REST = CRUD
Truth -
1. REST focuses on resource state transfer.
2. Resources can be more than data entities.
3. Operations can extend beyond CRUD.
4. Resources represent business concepts.
mayank ahuja
Statelessness Means No State
Truth -
1. Application state can exist.
2. Server can maintain resource state.
3. Each request must contain all needed information.
4. No client session state on server.
What Must Be Stateless:
Request context
Authentication context
Client session
mayank ahuja
PUT vs POST Confusion
Truth -
1. PUT is idempotent (multiple identical requests =
same result).
2. POST is not idempotent.
3. PUT is for complete resource updates.
4. POST is for creation and actions.
PUT /articles/123 -> Replace entire resource
POST /articles -> Create new resource
PATCH /articles/123 -> Partial update
mayank ahuja
Version in URL Violates REST
Truth -
1. Versioning is implementation detail.
2. Multiple valid approaches exist.
3. URL versioning is acceptable.
4. Content negotiation versioning is acceptable.
Valid Versioning Approaches -
/v1/resources
Accept: application/[Link]+json;version=1
If you
find this
helpful, please
like and share
it with your
friends