Skip to main content

Python library for interacting with Gatum GET API

Project description

Python library for Gatum API

The library for interacting with Gatum GET API

Requires Python 3.10 or later.

Getting Started

To use the library, first install it from PyPI using pip:

pip install gatum-api-py

Usage for Gatum GET API

Once you have installed the library, get an API token from Gatum WEB application.

Send SMS

from gatum_api_py import GatumAPI

# base_url parameter must be set according to your vendor:
client = GatumAPI(base_url='https://api.gatum.io', token='your_token')

# .send_sms() returns a requests library object with server response data
response = client.send_sms(phone='380957225759',  # required, destination phone number in MSISDN format
                           sender_id='Verify',  # required, numeric SID length must be 3-15 symbols, 
                           # alphanumeric SID length must be <= 11 symbols
                           text='Your OTP is 4542',  # required
                           sms_type='sms',  # optional, allowed types: 'sms', 'hlr', 'mnp', by default: 'sms'
                           lifetime='86400',  # optional, how many seconds this SMS will live, by default: '86400'
                           begin_date='2023-03-19',  # optional, the date when SMS should be sent,
                           # format: 'YYYY-MM-DD', by default: the current date
                           begin_time='19:16:00',
                           # optional, the time when SMS should be sent in GMT+0 in selected beginDate,
                           # format: 'HH:MM:SS', by default: the current time
                           delivery=False)  # optional, whether to return the DLR, 'TRUE' or 'FALSE', by default: 'TRUE'

print(response.json())

Receive DLR

To receive DLR, you need to go to the API > GET section in your WEB cabinet and in the DLR sending to webhook field, specify the webhook URL where Gatum should send them.

For example, you specified the URL of your webhook as https://yourdomain.com/apidlr, in this case, to send DLR Gatum will make a GET request to the URL https://yourdomain.com/apidlr?id_state=598801503&state=DELIVRD&time=2023-07-23+21%3A41%3A20
To confirm that you received the DLR, you need to return the value of the id_state parameter in response to this request.

An example of a simple listener written using the Python Flask framework:

from flask import Flask, request

app = Flask(__name__)


@app.route('/apidlr', methods=['GET'])
def receive_dlr():
    id_state = request.args.get('id_state')
    state = request.args.get('state')
    dlr_time = request.args.get('time')
    
    print(f'SMS ID = {id_state}, DLR status = {state}, DLR time = {dlr_time}')

    return id_state, 200


if __name__ == "__main__":
    app.run(debug=False, port=5000)

The output:

SMS ID = 598801503, DLR status = DELIVRD, DLR time = 2023-07-23 21:41:20

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

gatum-api-py-1.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

gatum_api_py-1.0.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file gatum-api-py-1.0.1.tar.gz.

File metadata

  • Download URL: gatum-api-py-1.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for gatum-api-py-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7a3ae7e714359365b515dbfef40f08d8ac38820ba17357ea73d3a4e15a6b615b
MD5 6078bddf69b49b796b4b4ca33cfc54ea
BLAKE2b-256 58ba8ba85058cb14985438cb28fa51b269df9879a8bf6a394e6b6043f0ba7671

See more details on using hashes here.

File details

Details for the file gatum_api_py-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gatum_api_py-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for gatum_api_py-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef0e1fe83536d0dbea5de6c76d8b0b14162c76daf15714a2d03ab7a893baadd3
MD5 917831e78cb5d08265251193744a6c8a
BLAKE2b-256 28f375177d99fc66311508d042536896d6a1109677eb2bf274d995bc379aec4c

See more details on using hashes here.

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