0%

REST API Best Practice

Terminology

  • Rest: Representational State Transfer
  • API: Application Programming Interface

RESTful API Main Criteria:

  • Client-server

    A client-server architecture made up of clients, servers, and resources, with requests managed through HTTP.

  • Stateless

    Stateless client-server communication, meaning no client information is stored between get requests and each request is separate and unconnected.

  • Cache

    Cacheable data that streamlines client-server interactions.

  • Uniform Interface

    A uniform interface between components so that information is transferred in a standard form.

    This requires that:

    • resources requested are identifiable and separate from the representations sent to the client.
    • resources can be manipulated by the client via the representation they receive because the representation contains enough information to do so.
    • self-descriptive messages returned to the client have enough information to describe how the client should process it.
    • hypertext/hypermedia is available, meaning that after accessing a resource the client should be able to use hyperlinks to find all other currently available actions they can take.
  • Layered System

    A layered system that organizes each type of server (those responsible for security, load-balancing, etc.) involved the retrieval of requested information into hierarchies, invisible to the client.

  • Code-on-demand (optional)

    The ability to send executable code from the server to the client when requested, extending client functionality.

Ref