RESTful API Design Fundamentals
Resource URI Representat ions HTTP Verbs Resources
Resource Any object associated with data, identified with URI, and can be operated by using HTTP methods
Collection(customers) Singleton(customer) /articles /articles/{articleI d}
Sub-collections /articles/{articleId}/comments /articles/{articleId}/comments/{commentId} (Sub-collection resource)
Http Verbs Article Create Article Update Article Delete
GET -> show POST -> create PUT -> update DELETE -> delete
Representation XML JSON
Resource URI Unique Resource Identifier
Choosing Resource Analyze your business domain Define your needs Consumer needs important
Fine Grained Resource Multiple API request (title, content, slug, etc...)
Coarse Grained Resource All the details at once. Send Article data to API
Business logic on consumer side First create article content Attach category (mandatory) If user does not add category, then what?
…. On every update on API side will reflect to consumer side
Action A depends on; Resource A Resource B Resource C
Then Action A can be defined as; Resource X
Versioning Url shouldn’t contain version http://yourdomain.com/api/v3.0/articles/123 (Bad)
… instead Version in the header GET /articles/123 Accept: application/vnd.huseyinbabal.blogging.article-v3+ json
Even worse http://yourdomain.com/api/v3.0/articles/v2.5/co mments/v1.7/likes
RESTful API Design Fundamentals

RESTful API Design Fundamentals