HomeAbout

REST

Pros and Cons

Pros

Specific data and resource.

Does not take long time to build one.

Cons

Does not scale well.

  • Causes tight coupling of frontend and backend.
  • Org-wise: Makes teams clash with each others requirements.

Need to create new endpoint to avoid over/under-fetching.

RESTFul Standard

Organizes data entities (resources) to unique URIs in the server

  • Making a request to the specific endpoint
    • Request is specific (HTTP verb)

URI stands for uniform resource identifiers

Rules to be Restful

Client-Server Architecture

  • Separation of Concerns
  • RESTful API should not care about the UI

Stateless

  • No client-context is store in the server

Cache-ability

  • Responses must define themselves as cacheable or non-cacheable (to the client)

Layered System

  • Intermediate servers may be used without the client knowing about it

Uniform Interface

  • Resources are identified in Requests, transferred data is decoupled from DB schema
  • Self-descriptive messages links to further resources

Anatomy of REST

Headers

  • Metadata about the request

Body

  • Payload of data

Server will execute the code from request and form a response.

  • Response come with a status code.

Response Header

  • Status about the server

Stateless

  • Two parties don't store info about each other
  • Every req-res is independent from all other cycles

Set of commands, functions, protocols, and objects that programmers can use to create software or interact with an external system

  • Provides developers standard commands for performing common operations so they do not have to write the code from scratch

Endpoint

Endpoint is a url to a specific api resource

# endpoint examples /this-is-an-endpoint /another/endpoint /some/other/endpoint /login /accounts /cart/items # full URL example https://example.com/this-is-an-endpoint https://example.com/another/endpoint https://example.com/some/other/endpoint https://example.com/login https://example.com/accounts https://example.com/cart/items

Trailing slash

Caches will store trailing stashes as separate items.

http://example/foo http://example/foo/

Most APIs do not end with a trailing slash.

Contrary to arguments, a collection should be named using a plural.

  • In this sense, trailing slash is unnecessary in any case.
AboutContact