REST
REST (Representational State Transfer)
200 Ok HTTP status in response.304 Not Modified HTTP status in response.We only need 2 base URLs per resource
/cars)/cars/1244)4 operations (CRUD)
/cars: create a new car/cars/1244: create a new car with id 1244 or fail/cars: list cars/cars/1244: show car 1244/cars : replace cars/cars/1244: if exists update car 1244, if not, create car 1244 or fail/cars : delete all cars/cars/1244: delete car 1244Avoid verbs to name your resources. Use plural nouns.
Use verbs only if the functionality provided by the call is an operation and not a resource, such as:
Be consistent
Use concrete resource names instead of abstract ones. e.g., /cars, /cats
accept: application/headerFew examples how respose format:
?alt=json\venue.jsonAccept: application/json or ?type=json?offset=10&limit=50limit=10&offset=0Few examples of pagination:
?offset=10&limit=50?offset=10&limit=50?start=10&count=50200 201 304 400 401 403 404 500{
"code": 23213,
"message": "MESSAGE",
"info": "https://SOME_DOMAIN/docs/error/CODE"
}
Examples by different orgs:
{
"type": "OAuthExeption",
"message": "----"
}
Twillo
{
"status": 401,
"message" "",
"code": 20003,
"more_info": "http://twillo.com/docs/erros/20003"
}
Assosiations used to represent relationships between entities
POST `/owners/1234/cars`
GET `/owners/1234/cars/1244`
? in the query string
GET /cars?color=red&location=newyork/v1/carsExamples by different orgs:
/2010-04-01/Accounts/services/data/v20.0/subjects/account/?v=1.0/v1/v2/v1/cars?fields=name,color,regitryLocation.postalCodeExamples by different orgs:
/people:(id,first-name,last-name,industry)/joe.smith/friends?fields=id,name,picture?fields=title,media:group(media:thumbnail)/search?q=short+hair/cars?q=red+color/search?q=red-color&scope=cars,ownersapi.domain.comdevelopers.domain.comExamples by different orgs:
api.foursquare.comdevelopers.foursquare.comapi.twitter.comsearch.twitter.comstream.twitter.comdev.twitter.comgraph.facebook.comapi.facebook.comdevelopers.facebook.comExamples by different orgs: