GithubHelp home page GithubHelp logo

rafavaliev / python-rest-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from messagebird/python-rest-api

0.0 1.0 0.0 235 KB

This repository contains the open source Python client for MessageBird's REST API.

License: BSD 2-Clause "Simplified" License

Python 100.00%

python-rest-api's Introduction

MessageBird's REST API for Python

This repository contains the open source Python client for MessageBird's REST API. Documentation can be found at: https://developers.messagebird.com/.

Build Status

Requirements

  • Sign up for a free MessageBird account
  • Create a new access key in the developers sections
  • An application written in Python (tested with Python 2.7 and Python 3.4)

Installation

The easiest way to install the messagebird package is either via pip:

$ pip install messagebird

or manually by downloading the source and run the setup.py script:

$ python setup.py install

Examples

We have put some self-explanatory examples in the examples directory, but here is a quick example on how to get started. Assuming the installation was successful, you can import the messagebird package like this:

import messagebird

Then, create an instance of messagebird.Client:

client = messagebird.Client('test_gshuPaZoeEG6ovbc8M79w0QyM')

Now you can query the API for information or send a request. For example, if we want to request our balance information you'd do something like this:

try:
  # Fetch the Balance object.
  balance = client.balance()

  # Print the object information.
  print('Your balance:\n')
  print('  amount  : %d' % balance.amount)
  print('  type    : %s' % balance.type)
  print('  payment : %s\n' % balance.payment)

except messagebird.client.ErrorException as e:
  print('Error:\n')

  for error in e.errors:
    print('  code        : %d' % error.code)
    print('  description : %s' % error.description)
    print('  parameter   : %s\n' % error.parameter)

This will give you something like:

$ python example.py
Your balance:

  amount  : 9 
  type    : credits
  payment : prepaid

Please see the other examples for a complete overview of all the available API calls.

Conversations WhatsApp Sandbox

To use the whatsapp sandbox you need to add messagebird.Feature.ENABLE_CONVERSATIONS_API_WHATSAPP_SANDBOX to the list of features you want enabled. Don't forget to replace YOUR_ACCESS_KEY with your actual access key.

  client = messagebird.Client('1ekjMs368KTRlP0z6zfG9P70z', features=[messagebird.Feature.ENABLE_CONVERSATIONS_API_WHATSAPP_SANDBOX])

Documentation

Complete documentation, instructions, and examples are available at: https://developers.messagebird.com/.

License

The MessageBird REST Client for Python is licensed under The BSD 2-Clause License. Copyright (c) 2014, MessageBird

python-rest-api's People

Contributors

17twentynine avatar donis avatar dysosmus avatar epels avatar guiajlopes avatar jornengelbart avatar marcelcorso avatar mariuspot avatar michi88 avatar prep avatar roaldnefs avatar samwierema avatar sarathsp06 avatar sebastiaanmb avatar stefan-messagebird avatar valenmope avatar victormb84 avatar

Watchers

 avatar

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.