PyPureLink Matrix
A modern Python library for connecting to and managing PureLink matrix switching devices.
Features
- 🔐 Secure authentication with base64 encoding
- 🔗 Simple connection management
- ⚙️ Device API client for PureLink matrix devices
- 📝 Full type hints and documentation
- ✅ Input validation following device requirements
- 🎯 Context manager support for automatic resource cleanup
🤖 AI Assistance Disclosure
Parts of this project were developed with the assistance of Artificial Intelligence. AI tools were utilized as an accelerator to:
- Co-author and refine segments of the core library code.
- Help parse and structure raw data payloads during the reverse-engineering of the original hardware protocol.
- Transform early functional prototypes into a structured, production-ready package architecture.
- Generate test suites (
pytest) and draft structural documentation.
While AI assisted in speeding up the development workflow, all architectural decisions, hardware testing, protocol verification, and final code reviews were executed entirely by the author to ensure reliability and accuracy.
Installation
Using UV (recommended)
uv pip install -e .
Using pip
pip install -e .
Quick Start
from pypurelinkmatrix import PureLinkClient
# Create a client instance
client = PureLinkClient(
host="192.168.1.100",
username="admin",
password="password123"
)
# Authenticate with the device
try:
if client.login():
print("Successfully connected!")
# Device is now authenticated and ready for commands
except Exception as e:
print(f"Authentication failed: {e}")
# Always cleanup
client.close()
Using Context Manager (recommended)
from pypurelinkmatrix import PureLinkClient
with PureLinkClient(host="192.168.1.100") as client:
if client.login("admin", "password123"):
print("Connected to device")
# Your code here
Credential Requirements
Based on PureLink device specifications:
- Username: 1-15 characters (letters, numbers, underscore only)
- Password: 1-15 characters (letters, numbers, underscore only)
Configuration
Create a .env file for sensitive credentials:
PURELINK_HOST=192.168.1.100
PURELINK_USERNAME=admin
PURELINK_PASSWORD=secure_password
Then use in your code:
import os
from dotenv import load_dotenv
from pypurelinkmatrix import PureLinkClient
load_dotenv()
client = PureLinkClient(
host=os.getenv("PURELINK_HOST"),
username=os.getenv("PURELINK_USERNAME"),
password=os.getenv("PURELINK_PASSWORD")
)
API Reference
PureLinkClient
Constructor
PureLinkClient(
host: str,
username: str = "",
password: str = "",
timeout: int = 30,
use_https: bool = False,
verify_ssl: bool = True
)
- host: Device IP address or hostname
- username: Username for authentication
- password: Password for authentication
- timeout: Request timeout in seconds (default: 30)
- use_https: Use HTTPS for connection (default: False)
- verify_ssl: Verify SSL certificates (default: True)
Methods
login(username: Optional[str] = None, password: Optional[str] = None) -> bool
Authenticate with the PureLink device.
Returns True if authentication succeeds.
Raises:
ValidationError: Invalid credential formatAuthenticationError: Authentication failedPureLinkConnectionError: Cannot connect to device
logout() -> bool
Logout from the device. Returns True.
close() -> None
Close the client session and cleanup resources.
Error Handling
from pypurelinkmatrix import PureLinkClient
from pypurelinkmatrix.exceptions import (
ValidationError,
AuthenticationError,
PureLinkConnectionError
)
try:
client = PureLinkClient(host="192.168.1.100")
client.login("admin", "password")
except ValidationError as e:
print(f"Invalid credentials: {e}")
except AuthenticationError as e:
print(f"Authentication failed: {e}")
except PureLinkConnectionError as e:
print(f"Cannot connect to device: {e}")
Development
Setup Development Environment
# Install development dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=src/pypurelinkmatrix
# Format code
black src tests
# Lint code
ruff check src tests
# Type checking
mypy src/pypurelinkmatrix
Project Structure
pypurelinkmatrix/
├── src/pypurelinkmatrix/
│ ├── __init__.py # Package initialization
│ ├── client.py # Main connection client
│ └── exceptions.py # Custom exceptions
├── tests/ # Test suite
├── examples/ # Examples
├── pyproject.toml # Project configuration
└── README.md # This file
Contributing
Contributions are welcome! Please ensure:
- Code passes
blackformatting - Code passes
rufflinting - Code passes
mypytype checking - Tests pass with good coverage
License
GPL-3.0 License - see LICENSE file for details
Support
For issues, questions, or contributions, please visit the GitHub repository.
Special Thanks
Many thanks to:
- PureLink for hardware (and less for their documentation)
- HTTP Toolkit for making reverse engineering so much easier
- Github Copilot for helping me writing a prototype (and unit testing) faster
Metadata
Release files for pypurelinkmatrix 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pypurelinkmatrix-0.1.2.tar.gz | 60.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pypurelinkmatrix-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 108.0 kB
Release files / pypurelinkmatrix-0.1.2.tar.gz
| Download URL | pypurelinkmatrix-0.1.2.tar.gz |
|---|---|
| Size | 60.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd65bb6503bb6f28847e328998594751db68a542ace81c37b5eaaba6e0cf7e9c
|
|
BLAKE2b-256 checksum How to use checksums |
6325b9d1c3bdfbbddb5c780ffa274b541fbc3f9fc41712a1c1017ee7dfbca3ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.
Transparency logRelease files / pypurelinkmatrix-0.1.2-py3-none-any.whl
| Download URL | pypurelinkmatrix-0.1.2-py3-none-any.whl |
|---|---|
| Size | 47.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
064e538fb7473fac823d917c27c3a8b3addab5e7f00c6596c5fcc1e9444aac2d
|
|
BLAKE2b-256 checksum How to use checksums |
5c38988cf744762bdd378d6dddc459b5436558b7601f6fb35aef545e4219e1ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.
Transparency log