Skip to content

colibri-software/tremendous-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tremendous-python

A python client library for the Tremendous API.

Installation

$ pip install tremendous-python

Getting started

All API requests require an access token. A sandbox access token is assigned upon signup through the Tremendous Dashboard. Once you are ready to move to production, you will be assigned a production access token.

Authentication

from tremendous import Tremendous

# Sandbox environment
client = Tremendous("[SANDBOX_ACCESS_TOKEN]", "https://testflight.tremendous.com/api/v2")

Campaigns are created within the dashboard by team admins. They define the catalog and presentation of your reward. API requests can always override these settings within the specific reward object by specifying the catalog, message, etc.

campaigns = client.campaigns.list()
campaign_id = campaigns[0]["id"]

The funding source you select is how you are charged for the order.

funding_sources = client.funding_sources.list()
funding_source_id = funding_sources[0]["id"]

Optionally pass a unique external_id for each order create call to guarantee that your order is idempotent and not executed multiple times.

external_id = "[ID FROM YOUR SYSTEM]"

An array data representing the rewards you'd like to send.

order_data = {
  "external_id": external_id,
  "payment": {
    "funding_source_id": funding_source_id,
  },
  "reward": {
    "value": {
      "denomination": 20,
      "currency_code": "USD"
    },
    "campaign_id": campaign_id,
    "delivery": {
      "method": "EMAIL",
    },
    "recipient": {
      "email": "[email protected]",
      "name": "Sam Stevens"
    }
  }
}

Submit the order.

client.orders.create(order_data)

About

Python Tremendous API Client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 97.9%
  • Makefile 2.1%