A new way to reduce JSON API output without all the hassles of graphql | Restmap

Saksham Khurana
Devs Life
Published in
2 min readMar 12, 2022

To create a simple way to query only the required data from a Rest API without relying on a lot of external tools or code.

Photo by Ferenc Almasi on Unsplash

What’s all the fuss about?

The problem is, Frontend devs have to constantly deal with lots of data in each API request & they have no way of limiting this response according to their needs. So consider they only need 1 key, they still have to get all the keys in the response.

The earliest solution and still a very good solution is using, GraphQl which is a query language for your API (read more here).

So have you created a GraphQl alternative?

NO !!!

In no way is Restmap a replacement for GraphQl which is a very extensive query language that does a lot of things.

Restmap solely aims to limit your data without lots of development time on fronend/backend. All you need is just few lines of code on server side

  • Graphql requires you to configure/change a lot of your frontend & backend.
  • For Graphql in frontend especially you need a new way to consume data by configuring a new library other than the existing REST API which put additional strain on frontend devs.

Restmap simply plugs & play in your existing system !!!

Sounds Good? Well let me introduce you to Restmap

  • Restmap simply works in the existing API by making a slight tweak on the server-side
  • Just import the library and call the reduceData method on the final output of your API
  • Clients can send restmap string via header, query, or body (however you wish to have it on the server-side)

Do you want examples?

You can also test out more on our Playground

Thanks for checking out this article, hope it helps you :)

--

--