Skip to main content

GREENSMS API: SMS, Call, Voice, VK, WhatsApp, Viber, HLR, Pay

Project description

greensms-python

GitHub release (latest by date) PyPI - Python Version GitHub Workflow Status Coveralls github

Documentation

The documentation for the GREENSMS API can be found here.

Installation

pipenv install greensms

or

pip install greensms

Sample Usage

Check out these code examples to get up and running quickly.

from greensms.client import GreenSMS

# Register at my.greensms.ru first
client = GreenSMS(user='test', password='test')

response = client.sms.send(to='71231234567', txt='Message to deliver')
print(response.request_id) # or print(response['request_id'])

Environment Variables

greensms-python supports credential storage in environment variables. If no credentials are provided following env vars will be used: GREENSMS_USER/GREENSMS_PASS OR GREENSMS_TOKEN.

Token Auth

from greensms.client import GreenSMS

# Register at my.greensms.ru first
client = GreenSMS(token='yourtoken')

response = client.account.balance()
print(response.balance)

Compatibility

greensms-python is compatible with Python 2.7 and Python 3.4 onwards until the latest Python 3.11 version

Methods

  • You can either use username/password combination or auth token to create an object with constructor
  • All methods support named **kwargs
  • Each API Function is available as MODULE.FUNCTION()
  • Parameters for each API can be referred from here
  • Response keys can be used as dictionary keys response['key'] or properties response.key
  • Response keys by default are available in snake_case. If you want to use camelCase, then pass use_camel_case=true, in the constructor

Handling Exceptions

  • Exceptions for all APIs are thrown with RestError class. It extends the default Python Exception class.
  • Each error, will have error, code, message, errorType fields.
  • In case of Validation Error, additional params are available to show field-wise rule failures. Can be accessed by e.params property on the error object

Getting help

If you need help installing or using the library, please contact us: support@greensms.ru.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

Contributing

Bug fixes, docs, and library improvements are always welcome. Please refer to our Contributing Guide for detailed information on how you can contribute. If you're not familiar with the GitHub pull request/contribution process, this is a nice tutorial.

Getting Started

If you want to familiarize yourself with the project, you can start by forking the repository and cloning it in your local development environment. The project requires Node.js to be installed on your machine.

After cloning the repository, install the dependencies by running the following command in the directory of your cloned repository:

pip install -r requirements.txt

In addition to this, we recommend running the setup with virtualenv, for creating an isolated Python development environment.

GreenSMS has all the unit tests defined under tests folder with _test.py extension. Although it uses Python Unittest, we recommended that you test with py.test. PyTest supports Python unit tests out of the box and is faster for running the tests in bulk.

pytest tests

We also support tox for automate env/interpretor wise testing. Support versions are added to tox.ini. Dependencies added in root requirements.txt are supposed to be added to tests/requirements.txt as well.

You can install and run tox for the project with the following commands.

pip install tox  # Install tox

tox # Run test

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

greensms-2.0.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

greensms-2.0.1-py2.py3-none-any.whl (12.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file greensms-2.0.1.tar.gz.

File metadata

  • Download URL: greensms-2.0.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for greensms-2.0.1.tar.gz
Algorithm Hash digest
SHA256 1796caf5747b8f9957cbdae53bdc8b058a401204d989c2d73bf7288bb3285d0a
MD5 a9962b3a437b6ad2f05fcfdc5d506f3c
BLAKE2b-256 47d158174f71c359d2d746f0939f8fca388e25c843c48833401f3f5b2d42a112

See more details on using hashes here.

File details

Details for the file greensms-2.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: greensms-2.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for greensms-2.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d0e74119c8390dd8ca6eb37aeb148cd400f562234d9e6d431256aa0007532154
MD5 fbbd5f239b306cdbab5fc701d29141ce
BLAKE2b-256 011ae3e638d1bd6fe6d05839314bf11490d61dc73bcc71afb66cbabb1b97d7ee

See more details on using hashes here.

Supported by

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