Skip to content

Latest commit

 

History

History
91 lines (59 loc) · 2.84 KB

README.org

File metadata and controls

91 lines (59 loc) · 2.84 KB

My notes for different Web APIs

Different Web APIs

There are many different HTTP APIs, REST is one of them.

REST (REpresentational State Transfer)

REST is not only CRUD, but things are done through mainly CRUD-based operations. REST will use HTTP methods such as GET, POST, PUT, DELETE, OPTIONS and, hopefully, PATCH to provide semantic meaning for the intention of the action being taken. I can also do file uploads.

The The six constraints:

  • Uniform Interface
  • Stateless
  • Cacheable
  • Client-Server
  • Layered System
  • Code on Demand (optional)

HATEOAS (Hypermedia As The Engine Of Application State) is a component of the REST application architecture. REST is using hypermedia control.

SOAP (Simple Object Access Protocol)

XML-RPC (XML Remote Procedure Call)

RPC, compared to REST however, would not do CRUD. Most use only GET and POST, with GET being used to fetch information and POST being used for everything else. It is common to see RPC APIs using something like POST /deleteFoo, with a body of { “id”: 1 }, instead of the REST approach, which would be DELETE /foos/1.

JSON-RPC (JSON Remote Procedure Call)

AMQP (Advanced Message Queuing Protocal)

GraphQL & Falcor

GraphQL

GraphQL is incorrectly considered by some to be a “replacement” to REST

  • REST and GraphQL are totally different
  • GraphQL isn’t a magic bullet, nor is it “better”
  • You can definitely use both at the same time
  • GraphQL is dope if used for the right thing

REST is an architectural conpect, where GraphQL is query language.

GraphQL Pros:

  • Very powerful and flexible
  • Static types and introspection — GraphiQL FTW
  • Many implementations in other languages, growing community

GraphQL Cons:

  • Steeper learning curve
  • No batteries included. Fair amount of assembling required
  • Relay (Javascript GraphQL client) has a steep learning curve

Falcor

  • GraphQL has a schema and static types, Falcor does not have that. There is currently no easy way (that I know of) to tell what type of data your Falcor will return to you.

Falcor Pros:

  • Really straight forward, easy to learn
  • Things like caching and query-merging included

Falcor Cons:

  • Not as powerful as GraphQL (no arguments)
  • No built-in model/schema introspection
  • No implementations other than JavaScript, and little visible traction

References