A modern, professional Python SIP client library with voice support, modular architecture, and comprehensive CLI interface. Perfect for building VoIP applications, softphones, and telecommunications tools.
- Full SIP Protocol Support - RFC 3261 compliant implementation
- Voice Communication - RTP-based audio streaming with device management
- Authentication - SIP digest authentication support
- Registration Management - Automatic re-registration with keep-alive
- Call Management - Multiple concurrent calls with state tracking
- Modular Architecture - Clean separation of concerns
- Rich CLI Interface - Beautiful command-line interface with colored output
- Comprehensive Logging - Structured logging with multiple output formats
- Type Safety - Full type hints and mypy compliance
- Professional APIs - Clean, intuitive programming interfaces
- Extensive Documentation - Complete guides and examples
- Cross-Platform - Works on Windows, macOS, and Linux
- SIP Providers - Works with Asterisk, FreeSWITCH, voip.ms, Twilio SIP
- Audio Devices - Enumeration and runtime switching
- Session Management - Proper SIP session handling
- Error Recovery - Robust error handling and recovery
- Network Resilience - NAT traversal and network change handling
# Install from PyPI (when published)
pip install usip
# Or install from source
git clone https://github.com/yourusername/uSIP.git
cd uSIP
pip install -e .Create a .env file with your SIP credentials:
SIP_DOMAIN=your-sip-provider.com
SIP_USERNAME=your-username
SIP_PASSWORD=your-password
SIP_PORT=5060# Test your configuration
usip-cli test
# Register with SIP server
usip-cli register
# Make a call
usip-cli call +1234567890
# Show status
usip-cli statusfrom sip_client import SIPClient, SIPAccount
# Create account
account = SIPAccount(
username="your-username",
password="your-password",
domain="your-sip-provider.com"
)
# Initialize client
client = SIPClient(account)
client.start()
# Register
if client.register():
print("Registration successful!")
# Make a call
call_id = client.make_call("sip:+1234567890@provider.com")
if call_id:
print(f"Call initiated: {call_id}")
# Hang up after some time
input("Press Enter to hang up...")
client.hangup(call_id)
# Clean up
client.stop()Main client class for SIP operations:
class SIPClient:
def __init__(self, account: SIPAccount)
def start() -> bool
def stop()
def register() -> bool
def make_call(target_uri: str) -> Optional[str]
def hangup(call_id: str) -> bool
def get_calls() -> List[CallInfo]Account configuration:
@dataclass
class SIPAccount:
username: str
password: str
domain: str
port: int = 5060
display_name: Optional[str] = Noneclass CallState(Enum):
IDLE = auto()
CALLING = auto()
RINGING = auto()
CONNECTED = auto()
DISCONNECTED = auto()
FAILED = auto()| Command | Description | Example |
|---|---|---|
test |
Test SIP configuration | usip-cli test |
register |
Register with SIP server | usip-cli register |
call <number> |
Make a call | usip-cli call +1234567890 |
status |
Show client status | usip-cli status |
Environment variables:
| Variable | Description | Required | Default |
|---|---|---|---|
SIP_DOMAIN |
SIP server domain | Yes | - |
SIP_USERNAME |
SIP username | Yes | - |
SIP_PASSWORD |
SIP password | Yes | - |
SIP_PORT |
SIP server port | No | 5060 |
uSIP/
βββ src/sip_client/ # Main library
β βββ models/ # Data models
β β βββ account.py # SIP account configuration
β β βββ call.py # Call information
β β βββ enums.py # State enumerations
β βββ audio/ # Audio management
β β βββ manager.py # Audio streaming
β β βββ devices.py # Device enumeration
β βββ sip/ # SIP protocol
β β βββ protocol.py # Core SIP implementation
β β βββ messages.py # Message parsing
β βββ utils/ # Utilities
β β βββ helpers.py # Helper functions
β βββ client.py # Main client class
βββ usip_cli.py # CLI interface
βββ pyproject.toml # Project configuration
- Client Layer - High-level SIP client API
- Protocol Layer - SIP message handling and networking
- Audio Layer - RTP streaming and device management
- Model Layer - Data structures and state management
- CLI Layer - Command-line interface
Tested with:
- β voip.ms - Full compatibility
- β Asterisk - Complete support
- β FreeSWITCH - Full functionality
- β Twilio SIP - Voice calling
- π Other RFC 3261 compliant servers
$ usip-cli test
Testing SIP client configuration...
β Configuration loaded successfully
β SIP client initialized successfully
β Registration successful
SIP client is ready for calls!We welcome contributions! Please see our Contributing Guide for details.
# Clone repository
git clone https://github.com/yourusername/uSIP.git
cd uSIP
# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run tests
pytest
# Run type checking
mypy src/
# Format code
black src/
isort src/- Python 3.8+
- click - CLI framework
- rich - Terminal formatting
- cryptography - Authentication
This project is licensed under the MIT License - see the LICENSE file for details.
- Built for the Python telecommunications community
- Inspired by modern VoIP standards and practices
- Designed for both beginners and professionals
- π Documentation: usip.readthedocs.io
- π Bug Reports: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π§ Email: contact@usip.dev
uSIP - Modern Python SIP Client Library for Professional VoIP Applications