Python client library for Avanak voice message REST API. Avanak is a Persian voice messaging service that allows you to send voice messages, OTP codes, and manage campaigns programmatically.
- ✅ Complete API Coverage: All 17 Avanak REST API endpoints
- ✅ Type Safety: Full type hints and Pydantic models
- ✅ Easy to Use: Simple, intuitive API design
- ✅ Well Tested: Comprehensive test suite with 20+ unit tests
- ✅ CLI Tool: Command-line interface for quick operations
- ✅ Modern Python: Supports Python 3.8+ with modern practices
pip install avanakOr with uv (recommended):
uv add avanakfrom avanak import AvanakClient
# Initialize client with your API token
client = AvanakClient(token="your_api_token")
# Get account status
status = client.account_status()
print(f"Account: {status.account_name}")
print(f"Credit: {status.remaind_credit} Rials")
# Send OTP (One-Time Password)
otp = client.send_otp(length=4, number="09120000000")
print(f"OTP Code: {otp.generated_code}")
# Generate text-to-speech
tts = client.generate_tts(
text="سلام، این یک پیام صوتی آزمایشی است",
title="Test Message"
)
print(f"Message ID: {tts.id}")
# Send quick voice message
result = client.quick_send(
message_id=tts.id,
number="09120000000"
)
print(f"Send Status: {result['Status']}")The package includes a command-line tool for quick operations:
# After installation, use the avanak command directly
avanak account-status
avanak send-otp 4 09120000000
avanak generate-tts "Hello World" "Greeting"
# Or run as a module
python -m avanak account-statusaccount_status()- Get account information and credit balance
send_otp(length, number, ...)- Send one-time password
upload_message_base64(title, base64, ...)- Upload audio filedownload_message(message_id)- Download audio filegenerate_tts(text, title, ...)- Generate text-to-speechget_message(message_id)- Get message detailsdelete_message(message_id)- Delete messageget_messages(skip, take)- List messages
quick_send(message_id, number, ...)- Send existing messagequick_send_with_tts(text, number, ...)- Send TTS message directly
create_campaign(title, numbers, message_id, ...)- Create bulk campaignstart_campaign(campaign_id, ...)- Start campaignstop_campaign(campaign_id)- Stop campaignget_campaign(campaign_id)- Get campaign detailsget_campaign_numbers_by_campaign_id(campaign_id)- Get campaign recipients
get_quick_send(quick_send_id)- Get send statusget_quick_send_statistics(start_date, end_date)- Get statistics
Get your API token from the Avanak Portal. The token can be provided via:
- Environment variable:
export AVANAK_TOKEN=your_token - File: Save token in
~/.avanak_token - Direct parameter:
AvanakClient(token="your_token")
This project uses modern Python development tools:
# Install dependencies
uv sync
# Run tests
uv run pytest tests/ -v
# Lint code
uv run ruff check .
# Format code
uv run ruff format .
# Build package
uv buildContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- 📖 Documentation
- 🐛 Issues
- 💬 Avanak Portal