skillfed

btsocket

Python library for BlueZ Bluetooth Management API

btsocket v0.3.0 625.5K downloads/30d#5,695 on PyPI18
Permissive license MIT AGING released

What it is and what it does

btsocket is a low-level Python wrapper around the BlueZ Bluetooth Management API on Linux. It provides access to the kernel's mgmt socket interface for controlling Bluetooth adapters—powering them on/off, discovering devices, and managing connections—without the ability to read or write data on connected devices themselves. The library requires root or CAP_NET_ADMIN capability for most operations.

The package splits functionality into three layers: a socket layer (working around a Python limitation to access the user channel), a protocol layer for encoding and decoding binary mgmt commands and responses, and a programming paradigm layer offering both synchronous (blocking) and callback-driven (event-based) APIs. It is explicitly positioned as an early-stage proof of concept and not recommended as a first Bluetooth library for newcomers.

Use it for:

  • Automate Bluetooth adapter power management and discovery on embedded Linux systems
  • Build home automation scripts that scan for and manage Bluetooth device presence
  • Develop educational projects exploring the BlueZ stack and low-level Bluetooth protocol
  • Monitor and control Bluetooth adapters programmatically in system administration tools
  • Create event-driven applications that react to Bluetooth device discovery or connection changes

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A Python library for controlling BlueZ Bluetooth adapters on Linux via the Management API, supporting both synchronous and event-driven command patterns.

Yes, if you need direct access to BlueZ's management API on Linux and are comfortable with root-level operations and early-stage code. No, if you are new to Bluetooth, need data I/O on connected devices, or require a mature, actively maintained library. The aging maintenance status suggests caution for production use.

Install

btsocket on PyPI

pip

pip install btsocket

uv

uv add btsocket

poetry

poetry add btsocket

Installing btsocket

Before you install

Low install friction with no runtime dependencies. Maintenance is aging—last release was over a year ago and the repository shows limited activity (18 stars), though it remains unarchived.

License in practice

MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install btsocket

from btsocket import btmgmt_sync
response = btmgmt_sync.send('SetPowered', 0, 1)

Requires root or CAP_NET_ADMIN capability; Linux-only; works around Python socket limitation documented at https://bugs.python.org/issue36132

Verify before relying

  • Whether the library works with modern Python versions (requires_python is unspecified)
  • Current state of the Python socket bug at https://bugs.python.org/issue36132 and whether it affects current releases
  • Compatibility with recent BlueZ versions and Linux kernel releases

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 795 days since the last release
Last repo commit
First released
Downloads 625,467/month — #5,695 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: btsocket-0.3.0-py2.py3-none-any.whl

Keywords: BlueZ, Bluetooth, Management, MGMT, API

Development Status :: 3 - AlphaIntended Audience :: DevelopersIntended Audience :: EducationLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3 :: OnlyTopic :: EducationTopic :: Home AutomationTopic :: Software Development :: Embedded SystemsTopic :: System :: Hardware

Tags

bluez bluetooth management api pythonlinux bluetooth control librarybluetooth device discovery pythonmgmt socket bluetoothbluetooth adapter controlbluez python wrapperbluetooth management commands
bluetoothlinux-onlyrequires-root

More Home Automation packages

netaddr

Represents and manipulates IPv4, IPv6, MAC…

permissive · top 5,000 on PyPI

homeassistant

Home Assistant is an open-source home…

permissive · top 5,000 on PyPI

python-statemachine

Defines finite state machines and statecharts…

permissive · top 5,000 on PyPI

aiohomematic

An async Python library for controlling and…

permissive · top 15,000 on PyPI

hass-web-proxy-lib

Provides base classes and utilities for Home…

permissive · top 15,000 on PyPI

openccu-data

Extracts and distributes Homematic CCU…

permissive · top 15,000 on PyPI

bluezoo

BlueZoo is a mock BlueZ D-Bus API service that…

copyleft · top 15,000 on PyPI

pyobjc-framework-IOBluetooth

Provides Python bindings to macOS's IOBluetooth…

permissive · top 15,000 on PyPI

winrt-Windows.Devices.Bluetooth

Provides Python bindings to Windows Runtime…

permissive · top 15,000 on PyPI

bluetooth-adapters

Enumerates and locates Bluetooth adapters on a…

permissive · top 15,000 on PyPI

matter-ble-proxy

A Python client library that bridges BLE…

permissive · top 15,000 on PyPI

pyobjc-framework-CoreBluetooth

Provides Python bindings to macOS's…

permissive · top 5,000 on PyPI

xiaomi-ble

Manages Xiaomi BLE (Bluetooth Low Energy)…

permissive · top 15,000 on PyPI

Adax-local

A Python library for local communication with…

permissive · top 15,000 on PyPI

miniupnpc

Python binding for MiniUPnPc library that…

permissive · top 15,000 on PyPI

pylibfdt

Provides Python bindings to libfdt, the device…

unclear · top 15,000 on PyPI