pysmsboxnet

smsbox.net api client module.

class pysmsboxnet.api.Client(session: ClientSession, host: str, cle_api: str)

API client class.

Parameters:
  • session (aiohttp.ClientSession) – the aiohttp session to use

  • host (str) – the API endpoint host, for example api.smsbox.pro (https is forced)

  • cle_api (str) – the SMSBox API key, name is in French to reflect the documentation

async get_credits() float

Return float number of credits.

Raises:

pysmsboxnet.exceptions.SMSBoxException – result is not OK

async send(dest: str, msg: str, mode: str, parameters: dict[str, str] | None = None) int

Send a SMS.

Parameters:
  • dest (str) – SMS recipient(s), see API documentation about how to format

  • msg (str) – the SMS message

  • mode (str) – send mode, mode API parameter

  • parameters (dict) – other API parameter as strategy or if other charset than UTF8 is needed

Returns:

SMS ID if id parameter is set to 1 else 0

Return type:

int

Exceptions

The following exceptions can be thrown.

All exceptions are not applicable to all case but some are common, for example in case of an internal error or bad API key provided.

Exceptions for SMSBox API.

exception pysmsboxnet.exceptions.AuthException

Exception when API returns ERROR 02.

exception pysmsboxnet.exceptions.BillingException

Exception when API returns ERROR 03.

exception pysmsboxnet.exceptions.HTTPException(error_code: int)

Exception when API returns ERROR 03.

exception pysmsboxnet.exceptions.InternalErrorException

Exception when API returns ERROR 05.

exception pysmsboxnet.exceptions.ParameterErrorException

Exception when API returns ERROR 01.

exception pysmsboxnet.exceptions.SMSBoxException(message: str = 'Unknown API error')

Base exception for SMSBox API.

exception pysmsboxnet.exceptions.WrongRecipientException

Exception when API returns ERROR 04.