2.0.0 • Published 5 months ago

bloom-engine v2.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Bloom Client

Bloom Client is an npm package designed to interact with the Bloom Engine API. It simplifies the process of sending inputs and retrieving outputs by providing a user-friendly interface.

Features

  • Set inputs and outputs for API calls
  • Add inputs and outputs individually
  • Calculate results by calling the API
  • Retrieve outputs one by one

Installation

Install the package using npm:

npm install bloom-client

Usage

Here is an example of how to use the Bloom Client:

Import and Initialize

const BloomEngine = require('bloom-client');

const apiKey = 'your-api-key';
const apiVersion = 'v3.0';

const bloomEngine = new BloomEngine(apiKey, apiVersion);

How to Create an API Key

  1. Visit bloom-engine.cloud.
  2. Upload an Excel Spreadsheet.
  3. Get your own API key.

Set Inputs and Outputs

You can set all inputs and outputs at once:

bloomEngine.inputs({
    "Sheet1!B2": 10,
    "Sheet1!B3": 300000,
})
.outputs([
    "Sheet2!B5",
    "Sheet2!B6",
]);

Or add them individually:

bloomEngine
    .addInput("Sheet1!B12", "Manitoba")
    .addInput("Sheet1!B4", 0.1)
    .addOutput("Sheet2!B7")
    .addOutput("Sheet2!B8");

Calculate Results

Call the calculate method to interact with the API:

(async () => {
    try {
        const results = await bloomEngine.calculate();

        // Retrieve outputs by key
        console.log(results.get("Sheet2!B5"));
        console.log(results.get("Sheet2!B6"));
    } catch (error) {
        console.error('Error:', error);
    }
})();

API Reference

Constructor

new BloomEngine(apiKey, apiVersion)
  • apiVersion: The version of the API to use (e.g., 'v3.0').
  • apiKey: Your client key.

Methods

inputs(inputs)

  • Description: Sets multiple inputs at once.
  • Parameters:
    • inputs (Object): Key-value pairs of inputs.
  • Returns: The instance for chaining.

outputs(outputs)

  • Description: Sets multiple outputs at once.
  • Parameters:
    • outputs (Array): List of output keys.
  • Returns: The instance for chaining.

addInput(key, value)

  • Description: Adds a single input.
  • Parameters:
    • key (string): The input key.
    • value (any): The input value.
  • Returns: The instance for chaining.

addOutput(output)

  • Description: Adds a single output.
  • Parameters:
    • output (string): The output key.
  • Returns: The instance for chaining.

calculate()

  • Description: Calls the API and retrieves the results.
  • Returns: A Map containing the output key-value pairs.

Error Handling

If the API call fails, the calculate method throws an error. Use try...catch to handle exceptions gracefully.

License

This project is licensed under the MIT License.


For more information, feel free to reach out to the development team or consult the official documentation.

2.0.0

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago