NAV Navigation
Shell HTTP JavaScript Node.js Ruby Python Java Go PHP

Community Battery v1.0.0

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

A simple representation of a typical community battery.

Base URLs:

License: MIT

Authentication

Default

get__measure

Code samples

# You can also use wget
curl -X GET https://cbat:8080/measure \
  -H 'Accept: application/json'

GET https://cbat:8080/measure HTTP/1.1
Host: cbat:8080
Accept: application/json


const headers = {
  'Accept':'application/json'
};

fetch('https://cbat:8080/measure',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json'
};

fetch('https://cbat:8080/measure',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

require 'rest-client'
require 'json'

headers = {
  'Accept' => 'application/json'
}

result = RestClient.get 'https://cbat:8080/measure',
  params: {
  }, headers: headers

p JSON.parse(result)

import requests
headers = {
  'Accept': 'application/json'
}

r = requests.get('https://cbat:8080/measure', headers = headers)

print(r.json())

URL obj = new URL("https://cbat:8080/measure");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());

package main

import (
       "bytes"
       "net/http"
)

func main() {

    headers := map[string][]string{
        "Accept": []string{"application/json"},
    }

    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("GET", "https://cbat:8080/measure", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}

 'application/json',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
    $response = $client->request('GET','https://cbat:8080/measure', array(
        'headers' => $headers,
        'json' => $request_body,
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }

 // ...

GET /measure

Get operation for interface 'Measurements'

Provides measurements.

Example responses

200 Response

{
  "active_power": 1.3,
  "reactive_power": 0.1
}

Responses

Status Meaning Description Schema
200 OK Provides measurements. CommunityBattery

post__config

Code samples

# You can also use wget
curl -X POST https://cbat:8080/config \
  -H 'Content-Type: application/json'

POST https://cbat:8080/config HTTP/1.1
Host: cbat:8080
Content-Type: application/json

const inputBody = '{
  "active_power": 1.3,
  "reactive_power": 0.1
}';
const headers = {
  'Content-Type':'application/json'
};

fetch('https://cbat:8080/config',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

const fetch = require('node-fetch');
const inputBody = {
  "active_power": 1.3,
  "reactive_power": 0.1
};
const headers = {
  'Content-Type':'application/json'
};

fetch('https://cbat:8080/config',
{
  method: 'POST',
  body: JSON.stringify(inputBody),
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

require 'rest-client'
require 'json'

headers = {
  'Content-Type' => 'application/json'
}

result = RestClient.post 'https://cbat:8080/config',
  params: {
  }, headers: headers

p JSON.parse(result)

import requests
headers = {
  'Content-Type': 'application/json'
}

r = requests.post('https://cbat:8080/config', headers = headers)

print(r.json())

URL obj = new URL("https://cbat:8080/config");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());

package main

import (
       "bytes"
       "net/http"
)

func main() {

    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
    }

    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("POST", "https://cbat:8080/config", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}

 'application/json',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
    $response = $client->request('POST','https://cbat:8080/config', array(
        'headers' => $headers,
        'json' => $request_body,
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }

 // ...

POST /config

POST operation for interface 'Configure'

Sets the battery setpoints.

Body parameter

{
  "active_power": 1.3,
  "reactive_power": 0.1
}

Parameters

Name In Type Required Description
body body CommunityBattery true Sets the battery setpoints.

Responses

Status Meaning Description Schema

Schemas

CommunityBattery

{
  "active_power": 1.3,
  "reactive_power": 0.1
}

Properties

Name Type Required Restrictions Description
active_power number(double) true none Active power
reactive_power number(double) true none Reactive power