Provides an interface for (Web) applications that need to connect to each other via the Internet to communicate
Should contain resources and the method should define the action to be performed on a resource
// Endpoints, collection without action
/employees
/companies
/cars
// Methods/action to get the complete list per endpoint
GET /employees
GET /companies
GET /cars
// Methods to access one instance of a resource
// Shows the detail of employee number 20
GET /employees/20
// Deletes car number 100
DELETE /cars/100
// Deletes employee 3 from company 5
DELETE /companies/5/employees/3
// Requests using keys and values
/companies?search=Competa
/cars?order=desc&sort=brand
// Format request (not recommended!)
/companies?format=xml
/employees?format=json
// Format request to download (better!)
/companies.xml
/employees.json
// See next slide for requests with HTTP headers (recommended!)
Accept: application/json
Accept: application/xml
// 1xx: Informational
101: Switching to a newer protocol if there is an advantage.
// 2xx: Success
200 OK:
Standard response for successful HTTP requests.
201 Created:
Successful creation occurred (via either POST or PUT).
204 No Content:
The server successfully processed the request, but is not returning any content.
// 3xx: Redirection
301 Moved Permanently:
This and all future requests should be directed to the given URI.
// 4xx: Client error
400 Bad Request:
The request cannot be fulfilled due to bad syntax
401 Unauthorized:
Error code response for missing or invalid authentication token
403 Forbidden:
Error code for user not authorized to perform the operation or the resource is unavailable for some reason
404 Not Found:
Used when the requested resource is not found
// 5xx: Server error
501 Internal Server Error:
The general catch-all error when the server-side throws an exception.
502 Bad Gateway:
The server was acting as a gateway or proxy and received an invalid response from the upstream server.