Skip to main content

Python client library for Telerivet REST API

Project description

Python client library for Telerivet REST API

https://telerivet.com/api

Overview

This library makes it easy to integrate your Python application with Telerivet. You can use it to:

  • send SMS messages via an Android phone or SMS gateway service
  • update contact information in Telerivet (e.g. from a signup form on your own website)
  • add or remove contacts from groups
  • export your message/contact data from Telerivet into your own systems
  • schedule messages to be sent at a later time
  • control automated services
  • much more

All API methods are fully documented at https://telerivet.com/api/rest/python , as well as in the comments of the Python source files.

To learn what functionality is available, start with telerivet/__init__.py, telerivet/project.py, and telerivet/apicursor.py.

System Requirements

Python 2.6 or higher (including Python 3)

Installation

Telerivet's Python client library is distributed via pip (https://pypi.org/project/telerivet/). If you have pip, run:

pip install telerivet

Alternatively, if you don't have pip, you can install the install the library into your site-packages by downloading the code and running:

python setup.py install

The installation process will also install the requests module if it is not already installed (https://requests.readthedocs.io/).

Example Usage

from __future__ import print_function # python 2/3 compatibility for example code

import telerivet

API_KEY = 'YOUR_API_KEY'  # from https://telerivet.com/api/keys
PROJECT_ID = 'YOUR_PROJECT_ID'

tr = telerivet.API(API_KEY)

project = tr.initProjectById(PROJECT_ID)

# Send a SMS message
project.sendMessage(
    to_number = '555-0001',
    content = 'Hello world!'
)

# Query contacts
name_prefix = 'John';
cursor = project.queryContacts(
    name = {'prefix': name_prefix},
    sort = 'name'
).limit(20)

print("%d contacts matching %s:\n" % (cursor.count(), name_prefix))

for contact in cursor:
    print(contact.name, contact.phone_number, contact.vars.birthdate)

# Import a contact
contact = project.getOrCreateContact(
    name = 'John Smith',
    phone_number = '555-0001',
    vars = {
        'birthdate': '1981-03-04',
        'network': 'Vodacom'
    }
)

# Add a contact to a group
group = project.getOrCreateGroup('Subscribers')
contact.addToGroup(group)

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

telerivet-1.8.5.tar.gz (52.4 kB view details)

Uploaded Source

Built Distribution

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

telerivet-1.8.5-py3-none-any.whl (69.8 kB view details)

Uploaded Python 3

File details

Details for the file telerivet-1.8.5.tar.gz.

File metadata

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

File hashes

Hashes for telerivet-1.8.5.tar.gz
Algorithm Hash digest
SHA256 742c63364a5aa2e7fe21a679ba410ff601baff749d89dc9a3bc82eec228a1273
MD5 4319a9b24e8c98f8e36f7aa8d5485adc
BLAKE2b-256 88e82368bb9e912fd442d9275356573fb1bbddf1713c0d853773073c4f08f36b

See more details on using hashes here.

File details

Details for the file telerivet-1.8.5-py3-none-any.whl.

File metadata

  • Download URL: telerivet-1.8.5-py3-none-any.whl
  • Upload date:
  • Size: 69.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for telerivet-1.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 21db8eb44e9378f48634c3032ebf36ed1ee4492f928919f435b3fb819aeccc8f
MD5 d581a9b9a0aed99a8098efc01c5f1fab
BLAKE2b-256 c69ace87135aabf4816abc59e1f922c792d27104132ee87531f1c125af9c3e08

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