Wednesday, April 28, 2021

REST-API, JSON:API, GraphQL API whats the difference

 Hi All, 


After long time again writing some thing related to technical. So recently i saw there is a confusion which api specification to use. between REST, GraphQL, JSON API. 

So to first get a context list list down what all 3 api styles define and 


1) REST (Representational State Transfer) API. 

As this is the most popular api approach in current environment. 

REST was designed to provide interoperability between web resources by defining a uniform set of stateless operations. it uses http  verbs to act upon resources Get, Post, Put, Patch, Delete. 

Using stateless protocols and standard operations is meant to provide fast performance, reliable interactions, and extensibility through standardization.

As each request only responds with that which you asked for. This makes for a highly efficient, fast, and powerful approach.  But the same thing goes as a drawback of rest. When you need some group operation it leads to multiple round trips. and many times over fetching of data on client side which is not required. 


2) JSON:API

JSON:API sets a standard for communication; it expresses how requests to the server should be formatted, and then what the response to the client should be formatted as. Its goal is to optimize HTTP requests by reducing the number of requests needed as well as reducing the size of data packages exchanged between clients and servers.

To let know the server that api is containing data payload header used is 

Content-Type: application/vnd.api+json


A JSON object is at the root of requests, which must include either resource data, error, or meta information. Data, and also relationships to data can be fetched through GET calls like such

A typical JSON API request

GET /articles HTTP/1.1

Accept: application/vnd.api+json


// ...

{

  "type": "articles",

  "id": "1",

  "attributes": {

    "title": "My First Article"

  },

  "relationships": {

    "author": {

      "links": {

        "self": "/articles/1/relationships/author",

        "related": "/articles/1/author"

      },

      "data": { "type": "people", "id": "1" }

    }

  }

}

// ...


Advantages of using JSON API

Caching

Optimization Features (Sorting , pagination)

Compound Documents : Enables to add additional documents in the response.

GET https://api.example.com/posts?include=comments

 Sparse Field sets  :  Enable clients to only request data from specific fields.

GET /articles?include=author&;fields[articles]=title,body&;fields[people]=name 

HTTP/1.1

Accept: application/vnd.api+json

Optionality : Provides facility to turn on/off the features which are not required 


3) GraphQL

GraphQL is an application query language, It is primarily designed to create a predefined, understandable, and stable format for requests.

allowing the client to specifically state the structure of data and the data itself that should be returned from the server.

 GraphQL gives information as to related resources, allowing you to traverse from the first returned data to more related data content, forming a graph of related data and meta-relationships.


The provision of related resources also means that you can make more advanced queries and get all of that data in one fell swoop, whereas in other solutions like REST, you’d need to be make hugely complicated multi-endpoint series of calls to get everything you can in a single GraphQL request.


As sample GraphQL Request Body

{

    author {

        name,

        age

   }

}


this will return only author object with properties of name and age, other fields will not be send by server.




Saturday, January 9, 2021

M2 Plugin Option Chain filters with graphs and Positions

 Hi All, 


Now i have came with many small but required changes which were needed for intraday options trading. 

I have tried to explain them in below mentioned YouTube video. 



Added components are.


1) Graphs for Option OI.

2) Auto Refresh of Option chain

3) Display of Selected Strike ranges. 

4) Intraday  History view of Option OI.

5) OI Spurt for Given Option Chain. 

6) Strike Specific OI Built-up details. 

7) OI Change view for given strike at both Call & Put side. 

8) Position Updates

9) Gann Square


hope this will give you a trading edge in your intraday trading. 

you should go through video once and it will help you in understanding the details behind and how to use those features. 


Any many new features will come in 2021. so be ready for this.