Esteria API Client
A Rust-based client library for sending SMS messages via the Esteria API (https://esteria.eu). This project provides:
- A core Rust library for programmatic SMS sending.
- A command-line interface (CLI) for quick SMS dispatch.
- Python bindings for easy integration into Python applications.
The client supports advanced features like scheduled sending, delivery reports, flash SMS, test mode, and custom encodings.
Features
- Authentication: Secure API key-based access.
- SMS Options:
- Scheduled delivery.
- Delivery report (DLR) callbacks.
- Expiration timeouts.
- Flags for debug, no-log, flash, test, no-blacklist, and character conversion.
- Encodings: Default, 8-bit, or UDH (User Data Header).
- Error Handling: Detailed error codes and messages from the API.
- Cross-Platform: Works on Linux, macOS, and Windows.
- Python Integration: Seamless Python API via PyO3 bindings.
- CLI Tool: Simple command-line usage with environment variable support.
Installation
For Python Users (via PyPI)
Install the Python package directly:
This installs the Python bindings, which include the underlying Rust library.
For Rust Users (via crates.io)
Add the library to your Cargo.toml:
[]
= "0.1.0" # Replace with the latest version
To install the CLI globally:
Note: The cli feature enables the command-line tool, and python enables Python bindings (used for building wheels).
Building from Source
Clone the repository:
Build the Rust library and CLI:
For Python bindings, ensure you have maturin installed (for building wheels):
To build a PyPI wheel:
Usage
Environment Variables
The client supports these env vars for convenience:
ESTERIA_API_BASE_URL: API endpoint (default:https://api.esteria.eu).ESTERIA_API_KEY: Your API key.
CLI Usage
The CLI tool (esteria-api-client) allows sending SMS from the terminal.
Basic example:
Full options:
Output:
Send SMS via Esteria API
Usage: esteria-api-client [OPTIONS] --api-url <API_URL> --api-key <API_KEY> --sender <SENDER> --number <NUMBER> --text <TEXT>
Options:
-u, --api-url <API_URL> API base URL (e.g., https://api.esteria.eu)
-k, --api-key <API_KEY> API key for authentication
-s, --sender <SENDER> Sender name or number
-n, --number <NUMBER> Recipient phone number (with or without +)
-t, --text <TEXT> Message text to send
--time <TIME> Schedule time (RFC3339 format, e.g., 2024-12-31T23:59:59Z)
--dlr-url <DLR_URL> Delivery report URL
--expired <EXPIRED> Expiration time in minutes
--user-key <USER_KEY> User key for tracking
--debug Enable debug mode
--nolog Disable logging
--flash Send as flash SMS
--test Test mode (don't actually send)
--nobl No blacklist check
--convert Convert characters
--encoding <ENCODING> Encoding: default, 8bit, or udh [default: 8bit]
-h, --help Print help
-V, --version Print version
On success, it prints the message ID (e.g., Message ID: 12345).
Python Usage
Import and use the SmsClient class:
=
# Basic send
= await
# Message ID on success
# With options
= |
= await
# Run the async function
SmsFlags: Bitflags for options (e.g.,SmsFlags.debug(),SmsFlags.flash()). Combine with|.PyEncoding: Constants likePyEncoding.DEFAULT,PyEncoding.EIGHT_BIT,PyEncoding.UDH.- Errors: Raises
RuntimeErroron failure with details.
Note: The time parameter is a Unix timestamp (seconds since epoch).
Rust Usage (Library)
Use the SmsClient and SmsRequest structs:
use ;
use Utc;
async
SmsFlags: Bitflags (e.g.,SmsFlags::DEBUG).Encoding: Enum forDefault,EightBit,Udh.- Errors:
SmsErrorvariants for handling.
API Error Codes
If sending fails, the client returns detailed errors based on Esteria's response codes:
- 1: System internal error
- 2: Missing parameter
- 3: Unable to authenticate
- ... (see full list in
esteria.rs)
Developer Notes
- Features: Enable
clifor the command-line tool orpythonfor bindings via Cargo. - Dependencies: Uses
reqwestfor HTTP,chronofor dates,clapfor CLI,pyo3for Python, andbitflagsfor flags. - Logging: Uses
env_logger(init in CLI). - Testing: Run
cargo test. Use--flag-testfor API test mode. - Contributing: Pull requests welcome! Focus on bug fixes, features, or docs.
- License: GPLv3.
For issues or suggestions, open a GitHub issue.
This project is not affiliated with Esteria.eu. Ensure you have an active Esteria account and API key.