Makes one authenticated REST call to the BDP API and prints a compact result summary.
- Node.js 18.0.0 or later
- API token (See Setup Credentials )
- Network: Outbound HTTPS (443) to
ecostruxure-building-platform-api-uat.se.app
cd examples/rest-quickstart-nodejsnpm installChoose one method.
Option A: .env file
-
Copy
.env.templateto.env. -
Set your token:
BDP_API_TOKEN=eyJ...
Option B: environment variable
# bash
export BDP_API_TOKEN="eyJ..."or
# powershell
$env:BDP_API_TOKEN = "eyJ..."If both are set, the environment variable wins.
node call_rest_api.js --resource sites --take 5The script supports three resources:
sites(default)organizationsbuildings(requires--site-id)
Examples:
node call_rest_api.js --raw
node call_rest_api.js --resource organizations
node call_rest_api.js --resource buildings --site-id YOUR_SITE_GUID --take 10- Exit code
0when the API answers with a valid JSON body. - A one-line call summary showing method, URL and HTTP status.
- A compact list of returned entities by
idandname.
Expected output sample:
GET https://ecostruxure-building-platform-api-uat.se.app/api/Sites?take=5
status: 200
items: 5
- 8f6...c9d | Example Site
- 9ab...72e | North Campus
If you strip everything down, the REST call is just:
- Build a URL
- Add headers (
Authorization,X-Api-Version) - Send a
GETrequest
This is the smallest possible version of the call logic:
import https from 'https';
import { URL } from 'url';
const url = new URL('https://ecostruxure-building-platform-api-uat.se.app/api/Sites?take=5');
const options = {
hostname: url.hostname,
path: url.pathname + url.search,
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'X-Api-Version': '3.0',
'Accept': 'application/json',
},
timeout: 30000,
};
https.request(options, (res) => {
let data = '';
res.on('data', chunk => { data += chunk; });
res.on('end', () => {
const body = JSON.parse(data);
});
}).end();That is the core network call in call_rest_api.js, without token loading,
argument parsing, or response summarization.
Every REST call uses the same bearer token model as GraphQL:
Authorization: Bearer ******
Tokens are short-lived by design. Re-copy a fresh token when needed.
Every REST operation declares this header. This script sends 3.0 by default.
- Use
--api-version 3.0(default) 2.0is also accepted- Unsupported values return
400 Unsupported API Version was requested
Table - Responses and what they mean
| Response | Meaning |
|---|---|
| 401 | Token expired or malformed |
| 403 with a JSON body | Token valid, but your consumer is not authorized for that data |
| 403 returning an HTML error page | Refused in front of the API, request did not reach the API |
| 400 Unsupported API Version | X-Api-Version is not 2.0 or 3.0 |
| 200 with an empty result | Subscription rule is missing, or filters out everything |
See Troubleshooting for the 403 distinction.