# HTTP Gateway

A first-class RESTful interface for NATS. The HTTP Gateway is a stateless component which can be added to any NATS system managed by Control Plane

## Getting started

* Before deploying your own HTTP Gateway you may want to familiarize yourself with API Token management and the API usage in [Synadia Cloud](/cloud/http-gateway.md). The HTTP Gateway is supported in the free tier subscription.

* You can find more usage examples in the preview announcement at [HTTP Gateway preview announcement](https://www.synadia.com/blog/synadia-cloud-http-gateway-preview).

* If the HTTP Gateway fits your requirements jump to the [deployment instructions](/platform/1.14/http-gateway/gateway_deployment.md).

## Supported NATS functionality

**As of June 2024 the following are supported:**

* Key/Value Store

  * Management
  * Access

* Object Store

  * Management
  * Store Access

* NATS Core

  * Publish and Subscribe (experimental)
  * Request/Reply (experimental)
    * Including access to NATS micro services

## API example

```
curl -H "Authorization: Bearer <API_TOKEN>" \

    https://<your gateway>:<port>/v1/kvm/buckets
```

* Each gateway serves its full API documentation at `/api/`, for example `https://<your gateway>:<port>/api/`.

* Check here for [features and architecture](/platform/1.14/http-gateway/gateway_architecture.md).

## Why would you use the HTTP Gateway?

For those who are familiar with NATS' [native WebSocket support](https://docs.nats.io/running-a-nats-service/configuration/websocket/websocket_conf) and [client library](https://github.com/nats-io/nats.ws), you may be thinking why is HTTP Gateway necessary?

An important distinction between NATS and HTTP, is that HTTP is inherently designed to have stateless interactions between the client and server. For example, a request against an API that returns a JSON representation of a resource. The connection only needs to exist for the duration of that exchange. There are certainly optimizations to amortize the setup cost of the connection such as keep-alive and pipelining many requests for assets, but the *model* is a once-and-done exchange.

NATS, on the other hand, was designed for long-lived connections enabling high-throughput and low-latency M:N exchange of messages and data and **the choice** of synchronous or asynchronous interactions. Supporting WebSockets as a transport enabled running a NATS client in the browser, but it still assumes a long-lived connection.

The two predominant motivations driving the development of this component were:

* enabling access to NATS data services (key-value and object store) and invocation of NATS microservices on the backend via an HTTP API
* acknowledging there are constrained environments where *only* an HTTP client is available and there is no ability to install a NATS client

The outcome we wanted was a first-class HTTP interface to NATS without needing to explicitly learn NATS or use a NATS client.

However, being powered by NATS within Synadia Cloud means data and services can be transparently accessible across all major geos, the three major cloud providers, and out to an edge **you define** without any additional infrastructure or integrations.

## More information

[ArchitectureDependencies and Architecture of HTTP Gateway](/platform/1.14/http-gateway/gateway_architecture.md)[Deployment and ConfigurationDeployment of Synadia HTTP Gateway.](/platform/1.14/http-gateway/gateway_deployment.md)[Issuing API TokensIssuing API Tokens in Control Plane](https://docs.synadia.com/cloud/http-gateway)[Usage ExamplesUsage examples for HTTP Gateway.](https://www.synadia.com/blog/synadia-cloud-http-gateway-preview)
