A comprehensive Python library for the BrightSign Network (BSN) Cloud API
Project description
BSN Cloud API Python Library
A comprehensive Python library for interacting with the BrightSign Network (BSN) Cloud API. This library provides easy-to-use functions for managing BrightSign players remotely. At the moment, most non-DWS-related functions are not supported; this release focuses on remote DWS functionality.
Features
- Automatic Authentication - Handles OAuth2 authentication and automatic token renewal
- Extensive rDWS API Coverage – Covers the majority of remote DWS-related BSN Cloud API endpoints
- File Management - Upload, download, and manage files on BrightSign players
- Device Control - Reboot, configure, and control BrightSign devices remotely
- Diagnostics - Run network diagnostics, ping tests, and packet captures
- Video & Display Control - Manage video modes and display settings
- Registry Management - Read and modify player registry settings
- Storage Operations - Manage SD cards and other storage devices
- Advanced Features - SSH, DWS, firmware updates, and more
Installation
pip install bsn-cloud-api
If you wish to install the test version of this package install it using the following command:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ bsn-cloud-api
Quick Start
Method 1: Using Environment Variables (Recommended)
Create a .env file in your project root:
BSN_CLIENT_ID=your_client_id_here
BSN_SECRET=your_client_secret_here
BSN_NETWORK=your_network_name_here
Then use the library:
import bsn_cloud_api as bsn
# Get all devices
devices = bsn.get_devices()
# Reboot a player
result = bsn.put_device_reboot("SERIAL123")
# Upload a file to a player
bsn.put_device_files(
serial_number="SERIAL123",
local_file_path="video.mp4",
file_path="media/videos"
)
Method 2: Programmatic Configuration
import bsn_cloud_api as bsn
# Configure credentials in code
bsn.configure(
client_id="your_client_id",
secret="your_secret",
network="your_network"
)
# Now use the API
devices = bsn.get_devices()
Method 3: System Environment Variables
Set environment variables in your system:
export BSN_CLIENT_ID="your_client_id"
export BSN_SECRET="your_secret"
export BSN_NETWORK="your_network"
Then use the library without any configuration.
Authentication
The library automatically handles authentication for you:
The library automatically manages OAuth2 authentication for all API requests.
Lazy Initialization – No authentication or network requests are made until the first API call.
Automatic Login – Authentication is performed automatically when required.
Token Validity Checking – Before every API request, the library verifies that a valid access token is available.
Automatic Token Refresh – If the access token has expired, a new token is fetched automatically.
Time-Based Expiration – Token validity is determined using the expiration timestamp returned by the OAuth provider.
Network Selection – The configured BSN network is selected automatically after authentication.
Most authentication-related failures are returned as dictionaries containing an error key. Network-level issues (such as connectivity problems) may still raise exceptions from the underlying HTTP library.
You do not need to call login() manually in normal usage — authentication is handled transparently.
API Credentials
To get your BSN Cloud API credentials:
- Log in to https://adminpanel.bsn.cloud
- Select your network
- Navigate to Settings → Applications
- Create a new Application or use an existing one
- Copy your Client ID, Client Secret
Usage Examples
Device Management
# Get all devices
devices = bsn.get_devices()
# Get devices filtered by site
devices = bsn.get_devices(description="London HQ")
Provisioning Records
# Get all provisioning records (paginated)
records = bsn.get_provisioning_records(page_number=1, page_size=100)
# Get a specific provisioning record
record = bsn.get_provisioning_record(serial_number="ABC123")
# or by record ID
record = bsn.get_provisioning_record(record_id="507f1f77bcf86cd799439011")
# Create a new provisioning record
bsn.create_provisioning_record(
serial_number="ABC123",
username="admin",
setup_id="12345",
name="Lobby Display",
description="Main entrance display"
)
# Update an existing provisioning record
bsn.update_provisioning_record(
record_id="507f1f77bcf86cd799439011",
serial_number="ABC123",
username="admin",
name="Updated Lobby Display"
)
# Delete a provisioning record
bsn.delete_provisioning_record(serial_number="ABC123")
# or by record ID
bsn.delete_provisioning_record(record_id="507f1f77bcf86cd799439011")
# Delete multiple provisioning records
ids_to_delete = [
"507f1f77bcf86cd799439011",
"507f1f77bcf86cd799439012"
]
bsn.delete_provisioning_records(ids_to_delete)
Provisioning Records
# Get all provisioning records (paginated)
records = bsn.get_provisioning_records(page_number=1, page_size=100)
# Get a specific provisioning record
record = bsn.get_provisioning_record(serial_number="ABC123")
# or by record ID
record = bsn.get_provisioning_record(record_id="507f1f77bcf86cd799439011")
# Create a new provisioning record
bsn.create_provisioning_record(
serial_number="ABC123",
username="admin",
setup_id="12345",
name="Lobby Display",
description="Main entrance display"
)
# Update an existing provisioning record
bsn.update_provisioning_record(
record_id="507f1f77bcf86cd799439011",
serial_number="ABC123",
username="admin",
name="Updated Lobby Display"
)
# Delete a provisioning record
bsn.delete_provisioning_record(serial_number="ABC123")
# or by record ID
bsn.delete_provisioning_record(record_id="507f1f77bcf86cd799439011")
# Delete multiple provisioning records
ids_to_delete = [
"507f1f77bcf86cd799439011",
"507f1f77bcf86cd799439012"
]
bsn.delete_provisioning_records(ids_to_delete)
File Operations
# List files on SD card
files = bsn.get_device_files("SERIAL123", storage_type="sd", path="media")
# Upload a file
bsn.put_device_files(
serial_number="SERIAL123",
local_file_path="/local/path/video.mp4",
storage_type="sd",
file_path="media/videos",
dest_filename="intro.mp4"
)
# Create a directory
bsn.create_device_directory("SERIAL123", "media/videos")
# Delete a file
bsn.delete_device_file("SERIAL123", "media/old_video.mp4")
# Rename a file
bsn.rename_device_file("SERIAL123", "media/video.mp4", "intro.mp4")
Diagnostics
# Run full network diagnostics
diagnostics = bsn.get_device_diagnostics("SERIAL123")
# Ping a server
ping_result = bsn.get_device_ping("SERIAL123", "8.8.8.8")
# DNS lookup
dns_result = bsn.get_device_dns_lookup("SERIAL123", "google.com")
# Traceroute
trace = bsn.get_device_traceroute("SERIAL123", "google.com")
# Get network configuration
network_config = bsn.get_device_network_config("SERIAL123", interface="eth0")
# Start packet capture
bsn.start_device_packet_capture("SERIAL123", duration=60)
Video & Display Control
# Get current video mode
mode = bsn.get_device_video_mode("SERIAL123")
# Set video mode to 1080p60
bsn.set_device_video_mode("SERIAL123", "1920x1080x60p")
# Get display brightness (Moka displays only)
brightness = bsn.get_display_brightness("SERIAL123")
# Set display brightness
bsn.set_display_brightness("SERIAL123", 75)
# Control display power
bsn.set_display_power_settings("SERIAL123", "standby")
# Set volume
bsn.set_display_volume("SERIAL123", 50)
Registry Operations
# Get entire registry
registry = bsn.get_device_registry("SERIAL123")
# Get specific registry key
value = bsn.get_device_registry_key("SERIAL123", "networking", "dhcp")
# Set registry value
bsn.set_device_registry_key("SERIAL123", "networking", "dhcp", "yes")
# Delete registry key
bsn.delete_device_registry_key("SERIAL123", "customsection", "customkey")
# Flush registry to disk
bsn.flush_device_registry("SERIAL123")
Screenshots & Custom Commands
# Take a screenshot
snapshot = bsn.take_device_snapshot("SERIAL123")
thumbnail = snapshot['data']['result']['remoteSnapshotThumbnail']
# Send custom UDP command
bsn.send_device_custom_command("SERIAL123", "next", return_immediately=True)
# Download firmware
bsn.download_device_firmware(
"SERIAL123",
"https://example.com/firmware.bsfw"
)
API Documentation
For complete API documentation, see the BSN Cloud API Documentation.
Available Functions by Category
Unorganized BSN Cloud Platform Endpoints
Authentication
configure()- Set credentials programmaticallylogin()- Manual login (automatic when needed)
Most API failures are returned as dictionaries containing an error key. Network-level errors may still raise exceptions from the underlying HTTP library.
The API session is lazily initialized. No authentication or network requests occur until the first API call is made.
Device Management
get_devices()- List all devicesget_setups()- List setups/presentationsupdate_setup()- Update a setup
B-Deploy Endpoints (Setups and Provisioning)
Device Provisioning
get_provisioning_records()- Get paginated list of provisioning recordsget_provisioning_record()- Get single record by ID or serial number- Raises
ValueErrorif neitherrecord_idnorserial_numberprovided
- Raises
create_provisioning_record()- Create new provisioning record- Raises
ValueErrorif neithersetup_idnorsetup_nameprovided
- Raises
update_provisioning_record()- Update existing provisioning record- Raises
ValueErrorif neithersetup_idnorsetup_nameprovided
- Raises
delete_provisioning_record()- Delete single provisioning record- Raises
ValueErrorif neitherrecord_idnorserial_numberprovided
- Raises
delete_provisioning_records()- Delete multiple provisioning records- Raises
ValueErrorifidslist is empty
- Raises
Remote DWS Endpoints
Information Endpoints
get_device_info()- Get general device informationget_device_time()- Get device date and timeput_device_time()- Set device date and timeget_device_health()- Check device health/reachability
Logs Endpoints
get_device_logs()- Get device logsget_device_crash_dumps()- Get device crash dump
B-Deploy Endpoints (Setups and Provisioning)
Device Provisioning
get_provisioning_records()- Get paginated list of provisioning recordsget_provisioning_record()- Get single record by ID or serial number- Raises
ValueErrorif neitherrecord_idnorserial_numberprovided
- Raises
create_provisioning_record()- Create new provisioning record- Raises
ValueErrorif neithersetup_idnorsetup_nameprovided
- Raises
update_provisioning_record()- Update existing provisioning record- Raises
ValueErrorif neithersetup_idnorsetup_nameprovided
- Raises
delete_provisioning_record()- Delete single provisioning record- Raises
ValueErrorif neitherrecord_idnorserial_numberprovided
- Raises
delete_provisioning_records()- Delete multiple provisioning records- Raises
ValueErrorifidslist is empty
- Raises
Remote DWS Endpoints
Control Endpoints
put_device_reboot()- Reboot, factory reset, or reboot with options
DWS Password Control
get_device_password()- Get DWS password statusput_device_password()- Set DWS passwordget_device_local_dws_status()- Check local DWS statusset_device_local_dws()- Enable/disable local DWSreset_device_ssh_host_keys()- Reset SSH keysreset_device_dws_default_certs()- Reset DWS certificates
Storage/File Endpoints
get_device_files()- List filesput_device_files()- Upload filescreate_device_directory()- Create directoriesrename_device_file()- Rename filesdelete_device_file()- Delete files
Diagnostic Endpoints
get_device_diagnostics()- Full network diagnosticsget_device_dns_lookup()- DNS resolution testget_device_ping()- Ping testget_device_traceroute()- Tracerouteget_device_network_config()- Network configurationput_device_network_config()- Update network settingsget_device_network_neighborhood()- Discover nearby playersget_device_packet_capture_status()- Packet capture statusstart_device_packet_capture()- Start packet capturestop_device_packet_capture()- Stop packet captureget_device_telnet_status()- Telnet configurationput_device_telnet_config()- Configure telnetget_device_ssh_status()- SSH configurationput_device_ssh_config()- Configure SSH
Other Endpoints
reformat_device_storage()- Format storage devicereprovision_device()- Re-provision playertake_device_snapshot()- Take screenshotsend_device_custom_command()- Send custom UDP commanddownload_device_firmware()- Update firmware
Video Endpoints
get_device_video_mode()- Convenience method that returns the currently active video modeget_device_video_output()- Get output informationget_device_video_edid()- Get EDID dataget_device_video_power_save()- Power save statusset_device_video_power_save()- Enable/disable power saveget_device_video_modes()- List available modesget_device_video_current_mode()- Exposes the full BSN API and allows querying best, active, configured, or current modes.set_device_video_mode()- Change video mode
Registry Endpoints
get_device_registry()- Get full registryget_device_registry_key()- Get specific keyset_device_registry_key()- Set registry valuedelete_device_registry_key()- Delete registry keyflush_device_registry()- Flush to diskget_device_recovery_url()- Get recovery URLset_device_recovery_url()- Set recovery URL
Advanced Endpoints
get_device_property_lock()- Property lock statusset_device_property_lock()- Configure property lock
Display Control Endpoints (Moka displays only)
get_display_control_all()- All display settingsget_display_brightness()/set_display_brightness()- Brightnessget_display_contrast()/set_display_contrast()- Contrastget_display_volume()/set_display_volume()- Volumeget_display_power_settings()/set_display_power_settings()- Powerget_display_standby_timeout()/set_display_standby_timeout()- Standby timeoutget_display_white_balance()/set_display_white_balance()- Colorget_display_video_output()/set_display_video_output()- Video outputget_display_sd_connection()/set_display_sd_connection()- SD card controlget_display_always_connected()/set_display_always_connected()- Connectionget_display_always_on()/set_display_always_on()- Always onupdate_display_firmware()- Firmware updateget_display_info()- Display information
Error Handling
The library uses two approaches for error handling:
API/Network Errors (Returned as Dictionaries)
API failures and network issues are returned as error dictionaries:
result = bsn.get_device_files("INVALID_SERIAL", storage_type="sd")
if "error" in result:
print(f"Error {result['error']}: {result['details']}")
else:
# Success - process result
files = result['data']['result']
Input Validation Errors (Raised as Exceptions)
Invalid function arguments raise Python exceptions immediately:
try:
# Missing required parameter
bsn.create_provisioning_record(
serial_number="ABC123",
username="admin"
# Missing setup_id or setup_name!
)
except ValueError as e:
print(f"Validation error: {e}")
# Output: "Either 'setup_id' or 'setup_name' must be provided."
try:
# Invalid storage type
bsn.reformat_device_storage("ABC123", device_name="invalid")
except ValueError as e:
print(f"Validation error: {e}")
# Output: "Invalid device_name: 'invalid'. Must be one of: sd, usb, ssd"
try:
# Missing file
bsn.put_device_files("ABC123", local_file_path="/nonexistent/file.mp4")
except FileNotFoundError as e:
print(f"File error: {e}")
# Output: "File not found: '/nonexistent/file.mp4'"
Common Exceptions
| Exception | When It's Raised | Example |
|---|---|---|
ValueError |
Invalid parameter values or missing required parameters | Missing setup_id/setup_name, invalid storage_type |
FileNotFoundError |
Specified file doesn't exist | File path in put_device_files() |
Error Handling Best Practice
import bsn_cloud_api as bsn
try:
# Input validation happens here (raises exceptions)
result = bsn.create_provisioning_record(
serial_number="ABC123",
username="admin",
setup_id="12345"
)
# API/network errors are in the result dictionary
if "error" in result:
print(f"API Error: {result['error']}")
print(f"Details: {result['details']}")
else:
print("Success!")
print(result)
except ValueError as e:
print(f"Invalid input: {e}")
except FileNotFoundError as e:
print(f"File not found: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
Requirements
- Python 3.10+
requests- HTTP librarypython-dotenv- Environment variable management
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details
Support
For issues and questions:
- GitHub Issues: https://github.com/TobiaszGans/py_BSN_Cloud_API/issues
- BSN Cloud API Documentation: https://docs.brightsign.biz/developers/cloud-apis
- BrightSign Support: https://support.brightsign.biz
Design Philosophy
- Simple functional API (no client objects required)
- Single global authenticated session per process
- Thin wrapper around BSN Cloud API responses
- Minimal abstraction: responses closely match API output
Not Yet Supported
- Multi-network concurrent sessions
- Async / asyncio interface
- Automatic retry on rate limits
Changelog
Version 1.0.0 (Initial Release)
- Complete implementation of rDWS BSN Cloud API endpoints
- Automatic authentication and token renewal
- Support for all device control operations
- File management capabilities
- Network diagnostics tools
- Video and display control
- Registry management
- Display control for Moka displays
Author
Tobiasz Gans
Acknowledgments
- BrightSign for providing the BSN Cloud API
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bsn_cloud_api-1.2.1.tar.gz.
File metadata
- Download URL: bsn_cloud_api-1.2.1.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9c493723b6c463ff63c9d5e9c0526564d380332461a68ae4b0549851fb02895
|
|
| MD5 |
ed9cd466e861e7e9f9199a49b29dfcbc
|
|
| BLAKE2b-256 |
a5c6bcffed25e79d4885d811a58c7352179432fa5f60a1ae23dc40743beca5cb
|
File details
Details for the file bsn_cloud_api-1.2.1-py3-none-any.whl.
File metadata
- Download URL: bsn_cloud_api-1.2.1-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97cff984008ca7e0974adf8184db0aeb521ce0689ca63fd694ec01dd59d98dd5
|
|
| MD5 |
db1b7c5f983033c80f3c5a9ef9f06000
|
|
| BLAKE2b-256 |
7fc9ff49117748639e8f6ab635d736a7b68cf865a928c956c96cc16f67aa1eab
|