Skip to main content

Python Client for Suprema GSDK

This is the pip distributable version of the Suprema GSDK Python client, which makes it easier to interact with the GSDK.

The examples from the Suprema GSDK Wiki can be used, but with this package, all dependencies are handled via PIP. The EventCode .json file and device list are also initialized automatically when importing package.

Tips

On some clients (Particularly android) the EventCode json can sometimes not be loaded. If this happens, an error will display. You can then call

JsonFileLocation = "C:\\biostarPython\\event_code.json"
biostarPython.initCodeMap(JsonFileLocation)

To check Event codes, call

biostarPython.getEventString(eventCode,subCode)

To check device type, call

biostarPython.deviceType[deviceCode]

I'd also recommend checking out Advanced Installer! They allow free licences for open-source projects and the features of the program licences are well worth it!

How to use the rest of the classes.

All classes that can be used are imported under the biostarPython package. The ones currently written are:
GatewayClient, ConnectSvc, DeviceSvc, FaceSvc, FingerSvc, StatusSvc, UserSvc, DisplaySvc, AdminSvc, WiegandSvc, TimeSvc, CardSvc, EventSvc, NetworkSvc, ServerSvc, SystemSvc, DoorSvc, RS485Svc, AuthSvc, AccessSvc, ScheduleSvc, ActionSvc, TNASvc, OperatorSvc, LockZoneSvc, TimedAPBZoneSvc, APBZoneSvc, IntrusionZoneSvc, FireZoneSvc, InterlockZoneSvc, UDPSvc, DeviceLicenseSvc, MasterAdminSvc, RTSPSvc, VOIPSvc, CertSvc, ConnectMasterSvc, DeviceNotifySvc, GatewaySvc, InputSvc, LiftSvc, LiftZoneSvc, LoginSvc, MasterSvc, TenantSvc, ThermalSvc & UDPMasterSvc

All RPCs in the included proto files have wrappers. Availability depends on your gateway and device firmware.

With all of these services, they are a callable class underneath the biostarPython package. An example of initial setup with the GatewayClient and ConnectSvc is below: For all of the functions below these services, they are formated with the first letter in lowercase, so to search a device would be searchDevice(), to get info would be getInfo().
The guides on how to use these are present at the the GSDK Homepage

# import the service duh!
import biostarPython as g
# connect to the gateway, get a channel, then funnel this through to the 
# services!
gateway = g.GatewayClient('127.0.0.1',4000,'ca.crt')
channel = gateway.getChannel()
connect = g.ConnectSvc(channel)
face = g.FaceSvc(channel)
network = g.NetworkSvc(channel)
# will return a list of devices visible on UDP
deviceInfo = connect.searchDevice(300) 
# needs IP address, port and SSL state
bs3 = connect.connect(connect.getConnInfo('192.168.0.50', 51211, False))
# 4 is the default scan threshold
face.scan(bs3,4)
#lets get and change an IP Config
existingConfig = network.getIPConfig(bs3)
existingConfig.useDHCP = False
existingConfig.IPAddress = '192.168.0.20'
network.setIPConfig(bs3, existingConfig)

All of the specific APIs can be found at the wiki Above.

Closing gateway connections

Use GatewayClient as a context manager to close its gRPC channel automatically, including when an operation raises an exception:

with g.GatewayClient('127.0.0.1', 4000, 'ca.crt') as gateway:
    users = g.UserSvc(gateway.getChannel())
    print(users.getStatistic(deviceID))

For longer-lived clients, call gateway.close() explicitly when finished, ideally in a finally block. Calling close() more than once is safe. Closing the channel cancels active RPCs and subscriptions, including those using service instances created from that channel. It does not disconnect devices from the GSDK gateway. After closure, getChannel() returns None; create a new GatewayClient to reconnect.

Version 0.7.0.0 migration notes

Requires Python 3.10+, grpcio 1.85.4+, and protobuf 7.35.1+ (major version 7). TestSvc has been removed with the retired Test service.

  • ConnectSvc.setConnectionMode, enableSSL, and disableSSL now accept a single deviceID. Use setConnectionModeMulti(deviceIDs, mode), enableSSLMulti(deviceIDs), and disableSSLMulti(deviceIDs) for lists of devices.
  • Corrected argument names: DeviceSvc.resetConfigMulti(deviceIDs, withNetwork, withDB), DeviceSvc.clearDBMulti(deviceIDs), UserSvc.setJobCodeMulti(deviceIDs, userJobCodes), and DisplaySvc.updateNoticeMulti(deviceIDs, notice).
  • UserSvc.getPartial now takes (deviceID, userIDs, infoMask). UserSvc.deleteAllMulti takes only deviceIDs; the previous userIDs argument was unused.
  • EventSvc.subscribe accepts optional deviceIDs and eventCodes; DoorSvc.lock and unlock accept optional normalizeTimer; TNASvc.getTNALog accepts an optional filter message.
  • All methods whose RPC response contains deviceErrors now return that protobuf collection, including existing multi-device methods that previously returned None or the complete response. Other new methods return the response's sole field when it has one, the complete response when it has several fields, and None for empty responses. Other existing return conventions are preserved.
  • Importing the package no longer creates GSDKlog.log, installs a file handler, or sets a log level. Configure logging in your application as shown below.
  • Server-streaming methods return the gRPC iterator. Master channel methods accept an iterator of protobuf messages as requestIterator; MasterSvc.newCommandResponse, newRealtimeEvent, newDeviceStatus, and newRealtimeQR construct those messages. MasterSvc exposes gateway channel RPCs; it does not run the gateway command-processing loop automatically.

For example, subscribe to QR/barcode notifications using an existing channel:

notifications = g.DeviceNotifySvc(channel)
for scan in notifications.subscribeQRScan(queueSize=100, deviceIDs=[bs3]):
    print(scan.deviceID, scan.QRData)

Per-device errors and logging

Multi-device RPCs can complete while individual devices fail. Methods whose responses contain deviceErrors return that collection unchanged. Each entry contains deviceID, code, and msg; an empty collection means no per-device errors were reported. Gateway or transport failures still raise grpc.RpcError.

errors = face.setConfigMulti(deviceIDs=[bs3], config=face.getConfig(bs3))
for error in errors:
    print(error.deviceID, error.code, error.msg)

This changes existing multi-device return values in version 0.7.0.0. Code that used result.deviceErrors should now iterate over result directly. Callers that ignored the return value continue to work, but should inspect it to detect partial failures.

The package uses the biostarPython logger with a NullHandler. Your application controls log destinations, formatting, and levels. To enable file logging explicitly:

import logging

logging.basicConfig(
    filename="GSDKlog.log",
    level=logging.INFO,
    format="%(asctime)s %(levelname)s %(name)s %(message)s",
)

Omit filename to log to the console. Existing application logging configurations are preserved, and importing the package repeatedly does not add duplicate handlers.

Regenerating protobuf bindings

From the repository root, install the development dependencies once:

python -m pip install -r requirements-dev.txt

After updating the .proto files in biostarPython/proto, run:

python scripts/regenerate_protos.py

The command finds all current proto files, generates Python, gRPC, and typing outputs in a temporary directory, and fixes local imports to use biostarPython.service. It updates pythonOut, grpcOut, and pyiOut, copies the Python and gRPC modules into service, and removes obsolete generated files in those locations. Unrelated files such as __init__.py are preserved. Typing outputs remain in pyiOut.

The full test suite then checks every RPC wrapper against the generated schemas. If installation or validation fails, the previous generated files are restored and the command exits with an error. New or removed RPCs may require corresponding manual changes to biostarPython/__init__.py before regeneration can pass.

The generator version is pinned in requirements-dev.txt. When upgrading it, also review the runtime requirements in setup.py. Generation runs locally and does not contact a gateway or require hardware.

changelog

  • 0.7.0.0 - Added wrappers for all current RPCs, including DeviceNotify QR subscriptions and master services; corrected request mappings, arguments, and response fields; removed TestSvc and updated runtime requirements; exposed per-device errors consistently and moved logging configuration to the application.
  • 0.6.5.0 - Updated proto files to 1.9.1 distribution of GSDK, added support for BioStation 3 Max, updated GRPC and Protobuf to latest.
  • 0.6.0.0 - Updated proto files to 1.9.0 distribution of GSDK, added MasterAdminSvc, DeviceLicenseSvc, Support for multiple devices, Run Action, Lock Override, Door Mode Override, Realtime IO and User Override.
  • 0.4.0.2 - Updated proto files to 1.7.1 distribution of GSDK (Template only selection for FaceData and FaceConfig)
  • 0.4.0.1 - Added UpdateSlideImages to DisplaySvc and added Fingerprint to TestSvc.
  • 0.4.0.0 - Updated proto files to 1.7.0 (New Features, BEW3 support), added TestSvc (Waiting on support from device), fixed factoryDefault parameters.
  • 0.3.0.5 - Added UDPSvc for changing IP config via UDP, Updated Proto generation to 1.6.0 version of GSDK.
  • 0.3.0.2 - Fixed no response recieved from some user commands, also added newEventFilter() under event service, to create a new Filter.
  • 0.3.0.0 - Support for BS3, VOIP, RTSP and Wiegand User ID
  • 0.2.1.4 - Version Push
  • 0.2.1.2 - Fixed issue with importing none existent package
  • 0.2.1.0 - Addes getJobCode, setJobCode, setJobCodeMulti and setAccessGroupMulti to the UserSvc
  • 0.2.0.1 - Added searchInfoToConnectInfo(self, searchInfo, isAsync) under ConnectSvc, allowing generation of Connection Parameters directly from search results
  • 0.2.0.0 - Upgraded support for gRPC to the newest version supported by python (Regenerated .py files from .proto)
  • 0.1.9.0 - Added zone services, LockZone, APBZone, TimedAPBZone, FireZone, InterlockZone and IntrusionZone are included. Also edited protobuf version to include security fixes (3.20.1)
  • 0.1.8.8 - Fixed minor issue with finger.scan (Did not return data)
  • 0.1.8.6 - Fixed minor issues
  • 0.1.8 - Implemented version check for Protobuf (3.20)
  • 0.1.7 - Implemented proper logging, a GSDKlog.log file is now used instead of the standard print command.
  • 0.1.6 - Added firmwareUpdateMulti to DeviceSvc (Needed for multiple device upgrade internally)
  • 0.1.5 - Added OperatorSvc call so operators above 10 can be added. Supports getList, add, delete, deleteAll, addMulti, deleteMulti and deleteAllMulti
  • 0.1.4 - Added getFinger, getFace and getCard to UserSvc. Added getQRConfig, setQRConfig and writeQR to CardSvc()
  • 0.1.3 - Added AuthSvc, AccessSvc, ScheduleSvc, ActionSvc and TNASvc. Under UserSvc, added newUser, newUserCard, newUserFinger and newUserFace for ease of calling when enrolling new user info.
  • 0.1.2 - Updated initial json file string, so import on linux works
  • 0.1.1 - Added Readme
  • 0.1.0 - Initial Commit

Metadata

Release files for biostarPython 0.7.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for biostarPython 0.7.1.0
File Size Uploaded Provenance Actions
biostarpython-0.7.1.0.tar.gz 185.5 kB Without provenance Details for biostarpython-0.7.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for biostarPython 0.7.1.0
File Interpreter ABI Platform Actions
biostarpython-0.7.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for biostarpython-0.7.1.0-py2.py3-none-any.whl

Total release size: 467.3 kB

Release files / biostarpython-0.7.1.0.tar.gz

Download URL biostarpython-0.7.1.0.tar.gz
Size 185.5 kB
Tags Source
SHA-256 checksum
How to use checksums
20b8894b366d2685296b831560acf7f9c81064cf362c2755ea732a1e50f4701a
BLAKE2b-256 checksum
How to use checksums
5ef7cab45799c3279911d82a87b6f89af88fb20e533c94691a8422403213134f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / biostarpython-0.7.1.0-py2.py3-none-any.whl

Download URL biostarpython-0.7.1.0-py2.py3-none-any.whl
Size 281.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6de6ca0ba4a1c4ba76417ff872492786b0b29cd9e90cfec1a36c872d0a9e14a6
BLAKE2b-256 checksum
How to use checksums
c73ebe391deca14df5d891303c184b3bb51fb3ffbd121b1a8e007d5b128f4481
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Security for biostarPython 0.7.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page