Skip to main content

Python client for the Free Mobile SMS API — send SMS notifications programmatically.

Project description

freemobile-sms

Python client for the Free Mobile SMS API. Send SMS notifications to your Free Mobile phone programmatically.

Installation

pip install freemobile-sms-client

Quick Start

Environment Variables

export FREE_MOBILE_USER=12345678      # Your Free Mobile customer ID
export FREE_MOBILE_PASSWORD=yourApiKey # Your API key (from your Free Mobile account)

Python (Programmatic)

from freemobile_sms import FreeMobileClient

# Uses FREE_MOBILE_USER / FREE_MOBILE_PASSWORD from environment
with FreeMobileClient() as client:
    result = client.send("Server alert: disk usage at 90%")
    print(result.ok)       # True
    print(result.message)   # "SMS sent successfully"

Or with explicit credentials:

from freemobile_sms import FreeMobileClient, FreeMobileSettings

settings = FreeMobileSettings(user="12345678", password="yourApiKey")
with FreeMobileClient(settings=settings) as client:
    result = client.send("Hello from Python!")

POST Method (No URL Encoding)

The API supports POST requests where the message doesn't need to be URL-encoded:

with FreeMobileClient() as client:
    result = client.send("Hello with émojis and special chars!", method="POST")

Async Python

from freemobile_sms import AsyncFreeMobileClient

async with AsyncFreeMobileClient() as client:
    result = await client.send("Async alert!")
    print(result.message)

CLI

# Using environment variables
freemobile-sms send "Hello from the command line!"

# Using options
freemobile-sms send "Hello!" --user 12345678 --password yourApiKey

# Using POST method (no URL encoding needed)
freemobile-sms send "Hello!" --method POST --user 12345678 --password yourApiKey

API Reference

FreeMobileClient

Synchronous client. Use as a context manager for automatic cleanup.

Method Description
send(message, method="GET") Send an SMS. Returns SMSResult. Use method="POST" to avoid URL-encoding.

AsyncFreeMobileClient

Asynchronous client. Same interface, but send() is async.

FreeMobileSettings

Pydantic Settings model. Reads from environment variables with FREE_MOBILE_ prefix, or from a .env file.

Field Env var Default
user FREE_MOBILE_USER ""
password FREE_MOBILE_PASSWORD ""
api_url FREE_MOBILE_API_URL https://smsapi.free-mobile.fr/sendmsg

SMSResult

Field Type Description
success bool Whether the SMS was sent
status_code int HTTP status code from the API
message str Human-readable description
ok bool Alias for success

Exceptions

Exception Status Description
FreeMobileClientError Base exception
RateLimitError 402 Too many SMS sent in too short a time
AccessDeniedError 403 Service not activated or incorrect login/key
ServerError 500 Free Mobile server error

Development

# Install with dev dependencies
uv pip install -e ".[dev]"

# Run tests with coverage (requires 100%)
pytest

# Lint and format
ruff check .
ruff format .

# Install pre-commit hooks
pre-commit install

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freemobile_sms_client-0.1.0.tar.gz (83.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freemobile_sms_client-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file freemobile_sms_client-0.1.0.tar.gz.

File metadata

  • Download URL: freemobile_sms_client-0.1.0.tar.gz
  • Upload date:
  • Size: 83.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for freemobile_sms_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5121f5cb4da007de73fc644575e4d6802a3e42916c20bf0acb5546533a00842b
MD5 1e787eab90b0b09a476e928c7250643c
BLAKE2b-256 12344e244be4c9f2cc723e0f94ceb1793fa9b09fa3b24727494ca4a943041bbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for freemobile_sms_client-0.1.0.tar.gz:

Publisher: release.yml on kemar-openclaw/freemobile-sms

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file freemobile_sms_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for freemobile_sms_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5036101d8563a94c8b9680a87a96286c5f2e370c6a9d93591dc51913c61d90d
MD5 56f59563baab3c95ab633b0bf2ee016d
BLAKE2b-256 a4f2e17d15893b9814138dbc45c4457301c3c8f910dc44ec41da0f6cc422a507

See more details on using hashes here.

Provenance

The following attestation bundles were made for freemobile_sms_client-0.1.0-py3-none-any.whl:

Publisher: release.yml on kemar-openclaw/freemobile-sms

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page