GithubHelp home page GithubHelp logo

bsgworld / bsg-python Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 3.0 32 KB

A Python module for communicating with the BSG API. SMS, Viber, HLR services

Home Page: https://bsg.world/developers/

License: BSD 2-Clause "Simplified" License

Python 100.00%
python-sms rest-api sms sms-api sms-client sms-gateway sms-messages sms-python sms-python-package sms-restapi

bsg-python's Introduction

BSG REST API. Free SMS API - Python

This repository contains the open source Python client for BSG REST API. The API allows you to send bulk SMS campaigns, single transactional SMS, Viber messages, and check phone numbers via HLR requests. The API usage is free. You only pay for the messages sent.

Pricing

Prices for sending messages can be found here: Prices

Requirements

For access to BSG API:

For development:

Installation

Download repository, decompress, install with setup.py install

Usage

See BSG REST API Documentation for complete list of API clients, error codes, result codes etc.

An short example of a SMS API usage:

import pprint
import bsg_restapi as api
from examples.settings import API_KEY

client = api.SMSAPI(config={'api_key': API_KEY})
result = client.send(message=api.SMSMessage(body='test message text'), recipients=api.Recipient(380967770002))
print('Result of SMS sending:\n{}'.format(pprint.pformat(result)))
# getting status of SMS
status = client.get_status(result['reference'])
print('Current SMS status result for reference {}: \n{}'.format(result['reference'], pprint.pformat(status, indent=4)))

An example of a HLR API usage:

import pprint
import bsg_restapi as api
from examples.settings import API_KEY

# Create HLR API Client
client = api.HLRAPI(config={'api_key': API_KEY})

# Get prices for HLR
prices = client.get_prices()
print('HLR Prices (first 5 elements from {}): \n{}'.format(len(prices), pprint.pformat(prices[0:5], indent=4)))

# Get HLR for single smisdn:
lookup_list = api.HLRL(380970000000)
print('Created HLR request: \n{}'.format(pprint.pformat(lookup_list, indent=4)))
# Send the request
result = client.send(lookup_list)
# Get server response
result_id = result['result'][0]['id']
# Get status of HLR by result_id:
status_id = client.get_status(result_id)
# Try the same for 'reference'
result_ref = result['result'][0]['reference']
status_ref = client.get_status(result_ref)
# and print the result
print('Current HLR response by id: \n{}'.format(pprint.pformat(status_id, indent=4)))
print('Current HLR response by reference: \n{}'.format(pprint.pformat(status_ref, indent=4)))

See examples subfolder for

  • samples of usage,
  • various API processing and error handling aspects,
  • examples for client's SSL certificate and proxy usage.

bsg-python's People

Contributors

argestgroup avatar ikrupaua avatar naurzalin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

bsg-python's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.