Makes one authenticated REST call to the BDP API and prints a compact result summary.
- Python 3.9 or later
- API token (See Setup Credentials )
- Network: Outbound HTTPS (443) to
ecostruxure-building-platform-api-uat.se.app
cd examples/rest-quickstart-pythonChoose 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.
python call_rest_api.py --resource sites --take 5The script supports three simple resources:
sitesorganizationsbuildings(requires--site-id)
Examples:
python call_rest_api.py --resource organizations
python call_rest_api.py --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 urllib.request
request = urllib.request.Request(
"https://ecostruxure-building-platform-api-uat.se.app/api/Sites?take=5",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"X-Api-Version": "3.0",
"Accept": "application/json",
},
method="GET",
)
with urllib.request.urlopen(request, timeout=30) as response:
body = response.read()If you want one step more, print status and decoded body:
import urllib.request
request = urllib.request.Request(
"https://ecostruxure-building-platform-api-uat.se.app/api/Sites?take=5",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"X-Api-Version": "3.0",
"Accept": "application/json",
},
method="GET",
)
with urllib.request.urlopen(request, timeout=30) as response:
print(response.status)
print(response.read().decode("utf-8", errors="replace"))That is the core network call in call_rest_api.py, without token loading,
argument parsing, or response summarization.
Every REST call uses the same bearer token model as GraphQL:
Authorization: Bearer <token>
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.