Skip to main content

Vingd API interface client.

Project description

Vingd enables users to pay with money or with time. Money goes directly to publishers and time is monetized indirectly through interaction with brands, content creation, loyalty, bringing new users, etc. As a result Vingd dramatically increases monetization while keeping reach. Vingd’s secret sauce are mathematical models that are adapting to each user in order to extract as much value as possible from their time.

We use vingds (think of it as “digital currency”, points, or credits) to express the value (“price”) of intangible goods (such as TV streams or newspaper articles), to reward users for their activity (time), or to authorize (“charge”) them access to digital goods.

Vingd API for Python

Vingd API enables you to register Vingd objects you’re selling, create Vingd purchase orders, verify and commit Vingd purchases. You can also reward users, either directly (in backend), or indirectly via Vingd vouchers. Detailed docs and demos are available.

Installation

To install the last stable release of Vingd API:

$ pip install vingd

Or, to install from GitHub source:

$ git clone https://github.com/vingd/vingd-api-python
$ cd vingd-api-python
$ make env && source env/bin/activate   (skip if already in virtualenv)
$ python setup.py install

Examples

Client initialization and account balance fetching:

from vingd import Vingd

VINGD_USERNAME = 'test@vingd.com'
VINGD_PASSWORD = '123'

# Initialize Vingd client.
v = Vingd(username=VINGD_USERNAME, password=VINGD_PASSWORD,
          endpoint=Vingd.URL_ENDPOINT_SANDBOX, frontend=Vingd.URL_FRONTEND_SANDBOX)

# Fetch user balance.
balance = v.get_user_balance()

Sell content

Wrap up Vingd order and redirect user to confirm his purchase at Vingd frontend:

# Selling details.
OBJECT_NAME = "My test object"
OBJECT_URL = "http://localhost:666/"
ORDER_PRICE = 200 # VINGD 2.00

# Register Vingd object (once per selling item).
oid = v.create_object(OBJECT_NAME, OBJECT_URL)

# Prepare Vingd order.
order = v.create_order(oid, ORDER_PRICE)

# Order ready, redirect user to confirm his purchase at Vingd frontend.
redirect_url = order['urls']['redirect']

As user confirms his purchase on Vingd frontend he is redirected back to object URL expanded with purchase verification parameters.

# User confirmed purchase on Vingd frontend and came back to http://localhost:666/?oid=<oid>&tid=<tid>
purchase = v.verify_purchase(oid, tid)

# Purchase successfully verified, serve purchased content to user.
# ... content serving ...

# Content is successfully served, commit Vingd transaction.
commit = v.commit_purchase(purchase['purchaseid'], purchase['transferid'])

Reward user with vingd

Reward user with vingd:

# Vingd hashed user id, as obtained in purchase procedure (previous example).
REWARD_HUID = purchase['huid']
REWARD_AMOUNT = 75 # VINGD 0.75
REWARD_DESCRIPTION = "Testing direct rewarding"

# Reward user.
reward = v.reward_user(REWARD_HUID, REWARD_AMOUNT, REWARD_DESCRIPTION)

Reward user with voucher

Redirect user to redeem his reward on vingd frontend:

VOUCHER_AMOUNT = 100; # 1.00 vingd
VOUCHER_EXPIRES = {'days': 14}

# Create vingd voucher.
voucher = v.create_voucher(amount=VOUCHER_AMOUNT, expires=VOUCHER_EXPIRES)

# Redirect user to use voucher on vingd frontend:
redirect_url = voucher['urls']['redirect']

For more examples, see example/test.py in source.

Documentation

Automatically generated documentation for latest stable version is available on: https://vingd-api-for-python.readthedocs.org/en/latest/.

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

vingd-0.1.8.tar.gz (14.8 kB view details)

Uploaded Source

File details

Details for the file vingd-0.1.8.tar.gz.

File metadata

  • Download URL: vingd-0.1.8.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for vingd-0.1.8.tar.gz
Algorithm Hash digest
SHA256 25e0be7beff524c7255d87cbc9505df4963a17cc07e45d628a2a42dbcd3b6e25
MD5 8ab826012a6c686c0bf0fc35b115d262
BLAKE2b-256 8a4602e32021db86da1ddb4286cf431f435a828d3f1da6c78c0a9626ab539984

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page