Introduction

What is Resgate?

Resgate is an open-source Realtime API Gateway.

It is a simple server that lets you create REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.

Book Collection Animation
Video capture from the Book Collection Example. Try out the Live demo version yourself.

How does it work?

Resgate handles all API requests from your clients, instead of directly exposing your micro-services (represented by NodeJS and Go1 below). Clients will connect to Resgate, using either HTTP or WebSocket, to make requests. These requests are sent to the micro-services over NATS server, and Resgate will keep track on which resource each client has requested.

Whenever there is a change to the data, the responsible micro-service sends an event. Resgate will use this event to both update its own cache, and make sure each subscribing client is kept up-to-date.

RES Network Diagram
A basic setup with Resgate, NATS server, and two micro-services.

How do I use it?

You install and run the executable, together with NATS server, which is a simple and highly performant messaging system. Then you write a service that listens for requests, much like how you would write a service for a REST API.

As soon as you start the service, it will become available through Resgate by means of ordinary HTTP requests. Or if you connect to Resgate via WebSockets, using ResClient, the data you fetch from the service will be kept updated in real-time.

When to use it?

It is suitable for new REST APIs, especially where you otherwise might end up streaming events on a separate WebSocket or SSE connection. With Resgate, you get both a REST API and a real time API for a similar development effort compared to writing a standard REST API. And it solves all the tricky parts of synchronization for you, while giving you back features such as caching.

It is suitable when creating single page applications, using reactive frameworks such as React, Vue.js, or Modapp.

It is also a suitable alternative to Google Firebase’s real time database, especially when you would rather prefer to have most logic on the server, and you don’t want to store your data at Google.

What are the benefits?

Reactive user interfaces

Resgate helps making your web applications reactive. When someone makes an update to the data, this change will show on all clients without users having to reload the app, as expected of modern applications.

Reliability

Resgate will ensure that the data doesn’t grow stale or out of sync. If a connection is lost, a server is restarted, or a backend update is deployed, the clients will be able to resume without disruption.

Security

Your services are never exposed directly. Resgate prevents any access to a resource or method unless explicitly granted. The protocol allows for any type of authentication, and access may revoked at any moment.

Lower server load

Resgate’s cache takes load off the services. If thousands of clients wants to get a specific resource, Resgate only has to request it once.

Lower network traffic

Resgate keeps track of what data each client is subscribing to at the moment, sending only the necessary information to keep the state updated. The client will automatically tell Resgate when a specific resource is no longer in use.

Less code

Writing a service for Resgate produces a similar amount of code as with a REST API, or less when considering that separate event streaming is not required. Accessing the data on the client often requires less code, as no specific resource or event handling is needed.

Live queries

Resgate fully supports queries, filtered searches, and paginations, keeping the dynamic results updated in real time.


Where do I continue?

Live demo

Try the live demo and see what it is like using a RES API in action.

Try out examples

If you prefer to learn by looking at code examples, you should start by installing Resgate.
Once done, you can try out some of the examples for the language of your choice.

Understanding the protocol

If you are more into understanding how services are written, and how the protocol works, you should continue on with the Writing Services guide: Chapter 1 - Hello World

Enjoy using Resgate!


  1. The Go gopher was created by Takuya Ueda and designed by Renee French↩︎