Skip to main content

Nifty-Client

Nifty Client is the official Python client for the nifty API. It does some heavy lifting to provide a simple and portable client. If you do find the client missing some features, please make a pull request or cut an issue.

Installation

Installing the client is simple with pip:

pip install niftyclient

Quickstart

After installing the client, get your api credentials from the nifty dashboard, configure the client with the credentials and you are good to go.

from niftyclient import NiftyWalletClient

class ExampleConfig:
    key_id = "f4664c39663272d70b7ebdc96ddac72e"
    secret = "4c198a69e108ce6f293734d4f0a511a0d1fd6bf70a26e9c2e5f147ff41615f9bf3b6349595aff7011ca28f806976715a"
    user_id = "15695297-f441-4b1c-a75b-831fbb1d1431"


client = NiftyWalletClient(ExampleConfig())

client.get_wallet()
# Response is wallet response with no wallet
# MutableDictionaryObject({'available_resultset_size': 0, 'tracking_uuid': UUID('89feedd2-2c51-11e7-bd4c-000c29e41bf4'), 'wallets': [] 'limit': 30, 'offset': 0, 'returned_resultset_size': 0})

client.create_wallet()
# wallet created.
# MutableDictionaryObject({'available_resultset_size': 1, 'tracking_uuid': UUID('89feedd2-2c51-11e7-bd4c-000c29e41bf4'), 'wallets': [DictionaryObject({'user_name': u'mike', 'created_at': datetime.datetime(2017, 4, 24, 23, 33, 52, 747695, tzinfo=tzoffset(None, 10800)), 'balance': Decimal('0.00'), 'user_id': UUID('8dad2dea-7d7f-4e8b-a61c-53150f1b7452'), 'last_modified': datetime.datetime(2017, 4, 27, 21, 31, 15, 268358, tzinfo=tzoffset(None, 10800))})], 'limit': 30, 'offset': 0, 'returned_resultset_size': 1})
client.create_wallet()
# This operation is idempotent and will return the same result as above

client.get_wallet()
# MutableDictionaryObject({'available_resultset_size': 1, 'tracking_uuid': UUID('89feedd2-2c51-11e7-bd4c-000c29e41bf4'), 'wallets': [DictionaryObject({'user_name': u'mike', 'created_at': datetime.datetime(2017, 4, 24, 23, 33, 52, 747695, tzinfo=tzoffset(None, 10800)), 'balance': Decimal('0.00'), 'user_id': UUID('8dad2dea-7d7f-4e8b-a61c-53150f1b7452'), 'last_modified': datetime.datetime(2017, 4, 27, 21, 31, 15, 268358, tzinfo=tzoffset(None, 10800))})], 'limit': 30, 'offset': 0, 'returned_resultset_size': 1})

# Consume token. This operation is not idempotent and is atomic.
client.consume_token(
    transaction_id="2TR46IBB5C", phone_number="254722123456", till_number=703648)
# MutableDictionaryObject({'transactions': [DictionaryObject({'till_number': u'703648', 'payment_id': UUID('d2c29c60-0b1a-11e7-8f7b-061cf2e0e94d'), 'user_id': UUID('8dad2dea-7d7f-4e8b-a61c-53150f1b7452'), 'trans_amount': Decimal('799.23'), 'msisdn': u'254722123456', 'trans_time': datetime.datetime(2016, 5, 29, 21, 30, 52, 739072, tzinfo=tzoffset(None, 10800)), 'names': u'First M Last', 'trans_id': u'2TR46IBB5C'})], 'tracking_uuid': UUID('3582b27e-2c52-11e7-bd4c-000c29e41bf4'), 'available_resultset_size': 1, 'limit': 0, 'offset': 0, 'returned_resultset_size': 1})

# Operation should not succeed again
client.consume_token(
    transaction_id="2TR46IBB5C", phone_number="254722123456", till_number=703648)
# MutableDictionaryObject({'transactions': [], 'tracking_uuid': UUID('c63774da-2c52-11e7-bd4c-000c29e41bf4'), 'available_resultset_size': 0, 'limit': 0, 'offset': 0, 'returned_resultset_size': 0})

# Any incorrect field will not return a redemption transaction.
client.consume_token(
    transaction_id="2TR46IBB5C", phone_number="254716622446", till_number=703646)
# MutableDictionaryObject({'transactions': [], 'tracking_uuid': UUID('c63774da-2c52-11e7-bd4c-000c29e41bf4'), 'available_resultset_size': 0, 'limit': 0, 'offset': 0, 'returned_resultset_size': 0})

# Transactions list
client.transactions()
# MutableDictionaryObject({'transactions': [DictionaryObject({'till_number': u'703648', 'payment_id': UUID('d2c29c60-0b1a-11e7-8f7b-061cf2e0e94d'), 'user_id': UUID('8dad2dea-7d7f-4e8b-a61c-53150f1b7452'), 'trans_amount': Decimal('799.23'), 'msisdn': u'254722123456', 'trans_time': datetime.datetime(2016, 5, 29, 21, 30, 52, 739072, tzinfo=tzoffset(None, 10800)), 'names': u'First M Last', 'trans_id': u'2TR46IBB5C'}), DictionaryObject({'till_number': u'703648', 'payment_id': UUID('d2c29c60-0b1a-11e7-8f7b-061cf2e0e94d'), 'user_id': UUID('8dad2dea-7d7f-4e8b-a61c-53150f1b7452'), 'trans_amount': Decimal('581.37'), 'msisdn': u'254722123456', 'trans_time': datetime.datetime(2017, 1, 24, 21, 30, 52, 739243, tzinfo=tzoffset(None, 10800)), 'names': u'First M Last', 'trans_id': u'0OZC02Q1OZ'}), DictionaryObject({'till_number': u'703648', 'payment_id': UUID('d2c29c60-0b1a-11e7-8f7b-061cf2e0e94d'), 'user_id': UUID('8dad2dea-7d7f-4e8b-a61c-53150f1b7452'), 'trans_amount': Decimal('657.56'), 'msisdn': u'254722123456', 'trans_time': datetime.datetime(2017, 1, 31, 21, 30, 52, 739409, tzinfo=tzoffset(None, 10800)), 'names': u'First M Last', 'trans_id': u'3PEYGJ6IVK'}), DictionaryObject({'till_number': u'703648', 'payment_id': UUID('d2c29c60-0b1a-11e7-8f7b-061cf2e0e94d'), 'user_id': UUID('8dad2dea-7d7f-4e8b-a61c-53150f1b7452'), 'trans_amount': Decimal('837.30'), 'msisdn': u'254722123456', 'trans_time': datetime.datetime(2017, 2, 1, 21, 30, 52, 739964, tzinfo=tzoffset(None, 10800)), 'names': u'First M Last', 'trans_id': u'O65UCIF7I6'}), DictionaryObject({'till_number': u'703648', 'payment_id': UUID('d2c29c60-0b1a-11e7-8f7b-061cf2e0e94d'), 'user_id': UUID('8dad2dea-7d7f-4e8b-a61c-53150f1b7452'), 'trans_amount': Decimal('808.16'), 'msisdn': u'254722123456', 'trans_time': datetime.datetime(2017, 2, 15, 21, 30, 52, 740086, tzinfo=tzoffset(None, 10800)), 'names': u'First M Last', 'trans_id': u'ZJZCT31FQE'})], 'tracking_uuid': UUID('93b6845a-2c53-11e7-bf31-000c29e41bf4'), 'available_resultset_size': 5, 'limit': 30, 'offset': 0, 'returned_resultset_size': 5})

Metadata

Release files for niftyclient 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for niftyclient 0.3.0
File Size Uploaded Provenance Actions
niftyclient-0.3.0.tar.gz 7.1 kB Without provenance Details for niftyclient-0.3.0.tar.gz

Release files / niftyclient-0.3.0.tar.gz

Download URL niftyclient-0.3.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
caf194a3a2010546ae700a9874035319d645797f3c8ccb02279d8c0d7d7aa9b0
BLAKE2b-256 checksum
How to use checksums
fbce8638a8fbf1d6d62132504bda75bd10450552ce579dfb407b6daaf1eb88fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.7

Security for niftyclient 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file No provenance

0.2

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page