Kuda
AsyncKuda
Bases: BaseAsyncAPIWrapper
An asynchronous API wrapper to Kuda REST API endpoints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
email |
str
|
The email address of your Kuda account with access to an apiKey |
required |
api_key |
str
|
Your Kuda apiKey |
required |
mode |
Mode
|
The mode you desire to use the wrapper in (development or production) |
Mode.DEVELOPMENT
|
Source code in pykuda2/kuda.py
Kuda
Bases: BaseAPIWrapper
A synchronous API wrapper to Kuda REST API endpoints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
email |
str
|
The email address of your Kuda account with access to an apiKey |
required |
api_key |
str
|
Your Kuda apiKey |
required |
mode |
Mode
|
The mode you desire to use the wrapper in (development or production) |
Mode.DEVELOPMENT
|
Source code in pykuda2/kuda.py
Attributes on the Kuda
and AsyncKuda
classes
The wrapper classes Kuda
and AsyncKuda
classes have methods bounded to them that provides methods that lets you
interact with Kuda. Here's a comprehensive list of those attributes.
Attribute | Description | Example |
---|---|---|
accounts |
Provides methods that let's you interact with Kuda's Account API | kuda.accounts.get_admin_account_balance() |
transactions |
Provides methods that let's you interact with Kuda's Account Transactions API | kuda.transactions.get_banks() |
billing_and_betting |
Provided methods that let's you interact with Kuda's Bill Payments & Betting Services | kuda.billing_and_betting.get_purchased_bills() |
gift_cards |
Provides methods that let's you interact with Kuda's Gift Cards API | kuda.gift_cards.get_gift_cards() |
savings |
Provides methods that let's you interact with Kuda's Savings API | kuda.savings.get_fixed_savings_account(tracking_reference="12343443435") |
cards |
Provides methods that let's you interact with Kuda's Cards API | kuda.cards.get_cards(tracking_reference="24232244") |
Using a class attribute on the Kuda class to interact with Kuda
import os
from pykuda2 import Kuda
KUDA_EMAIL_ADDRESS = os.getenv("KUDA_EMAIL_ADDRESS")
KUDA_API_KEY = os.getenv("KUDA_API_KEY")
# You instantiate the wrapper classes
kuda = Kuda(email=KUDA_EMAIL_ADDRESS, api_key=KUDA_API_KEY)
# calling a method by accessing the attributes on `kuda`
response = kuda.accounts.get_admin_account_balance()
print(response)
What the async equivalent might look like
import asyncio
import os
from pykuda2 import AsyncKuda
KUDA_EMAIL_ADDRESS = os.getenv("KUDA_EMAIL_ADDRESS")
KUDA_API_KEY = os.getenv("KUDA_API_KEY")
# You instantiate the wrapper classes
async_kuda = AsyncKuda(email=KUDA_EMAIL_ADDRESS, api_key=KUDA_API_KEY)
# The bounded attributes have the same name for the async equivalent of the `Kuda` wrapper
async def print_admin_balance():
print(await async_kuda.accounts.get_admin_account_balance())
coroutines = asyncio.gather(print_admin_balance())
loop = asyncio.get_event_loop()
loop.run_until_complete(coroutines)