RESTful APIs

February 7, 2020
REST API

Notes on Designing APIs.

  1. Terms:
  1. URL Endpoints.

“The paths should contain the plural form of resources and the HTTP method should define the kind of action to be performed on the resource.”

  1. Methods:
  1. HTTP Response Codes.

Stats:

2xx Success. 200 Okay. 201 Created. 204 No content.

3xx Redirection. 304 Not Modified.

4xx Client Error. 400 Bad Request. 401 Unauthorized. 403 Forbidden. 404 Not Found. 410 Gone.

5xx Servor Error Category. 500 Internal Server Error. 503 Service Unavailable.

  1. Casing Convention.

camelCase because JSON is javaScript.

  1. Searching, sorting, filtering and pagination.

“We need to append the query params with the GET method API.”

See also this and that.

  1. Versioning

“When your APIs are being consumed by the world, upgrading the APIs with some breaking change would also lead to breaking the existing products or services using your APIs.”

http://api.yourservice.com/v1/companies/34/employees is a good example”