Skip to main content

Cardberg Service Bindings for Python

Project description

Cardberg Bindings for Python

Python library for Cardberg's API to work with gift cards.

The bindings currently allow you to:

  1. Get information on a specific card
  2. Create a transaction on a specific card

Detailed information of Cardberg's API can be found at their website. If you feel like you need covering additional API methods, please open an issue or create a pull request.


You can install this package by using pip:

pip install cardberg

If you fancy pipenv use:

pipenv install cardberg

To install from source, run:

python install

For the API client to work you would need Python 2.7+ or Python 3.4+.

To install via requirements file from your project, add the following for the moment before updating dependencies:



First off, you need to require the library and set the authentication information by providing your user handle and shared secret you got from the provider.

import cardberg
cardberg.api_credentials = ("partner_id", "shared_secret")

Getting card information is accomplished by calling cardberg.Card.get(). The method returns a Card object that includes id, name, surname, status and available credits and points. On this Card object we may create a transaction (whether positive or negative) by calling create_transaction() method with transaction type, decimal value of the transaction and optional bill ID for further reference.

Possible transaction types are either "credits" or "points" depending on what budget do we use. If you want to make a debit (for example your user is buying something) then provide a negative value.


import cardberg
from decimal import Decimal

cardberg.api_credentials = ("partner_id", "shared_secret")

card = cardberg.Card.get("D1nd17h")



  1. Check for open issues or open a new issue for a feature request or a bug.
  2. Fork the repository and make your changes to the master branch (or branch off of it).
  3. Send a pull request.


Run all tests on all supported Python versions:

make test

Run the linter with:

make lint

The client library uses Black for code formatting. Code must be formatted with Black before PRs are submitted. Run the formatter with:

make fmt


v0.2.0: 03/10/2019

Python 3 compatibility, code formatting covered by Black and various small fixes and formal changes to make everything better.

v0.1.1: 21/03/2016

Added rounding to two decimal places on credits and points returned from Cardberg's API.

v0.1.0: 14/03/2016

Initial version with support for card_info and create_transaction API methods.

Project details

Download files

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

Files for cardberg, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size cardberg-0.2.0-py2.7.egg (9.7 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size cardberg-0.2.0-py2.py3-none-any.whl (6.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size cardberg-0.2.0-py3.7.egg (9.9 kB) File type Egg Python version 3.7 Upload date Hashes View
Filename, size cardberg-0.2.0.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page