Skip to main content

A Python client for Mozilla's basket service.

Project description

This is a client for Mozilla’s email subscription service, basket. Basket is not a real subscription service, but it talks to a real one and we don’t really care who/what it is.

There are four API methods: subscribe, unsubscribe, user, and update_user. View the basket documentation for details.

https://travis-ci.org/mozilla/basket-client.png https://pypip.in/v/basket-client/badge.png

Installation

$ pip install basket-client

Usage

Do you want to subscribe people to Mozilla’s newsletters? All you need to do is:

import basket

basket.subscribe('<email>', '<newsletter>', <kwargs>)

You can pass additional fields as keyword arguments, such as format and country. For a list of available fields and newsletters, see the basket documentation.

Are you checking to see if a user was successfully subscribed? You can use the lookup_user method like so:

import basket

basket.lookup_user(email='<email>', api_key='<api_key>')

And it will return full details about the user. <api_key> is a special token that grants you admin access to the data. Check with the mozilla.org developers to get it.

Settings

BASKET_URL
URL to basket server, e.g. https://basket.mozilla.org
Default: http://localhost:8000
BASKET_API_KEY
The API Key granted to you by the mozilla.org developers so that you can use the lookup_user method with an email address.
BASKET_TIMEOUT
The number of seconds basket client should wait before giving up on the request.
Default: 10

If you’re using Django you can simply add these settings to your settings.py file. Otherwise basket-client will look for these values in an environment variable of the same name.

Tests

To run tests:

$ python setup.py test

Change Log

v0.3.7

  • Add the lookup_user function.
  • Add the BASKET_API_KEY setting.
  • Add the BASKET_TIMEOUT setting.

v0.3.6

  • Add the confirm function.

v0.3.5

  • Add tests

v0.3.4

  • Fix issue with calling subscribe with an iterable of newsletters.
  • Add request function to those exposed by the basket` module.

v0.3.3

  • Add get_newsletters API method for information on currently available newsletters.
  • Handle Timeout exceptions from requests.

Project details


Release history Release notifications

History Node

0.3.12

History Node

0.3.11

History Node

0.3.10

This version
History Node

0.3.7

History Node

0.3.6

History Node

0.3.4

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1

History Node

0.3.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
basket-client-0.3.7.tar.gz (7.8 kB) Copy SHA256 hash SHA256 Source None Aug 28, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page