> For the complete documentation index, see [llms.txt](https://notes.lirenxn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.lirenxn.com/2020/wk-notes-02-27-api-design-g-rpc-rest-etc.md).

# Wk-notes-02-27-API-design-(g)RPC-REST-etc

### API design: Servers communitaions

<https://nordicapis.com/when-to-use-what-rest-graphql-webhooks-grpc/>

**GraphQL** is an option to extend an API, and **gRPC** is a re-tooling to a classical approach,

#### REST <a href="#rest" id="rest"></a>

Stateless, Reliable, Scalable, **HATEOAS**, which means it's better/meant to be used with **hypermedia**(with hypertexts, namely links to other resources)

#### (g)RPC <a href="#grpc" id="grpc"></a>

> **gRPC** is actually a new take on an old approach known as **RPC**, or **Remote Procedure Call**.

**Custom contracted communications** based on **non-standard contract**, defined by client-server relationship, but largely defined by the resources themselves(server). It gives much power(responsibility) to client.

Popular in IoT for low-power devices.

**gRPC**

**Protobufs:**

> Protobufs are language and platform neutral systems used to serialize data, meaning that these communications can be efficiently serialized and communicated in an effective manner.

**Auth:**

> Strong authentication system that utilizes SSL/TLS through Google’s token-based system.

#### GraphQL <a href="#graphql" id="graphql"></a>

A reversal of the traditional relationship, where client defines the data and format they retrieve.

An awesome way to decouple client and server.

#### Webhooks <a href="#webhooks" id="webhooks"></a>

No client pull, it is a server push (callback) model.
