CS6 - APIDesign Continued
CS6 - APIDesign Continued
Akshaya Ganesan
Assistant Professor[Off-Campus]
BITS-Pilani
Precap
• Content negotiation is the process of selecting the best representation of a resource for a client
when there are multiple representations (or variants) available
• HTTP specifies two types of content negotiation.
• These are server-driven negotiation and agent-driven negotiation.
• Server-driven negotiation uses request headers to select a variant.
• Agent-driven negotiation uses a distinct URI for each variant.
Content Negotiation
Server Driven
• # Request headers
• Accept: application/atom+xml;q=1.0, application/xml;q=0.6, */*;q=0.0
• Accept-Language: fr;q=1.0, en;q=0.5
• Accept-Encoding: gzip
Content Negotiation
Agent Driven
• One of the first steps in developing a RESTful web service is designing the resource model.
• There is no right or wrong resource model.
• https://learn.microsoft.com/nl-nl/azure/architecture/best-practices/api-design
References
1) Restful Web services, Leonard Richardson and Sam Ruby, 1 st edition published by O'Reilly
Media,
2) REST API Design Rulebook by Mark Massé
Thank You!
In our next session: