Sigfox Manager
A Python library for handling Sigfox API operations with ease.
Features
Currently supports the following operations:
- Get all contracts on current Token
- Get all devices on selected contract
- Get device information
- Get messages from device
- Create device
- List device types with automatic pagination
- Resolve device types by id or name
- Provision devices with input validation
Installation
From PyPI (when published)
pip install sigfox-manager
From Source
git clone https://github.com/Jobenas/sigfox_manager_utility.git
cd sigfox_manager_utility
pip install .
For Development
git clone https://github.com/Jobenas/sigfox_manager_utility.git
cd sigfox_manager_utility
pip install -e .[dev]
Quick Start
from sigfox_manager import SigfoxManager
# Initialize the manager with your Sigfox API credentials
manager = SigfoxManager(user="your_username", pwd="your_password")
# Get all contracts
contracts = manager.get_contracts()
print(f"Found {len(contracts.data)} contracts")
# Get devices for a contract
if contracts.data:
contract_id = contracts.data[0].id
devices = manager.get_devices_by_contract(contract_id)
print(f"Found {len(devices.data)} devices")
# Get device information
if devices.data:
device_id = devices.data[0].id
device_info = manager.get_device_info(device_id)
print(f"Device: {device_info.name}")
# Get device messages
messages = manager.get_device_messages(device_id)
print(f"Found {len(messages.data)} messages")
# Paginate through all messages
all_messages = []
response = manager.get_device_messages(device_id)
all_messages.extend(response.data)
while response.paging.next is not None:
response = manager.get_device_messages(device_id, paging=response.paging)
all_messages.extend(response.data)
print(f"Total messages retrieved: {len(all_messages)}")
Device Type Management and Provisioning
from sigfox_manager import SigfoxManager
sm = SigfoxManager("API_LOGIN", "API_PASSWORD")
# List all device types with automatic pagination
dts = sm.get_device_types().data
print([(dt.id, dt.name) for dt in dts])
# Provision a device with input validation
# Device type can be specified by id or name
dev = sm.provision_device(
dev_id="19C3B",
pac="1234567890ABCDEF",
dev_type_ref="Type A", # Can use device type name or id
name="field-node-42",
automatic_renewal=True,
)
print(f"Created device: {dev.id} - {dev.name}")
Device Type Management and Provisioning
The library now includes enhanced features for managing device types and provisioning devices with validation:
from sigfox_manager import SigfoxManager
# Initialize the manager
sm = SigfoxManager("API_LOGIN", "API_PASSWORD")
# List all device types
dts = sm.get_device_types().data
print([(dt.id, dt.name) for dt in dts])
# Provision a new device with validation
# - Validates dev_id format (uppercase hex, 3-16 chars)
# - Validates pac format (16 alphanumeric chars)
# - Resolves device type by id or name
dev = sm.provision_device(
dev_id="19C3B",
pac="1234567890ABCDEF",
dev_type_ref="Type A", # Can be device type id or name
name="field-node-42",
automatic_renewal=True,
)
print(dev.id, dev.name)
API Reference
SigfoxManager
The main class for interacting with the Sigfox API.
Constructor
SigfoxManager(user: str, pwd: str)
Methods
get_contracts(fetch_all_pages: bool = True) -> ContractsResponse: Get all contracts visible to the userget_devices_by_contract(contract_id: str, fetch_all_pages: bool = True) -> DevicesResponse: Get all devices for a contractget_device_info(device_id: str) -> Device: Get detailed information about a specific deviceget_device_messages(device_id: str, threshold: Optional[int] = None, paging: Optional[Paging] = None) -> DeviceMessagesResponse: Get messages from a device with optional pagination supportget_device_message_number(device_id: str) -> DeviceMessageStats: Get message metrics for a devicecreate_device(dev_id, pac, dev_type_id, name, ...) -> BaseDevice: Create a new deviceget_device_types(fetch_all_pages: bool = True) -> DeviceTypesResponse: Get all device types with pagination supportresolve_device_type_id(ref: str) -> str: Resolve a device type reference (id or name) to its idprovision_device(dev_id: str, pac: str, dev_type_ref: str, name: Optional[str] = None, **kwargs) -> BaseDevice: Validate inputs and provision a new device
Exceptions
The library provides custom exceptions for better error handling:
SigfoxAPIException: Base exception for API errorsSigfoxDeviceNotFoundError: Raised when a device is not foundSigfoxAuthError: Raised for authentication errorsSigfoxDeviceCreateConflictException: Raised when trying to create a duplicate deviceSigfoxDeviceTypeNotFoundException: Raised when a device type cannot be resolved by id or name
Development
Setting up Development Environment
# Clone the repository
git clone https://github.com/Jobenas/sigfox_manager_utility.git
cd sigfox_manager_utility
# Install in development mode with dev dependencies
pip install -e .[dev]
Running Tests
pytest tests/
Code Formatting
black sigfox_manager/
Type Checking
mypy sigfox_manager/
Building the Package
python -m build
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for your changes
- Run the test suite
- Submit a pull request
Support
For issues and questions, please use the GitHub Issues page.
Metadata
Release files for sigfox-manager 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sigfox_manager-0.4.0.tar.gz | 135.6 kB | Without provenance | Details for sigfox_manager-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sigfox_manager-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for sigfox_manager-0.4.0-py3-none-any.whl |
Total release size: 148.0 kB
Release files / sigfox_manager-0.4.0.tar.gz
| Download URL | sigfox_manager-0.4.0.tar.gz |
|---|---|
| Size | 135.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60e8c8f3b7dcda83d14b55fa49da7a7aef0b719e31a32cdf3512353586e24b12
|
|
BLAKE2b-256 checksum How to use checksums |
2f665001c83a1bb7259395f147b146b347fdafcda0d8911ae8c67dc885ef028d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / sigfox_manager-0.4.0-py3-none-any.whl
| Download URL | sigfox_manager-0.4.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09c3577be306ef7d7a46902ef1ae57e4dd3132dd995f91577789c5611b750602
|
|
BLAKE2b-256 checksum How to use checksums |
d42a4ad5dea2f5482316ae2b603a5fd5d1d60123883f58e5b73b37d4f1bb49a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Security for sigfox-manager 0.4.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.