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
from urllib.parse import urlparse, parse_qs, unquote

app = Flask(__name__)


@app.route('/apidlr', methods=['GET'])
def receive_dlr():
    url = request.url
    parsed_url = urlparse(url)
    query_string = unquote(parsed_url.query)
    query_params = parse_qs(query_string) if parsed_url.query else {}

    params = {}
    for key, values in query_params.items():
        params[key] = values[0] if len(values) == 1 else values

    print(params)

    return params['id_state'], 200


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

The output:

{'id_state': '672887248', 'state': 'DELIVRD', 'time': '2023-11-28 13:23:13'}

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.2.tar.gz (4.0 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.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gatum-api-py-1.0.2.tar.gz
  • Upload date:
  • Size: 4.0 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.2.tar.gz
Algorithm Hash digest
SHA256 38090dde13de6fd51c40ac41fee38d3a350ba8bfa17213d91ddba3fb8fbd8a84
MD5 5f0bcffc5ba24c08d33001ec6e4d3a45
BLAKE2b-256 cbe0173cda6e0a29e95a51bde049ae281b430700f13442eb1720264f49ad7e7d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gatum_api_py-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a943dd52ae7f746b227747e89365bd32599849ff7f2cb3a3819bfa3e4ab2e89
MD5 3eb116af7df3e3ed1dc41b5467b74341
BLAKE2b-256 42aca641d60f5ee07ce36c773f6ec485703df750b1e5e7f3700c7fbe80e51eaa

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