This folder contains runnable example scripts demonstrating various features of the Puzzel SMS Gateway Python Client.
Simple SMS sending example
The most basic example showing how to send a single SMS message. Perfect starting point for new users.
python docs/examples/example_basic.pyFeatures demonstrated:
- Client setup and initialization
- Basic message sending
- Response handling
Advanced configuration example
Comprehensive example showing all available configuration options.
python docs/examples/example_advanced.pyFeatures demonstrated:
- Scheduled message delivery (send window)
- Custom originator (sender ID)
- Priority and validity settings
- Premium SMS with pricing
- GAS settings
- Custom parameters
- All message settings options
Multiple recipients example
Examples of sending SMS to multiple recipients in different ways.
python docs/examples/example_multiple_recipients.pyFeatures demonstrated:
- Sending same message to multiple recipients
- Sending personalized messages to different recipients
- Batch sending with rate limiting
- Bulk message handling
Batch management example
Examples of managing message batches.
python docs/examples/example_batch_management.pyFeatures demonstrated:
- Listing all batches for a service
- Getting details of a specific batch
- Stopping a batch
- Monitoring batch status
-
Install the SMS Gateway client:
# Using uv (recommended) uv pip install puzzel-sms-gateway-client # Or using pip pip install puzzel-sms-gateway-client
-
Configure your credentials in each example file:
BASE_URL: Your SMS Gateway server URLSERVICE_ID: Your service IDUSERNAME: Your usernamePASSWORD: Your passwordRECIPIENT: A valid phone number for testing
# Run an example from your project directory
python docs/examples/example_basic.pyAll examples are designed to be easily customizable:
- Open the example file in your editor
- Update the configuration variables at the top
- Modify the message content or settings as needed
- Run the script
Each example follows a consistent structure:
"""
Example description and features demonstrated
"""
import asyncio
# ... imports ...
async def main_function():
"""Main example function."""
# Configuration
BASE_URL = "..."
SERVICE_ID = ...
# ... etc ...
# Setup client
# ... client setup code ...
# Example code
# ... demonstration code ...
# Error handling
try:
# ... API calls ...
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
asyncio.run(main_function())- Start Simple: Begin with
example_basic.pyto verify your setup works - Test Safely: Use your own phone number for testing
- Read Comments: Each example includes detailed comments explaining the code
- Check Output: Examples print detailed information about the API responses
- Handle Errors: All examples include error handling patterns
If you get import errors, make sure you've installed the client:
# Install from PyPI
pip install puzzel-sms-gateway-client
# or
uv pip install puzzel-sms-gateway-clientCheck that:
- Your
BASE_URLis correct - You have network access to the SMS Gateway server
- The server is running and accessible
Verify that:
- Your
SERVICE_ID,USERNAME, andPASSWORDare correct - Your account has permission to send SMS
Phone numbers must:
- Include country code (e.g.,
+47for Norway) - Be in format:
+[country code][number] - Example:
+47xxxxxxxxx
After running the examples:
- Review the 04 - Complete Examples Documentation for more use cases
- Check the 05 - API Models Reference for detailed model information
- Explore 06 - Advanced Topics for production patterns
- Read the 03 - Quick Reference for common operations
- Check the 02 - Getting Started Guide
- Review the Main README
- Contact Puzzel support
If you create a useful example, consider:
- Following the existing code style
- Adding detailed comments
- Including error handling
- Documenting what the example demonstrates