# SPADE Node - JS Client

A client-side JavaScript library that can be used to interact with Data Broker's API.

## Installation

Install the package via npm:

```
npm i @bavenir/spade-node-js-client
```

Link to project https://www.npmjs.com/package/@bavenir/spade-node-js-client


## Usage

Import the DataBroker class and create an instance with your configuration:

```
import { DataBroker } from '@bavenir/data-broker-client';

const config = {
  url: 'example.com',
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret'
};

const dataBroker = new DataBroker(config);
```

## API

### Healthcheck

Retrieve the health status of the Data Broker:

```
dataBroker.healthcheck().then((status) => {
  console.log(status);
});
```

### Items

Run a discovery on the Data Broker and return a list of items:

```
dataBroker.discovery('$').then((items) => {
  console.log(items);
});
```

### Consumption

Retrieve the value read from a property of an Item:

```
dataBroker.consumption('item-oid', 'property-pid').then((value) => {
  console.log(value);
});
```

## Who do I talk to?

Developed by bAvenir:
* Matej Kokol - [matej.kokol@bavenir.eu](mailto:matej.kokol@bavenir.eu)
* Jorge Almela - [jorge.almela@bavenir.eu](mailto:jorge.almela@bavenir.eu)
* Peter Drahovsky - [peter.drahovsky@bavenir.eu](mailto:peter.drahovsky@bavenir.eu)

## License

Copyright (C) 2024 bAvenir

This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0

