Skip to main content

Avanak

PyPI version Python versions License: MIT

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.

Features

  • ✅ 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

Installation

pip install avanak

Or with uv (recommended):

uv add avanak

Quick Start

from 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']}")

CLI Usage

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-status

API Reference

Account Management

  • account_status() - Get account information and credit balance

OTP Operations

  • send_otp(length, number, ...) - Send one-time password

Message Management

  • upload_message_base64(title, base64, ...) - Upload audio file
  • download_message(message_id) - Download audio file
  • generate_tts(text, title, ...) - Generate text-to-speech
  • get_message(message_id) - Get message details
  • delete_message(message_id) - Delete message
  • get_messages(skip, take) - List messages

Sending Operations

  • quick_send(message_id, number, ...) - Send existing message
  • quick_send_with_tts(text, number, ...) - Send TTS message directly

Campaign Management

  • create_campaign(title, numbers, message_id, ...) - Create bulk campaign
  • start_campaign(campaign_id, ...) - Start campaign
  • stop_campaign(campaign_id) - Stop campaign
  • get_campaign(campaign_id) - Get campaign details
  • get_campaign_numbers_by_campaign_id(campaign_id) - Get campaign recipients

Reporting

  • get_quick_send(quick_send_id) - Get send status
  • get_quick_send_statistics(start_date, end_date) - Get statistics

Authentication

Get your API token from the Avanak Portal. The token can be provided via:

  1. Environment variable: export AVANAK_TOKEN=your_token
  2. File: Save token in ~/.avanak_token
  3. Direct parameter: AvanakClient(token="your_token")

Development

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 build

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Metadata

Release files for avanak 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for avanak 0.1.2
File Interpreter ABI Platform
avanak-0.1.2-py3-none-any.whl Python 3 none any Details

Release files / avanak-0.1.2-py3-none-any.whl

Download URL avanak-0.1.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df4a8113bdb8270c593b4b3a735a41a47724d34650b8fd65bce08bd002079841
BLAKE2b-256 checksum
How to use checksums
4af10452763b3a66ad4f369a40c27ab79b8f5d6d52d23413b9ab2813948726da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for avanak 0.1.2

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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page