> For the complete documentation index, see [llms.txt](https://docs.energyweb.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.energyweb.org/energy-solutions/digital-spine-by-energy-web/component-guides/ddhub-client-gateway/technical-guide/integration-options.md).

# Integration Options

## Overview

Client Gateway offers a user interface for managing topics and channels, as well as for sending and receiving data; however, these functions can also be performed using REST APIs. Additionally, two-way interactive communication between senders and receivers can also be achieved using the WebSocket APIs.

***

## User Guide

### Pre-requisites

* Authorization to Client Gateway

### HTTP API

Navigate to Client Gateway Swagger to see the available REST API collection

<figure><img src="https://4257445316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fnf3YeoQlQerc93GsC2Me%2Fuploads%2Fpw3A6z35N1jbNwhlHLdc%2FScreenshot%202025-05-09%20at%2011.05.13%E2%80%AFAM.png?alt=media&amp;token=5840f66c-88c2-4544-be3a-b5da2601f623" alt=""><figcaption><p>Integration APIs</p></figcaption></figure>

<figure><img src="https://4257445316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fnf3YeoQlQerc93GsC2Me%2Fuploads%2Ft14VsHFpF3ZTKr2S0ODq%2Fimage.png?alt=media&amp;token=8ae1c026-64c5-4b1e-93d3-6d6f8ae6c140" alt=""><figcaption><p>Client Gateway Swagger</p></figcaption></figure>

#### Sending Requests and Consuming Data (example)

{% hint style="info" %}
This example uses `axios` library to demonstrate requests.
{% endhint %}

```typescript
import axios from 'axios';

axios.get('https://{the-client-gw-api-here}/api/v2/identity', {
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': '{the-api-key-here}'
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error('Error fetching data:', error);
});
```

### WebSocket API

Unlike REST APIs, which require separate requests for each interaction, WebSockets allow continuous, two-way communication — ideal for real-time messaging. Navigate to Web Socket API for DDHub Gateway Web Socket API 1.0.0

<figure><img src="https://4257445316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fnf3YeoQlQerc93GsC2Me%2Fuploads%2FlyD71onvCagQbUgR1JCQ%2FScreenshot%202025-05-09%20at%2011.06.00%E2%80%AFAM.png?alt=media&amp;token=7810ba61-cdba-4cf4-a762-c42357306415" alt=""><figcaption><p>Integration APIs</p></figcaption></figure>

<figure><img src="https://4257445316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fnf3YeoQlQerc93GsC2Me%2Fuploads%2FaHYhw1EJo7ZqpBR0tDa0%2Fimage.png?alt=media&amp;token=fd261ef7-2f4a-43b0-9490-11a1b8f93569" alt=""><figcaption><p>WebSocket API documentation</p></figcaption></figure>

#### Connecting

Please ensure to use `Sec-WebSocket-Protocol` : `ddhub-protocol` in the header

```javascript
// Connect websocket
const socket = new WebSocket('wss:{ddhub-wss-url}', ['ddhub-protocol']);

socket.onopen = () => {
  console.log('Connected with subprotocol:', socket.protocol);
};
```

#### Sending a WS Message (example)

```javascript
// send message
socket.send(JSON.stringify({
  "fqcn": "test.pub.chnl",
  "topicName": "test_topic",
  "topicVersion": "1.0.1",
  "topicOwner": "ddhub.test",
  "transactionId": "45d5a89f-7c2c-48b0-ae9a-54f4128e818",
  "payload": "{ data: 70 }"
}));
```

#### Consuming a WS Message

```javascript
// set up a listener for incoming messages
socket.onmessage = function (event) {
  const data = JSON.parse(event.data);
  console.log('Received:', data);
};
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.energyweb.org/energy-solutions/digital-spine-by-energy-web/component-guides/ddhub-client-gateway/technical-guide/integration-options.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
