diff --git a/luno_python/client.py b/luno_python/client.py
index 7bae86b..4879ab8 100644
--- a/luno_python/client.py
+++ b/luno_python/client.py
@@ -1,5 +1,3 @@
-"""Luno API client implementation."""
-
from .base_client import BaseClient
@@ -15,15 +13,15 @@ class Client(BaseClient):
c = Client(api_key_id='key_id', api_key_secret='key_secret')
try:
res = c.get_ticker(pair='XBTZAR')
- print(res)
+ print res
except Exception as e:
- print(e)
+ print e
"""
def cancel_withdrawal(self, id):
- """Make a call to DELETE /api/1/withdrawals/{id}.
+ """Makes a call to DELETE /api/1/withdrawals/{id}.
- Cancel a withdrawal request.
+ Cancels a withdrawal request.
This can only be done if the request is still in state PENDING.
Permissions required: Perm_W_Withdrawals
@@ -32,38 +30,64 @@ def cancel_withdrawal(self, id):
:type id: int
"""
req = {
- "id": id,
+ 'id': id,
+ }
+ return self.do('DELETE', '/api/1/withdrawals/{id}', req=req, auth=True)
+
+ def convert(self, amount, idempotency_key, source_account_id, target_account_id):
+ """Makes a call to POST /api/exchange/1/convert.
+
+ Instantly convert between two currencies. Only conversions between ZAR and ZARU are supported. Conversions will be done at a 1:1 rate.
+
+ Permissions required: MP_Transfers
+
+ :param amount: Amount to convert from the source account. Must be positive.
+ :type amount: float
+ :param idempotency_key: A unique key to prevent duplicate conversions. If a conversion with the same key
+ already exists and completed successfully, the original result is returned.
+ Use a new key to retry a failed conversion.
+ :type idempotency_key: str
+ :param source_account_id: The account to convert funds from.
+ :type source_account_id: int
+ :param target_account_id: The account to receive the converted funds.
+ :type target_account_id: int
+ """
+ req = {
+ 'amount': amount,
+ 'idempotency_key': idempotency_key,
+ 'source_account_id': source_account_id,
+ 'target_account_id': target_account_id,
}
- return self.do("DELETE", "/api/1/withdrawals/{id}", req=req, auth=True)
+ return self.do('POST', '/api/exchange/1/convert', req=req, auth=True)
- def create_account(self, currency, name):
- """Make a call to POST /api/1/accounts.
+ def create_account(self, currency, name, account_type=None):
+ """Makes a call to POST /api/1/accounts.
- This request creates an Account for the specified currency. Please note that the balances for the Account will
- be displayed based on the asset value, which is the currency the Account is based on.
+ This request creates an Account for the specified currency. Please note that the balances for the Account will be displayed based on the asset value, which is the currency the Account is based on.
Permissions required: Perm_W_Addresses
- :param currency: The currency code for the Account you want to create. Please see the Currency section for a
- detailed list of currencies supported by the Luno platform.
+ :param currency: The currency code for the Account you want to create. Please see the Currency section for a detailed list of currencies supported by the Luno platform.
- Users must be verified to trade currency in order to be able to create an Account. For more
- information on the verification process, please see
- How do I verify my identity?.
+ Users must be verified to trade currency in order to be able to create an Account. For more information on the verification process, please see How do I verify my identity?.
Users have a limit of 10 accounts per currency.
:type currency: str
:param name: The label to use for this account
:type name: str
+ :param account_type: The type to use for this account (if not provided, defaults to
+ TRANSACTIONAL).
+ :type account_type: str
"""
req = {
- "currency": currency,
- "name": name,
+ 'currency': currency,
+ 'name': name,
+ 'account_type': account_type,
}
- return self.do("POST", "/api/1/accounts", req=req, auth=True)
+ return self.do('POST', '/api/1/accounts', req=req, auth=True)
def create_beneficiary(self, account_type, bank_account_number, bank_name, bank_recipient):
- """Make a call to POST /api/1/beneficiaries.
+ """Makes a call to POST /api/1/beneficiaries.
Create a new beneficiary.
@@ -79,17 +103,17 @@ def create_beneficiary(self, account_type, bank_account_number, bank_name, bank_
:type bank_recipient: str
"""
req = {
- "account_type": account_type,
- "bank_account_number": bank_account_number,
- "bank_name": bank_name,
- "bank_recipient": bank_recipient,
+ 'account_type': account_type,
+ 'bank_account_number': bank_account_number,
+ 'bank_name': bank_name,
+ 'bank_recipient': bank_recipient,
}
- return self.do("POST", "/api/1/beneficiaries", req=req, auth=True)
+ return self.do('POST', '/api/1/beneficiaries', req=req, auth=True)
- def create_funding_address(self, asset, account_id=None, name=None):
- """Make a call to POST /api/1/funding_address.
+ def create_funding_address(self, asset, account_id=None, name=None, network=None):
+ """Makes a call to POST /api/1/funding_address.
- Allocate a new receive address to your account. There is a rate limit of 1
+ Allocates a new receive address to your account. There is a rate limit of 1
address per hour, but bursts of up to 10 addresses are allowed. Only 1
Ethereum receive address can be created.
@@ -97,22 +121,25 @@ def create_funding_address(self, asset, account_id=None, name=None):
:param asset: Currency code of the asset.
:type asset: str
- :param account_id: An optional account_id to assign the new Receive Address too
+ :param account_id: An optional account_id to assign the new Receive Address to. If omitted, Receive Address will be assigned to the default account.
:type account_id: int
:param name: An optional name for the new Receive Address
:type name: str
+ :param network: The blockchain network to use for the transaction. If none is provided the default network is used
+ :type network: int
"""
req = {
- "asset": asset,
- "account_id": account_id,
- "name": name,
+ 'asset': asset,
+ 'account_id': account_id,
+ 'name': name,
+ 'network': network,
}
- return self.do("POST", "/api/1/funding_address", req=req, auth=True)
+ return self.do('POST', '/api/1/funding_address', req=req, auth=True)
- def create_withdrawal(self, amount, type, beneficiary_id=None, external_id=None, fast=None, reference=None):
- """Make a call to POST /api/1/withdrawals.
+ def create_withdrawal(self, amount, type, beneficiary_id=None, external_id=None, fast=None, reference=None, source_account_id=None):
+ """Makes a call to POST /api/1/withdrawals.
- Create a new withdrawal request to the specified beneficiary.
+ Creates a new withdrawal request to the specified beneficiary.
Permissions required: Perm_W_Withdrawals
@@ -122,35 +149,37 @@ def create_withdrawal(self, amount, type, beneficiary_id=None, external_id=None,
:type type: str
:param beneficiary_id: The beneficiary ID of the bank account the withdrawal will be paid out to.
This parameter is required if the user has set up multiple beneficiaries.
- The beneficiary ID can be found by selecting on the beneficiary name on the user's
- Beneficiaries page.
+ The beneficiary ID can be found by selecting on the beneficiary name on the user’s Beneficiaries page.
:type beneficiary_id: int
:param external_id: Optional unique ID to associate with this withdrawal.
Useful to prevent duplicate sends.
This field supports all alphanumeric characters including "-" and "_".
:type external_id: str
:param fast: If true, it will be a fast withdrawal if possible. Fast withdrawals come with a fee.
- Currently fast withdrawals are only available for `type=ZAR_EFT`; for other types, an error is
- returned. Fast withdrawals are not possible for Bank of Baroda, Deutsche Bank, Merrill Lynch South
- Africa, UBS, Postbank and Tyme Bank.
+ Currently fast withdrawals are only available for `type=ZAR_EFT`; for other types, an error is returned.
+ Fast withdrawals are not possible for Bank of Baroda, Deutsche Bank, Merrill Lynch South Africa, UBS, Postbank and Tyme Bank.
The fee to be charged is the same as when withdrawing from the UI.
:type fast: bool
:param reference: For internal use.
Deprecated: We don't allow custom references and will remove this soon.
:type reference: str
+ :param source_account_id: Optional source account ID representing the account from which the Withdrawal will be made,
+ fall back to the default account if not provided.
+ :type source_account_id: int
"""
req = {
- "amount": amount,
- "type": type,
- "beneficiary_id": beneficiary_id,
- "external_id": external_id,
- "fast": fast,
- "reference": reference,
+ 'amount': amount,
+ 'type': type,
+ 'beneficiary_id': beneficiary_id,
+ 'external_id': external_id,
+ 'fast': fast,
+ 'reference': reference,
+ 'source_account_id': source_account_id,
}
- return self.do("POST", "/api/1/withdrawals", req=req, auth=True)
+ return self.do('POST', '/api/1/withdrawals', req=req, auth=True)
def delete_beneficiary(self, id):
- """Make a call to DELETE /api/1/beneficiaries/{id}.
+ """Makes a call to DELETE /api/1/beneficiaries/{id}.
Delete a beneficiary
@@ -160,17 +189,21 @@ def delete_beneficiary(self, id):
:type id: int
"""
req = {
- "id": id,
+ 'id': id,
}
- return self.do("DELETE", "/api/1/beneficiaries/{id}", req=req, auth=True)
+ return self.do('DELETE', '/api/1/beneficiaries/{id}', req=req, auth=True)
- def get_balances(self, assets=None, account_id=None):
- """Make a call to GET /api/1/balance.
+ def get_balances(self, account_type=None, assets=None, account_id=None):
+ """Makes a call to GET /api/1/balance.
The list of all Accounts and their respective balances for the requesting user.
Permissions required: Perm_R_Balance
+ :param account_type: Only return balances for wallets of these types (if not provided, all
+ account types are returned). To filter by multiple types, pass the
+ parameter multiple times, e.g. `account_type=SPOT&account_type=SPOT_MARGIN`.
+ :type account_type: list
:param assets: Only return balances for wallets with these currencies (if not provided,
all balances will be returned). To request balances for multiple currencies,
pass the parameter multiple times,
@@ -181,15 +214,16 @@ def get_balances(self, assets=None, account_id=None):
:type account_id: str
"""
req = {
- "assets": assets,
+ 'account_type': account_type,
+ 'assets': assets,
}
- response = self.do("GET", "/api/1/balance", req=req, auth=True)
+ response = self.do('GET', '/api/1/balance', req=req, auth=True)
# If account_id is specified, filter to return only that account
if account_id is not None:
- if "balance" in response:
- for account in response["balance"]:
- if str(account.get("account_id")) == str(account_id):
+ if 'balance' in response:
+ for account in response['balance']:
+ if str(account.get('account_id')) == str(account_id):
return account
# If account_id not found, return None
return None
@@ -198,7 +232,7 @@ def get_balances(self, assets=None, account_id=None):
return response
def get_candles(self, duration, pair, since):
- """Make a call to GET /api/exchange/1/candles.
+ """Makes a call to GET /api/exchange/1/candles.
Get candlestick market data from the specified time until now, from the oldest to the most recent.
@@ -217,17 +251,16 @@ def get_candles(self, duration, pair, since):
:type since: int
"""
req = {
- "duration": duration,
- "pair": pair,
- "since": since,
+ 'duration': duration,
+ 'pair': pair,
+ 'since': since,
}
- return self.do("GET", "/api/exchange/1/candles", req=req, auth=True)
+ return self.do('GET', '/api/exchange/1/candles', req=req, auth=True)
def get_fee_info(self, pair):
- """Make a call to GET /api/1/fee_info.
+ """Makes a call to GET /api/1/fee_info.
- Return the fees and 30 day trading volume (as of midnight) for a given currency pair. For complete details,
- please see Fees & Features.
+ Returns the fees and 30 day trading volume (as of midnight) for a given currency pair. For complete details, please see Fees & Features.
Permissions required: Perm_R_Orders
@@ -235,18 +268,17 @@ def get_fee_info(self, pair):
:type pair: str
"""
req = {
- "pair": pair,
+ 'pair': pair,
}
- return self.do("GET", "/api/1/fee_info", req=req, auth=True)
+ return self.do('GET', '/api/1/fee_info', req=req, auth=True)
- def get_funding_address(self, asset, address=None):
- """Make a call to GET /api/1/funding_address.
+ def get_funding_address(self, asset, address=None, network=None):
+ """Makes a call to GET /api/1/funding_address.
- Return the default receive address associated with your account and the
- amount received via the address. Users can specify an optional address parameter to return information for a
- non-default receive address.
- In the response, total_received is the total confirmed amount received excluding unconfirmed
- transactions. total_unconfirmed is the total sum of unconfirmed receive transactions.
+ Returns the default receive address associated with your account and the
+ amount received via the address. Users can specify an optional address parameter to return information for a non-default receive address.
+ In the response, total_received is the total confirmed amount received excluding unconfirmed transactions.
+ total_unconfirmed is the total sum of unconfirmed receive transactions.
Permissions required: Perm_R_Addresses
@@ -255,15 +287,18 @@ def get_funding_address(self, asset, address=None):
:param address: Specific cryptocurrency address to retrieve. If not provided, the
default address will be used.
:type address: str
+ :param network: The blockchain network to use for the transaction. If none is provided the default network is used
+ :type network: int
"""
req = {
- "asset": asset,
- "address": address,
+ 'asset': asset,
+ 'address': address,
+ 'network': network,
}
- return self.do("GET", "/api/1/funding_address", req=req, auth=True)
+ return self.do('GET', '/api/1/funding_address', req=req, auth=True)
def get_move(self, client_move_id=None, id=None):
- """Make a call to GET /api/exchange/1/move.
+ """Makes a call to GET /api/exchange/1/move.
Get a specific move funds instruction by either id or
client_move_id. If both are provided an API error will be
@@ -271,21 +306,21 @@ def get_move(self, client_move_id=None, id=None):
Permissions required: MP_None
- :param client_move_id: Get by the user defined ID. This is mutually exclusive with id and is
- required if id is not provided.
+ :param client_move_id: Get by the user defined ID. This is mutually exclusive with id and is required if id is
+ not provided.
:type client_move_id: str
:param id: Get by the system ID. This is mutually exclusive with client_move_id and is required if
client_move_id is not provided.
:type id: str
"""
req = {
- "client_move_id": client_move_id,
- "id": id,
+ 'client_move_id': client_move_id,
+ 'id': id,
}
- return self.do("GET", "/api/exchange/1/move", req=req, auth=True)
+ return self.do('GET', '/api/exchange/1/move', req=req, auth=True)
def get_order(self, id):
- """Make a call to GET /api/1/orders/{id}.
+ """Makes a call to GET /api/1/orders/{id}.
Get an Order's details by its ID.
@@ -295,12 +330,12 @@ def get_order(self, id):
:type id: str
"""
req = {
- "id": id,
+ 'id': id,
}
- return self.do("GET", "/api/1/orders/{id}", req=req, auth=True)
+ return self.do('GET', '/api/1/orders/{id}', req=req, auth=True)
def get_order_book(self, pair):
- """Make a call to GET /api/1/orderbook_top.
+ """Makes a call to GET /api/1/orderbook_top.
This request returns the best 100 `bids` and `asks`, for the currency pair specified, in the Order Book.
@@ -312,12 +347,12 @@ def get_order_book(self, pair):
:type pair: str
"""
req = {
- "pair": pair,
+ 'pair': pair,
}
- return self.do("GET", "/api/1/orderbook_top", req=req, auth=False)
+ return self.do('GET', '/api/1/orderbook_top', req=req, auth=False)
def get_order_book_full(self, pair):
- """Make a call to GET /api/1/orderbook.
+ """Makes a call to GET /api/1/orderbook.
This request returns all `bids` and `asks`, for the currency pair specified, in the Order Book.
@@ -333,12 +368,12 @@ def get_order_book_full(self, pair):
:type pair: str
"""
req = {
- "pair": pair,
+ 'pair': pair,
}
- return self.do("GET", "/api/1/orderbook", req=req, auth=False)
+ return self.do('GET', '/api/1/orderbook', req=req, auth=False)
def get_order_v2(self, id):
- """Make a call to GET /api/exchange/2/orders/{id}.
+ """Makes a call to GET /api/exchange/2/orders/{id}.
Get the details for an order.
@@ -348,12 +383,12 @@ def get_order_v2(self, id):
:type id: str
"""
req = {
- "id": id,
+ 'id': id,
}
- return self.do("GET", "/api/exchange/2/orders/{id}", req=req, auth=True)
+ return self.do('GET', '/api/exchange/2/orders/{id}', req=req, auth=True)
def get_order_v3(self, client_order_id=None, id=None):
- """Make a call to GET /api/exchange/3/order.
+ """Makes a call to GET /api/exchange/3/order.
Get the details for an order by order reference or client order ID.
Exactly one of the two parameters must be provided, otherwise an error is returned.
@@ -365,15 +400,15 @@ def get_order_v3(self, client_order_id=None, id=None):
:type id: str
"""
req = {
- "client_order_id": client_order_id,
- "id": id,
+ 'client_order_id': client_order_id,
+ 'id': id,
}
- return self.do("GET", "/api/exchange/3/order", req=req, auth=True)
+ return self.do('GET', '/api/exchange/3/order', req=req, auth=True)
def get_ticker(self, pair):
- """Make a call to GET /api/1/ticker.
+ """Makes a call to GET /api/1/ticker.
- Return the latest ticker indicators for the specified currency pair.
+ Returns the latest ticker indicators for the specified currency pair.
Please see the Currency list for the complete list of supported currency pairs.
@@ -381,14 +416,14 @@ def get_ticker(self, pair):
:type pair: str
"""
req = {
- "pair": pair,
+ 'pair': pair,
}
- return self.do("GET", "/api/1/ticker", req=req, auth=False)
+ return self.do('GET', '/api/1/ticker', req=req, auth=False)
def get_tickers(self, pair=None):
- """Make a call to GET /api/1/tickers.
+ """Makes a call to GET /api/1/tickers.
- Return the latest ticker indicators from all active Luno exchanges.
+ Returns the latest ticker indicators from all active Luno exchanges.
Please see the Currency list for the complete list of supported currency pairs.
@@ -398,14 +433,14 @@ def get_tickers(self, pair=None):
:type pair: list
"""
req = {
- "pair": pair,
+ 'pair': pair,
}
- return self.do("GET", "/api/1/tickers", req=req, auth=False)
+ return self.do('GET', '/api/1/tickers', req=req, auth=False)
def get_withdrawal(self, id):
- """Make a call to GET /api/1/withdrawals/{id}.
+ """Makes a call to GET /api/1/withdrawals/{id}.
- Return the status of a particular withdrawal request.
+ Returns the status of a particular withdrawal request.
Permissions required: Perm_R_Withdrawals
@@ -413,28 +448,45 @@ def get_withdrawal(self, id):
:type id: int
"""
req = {
- "id": id,
+ 'id': id,
+ }
+ return self.do('GET', '/api/1/withdrawals/{id}', req=req, auth=True)
+
+ def linked_users(self, limit=None, offset=None):
+ """Makes a call to GET /api/1/users/linked.
+
+ Returns a list of users linked to this API key with additional permissions.
+
+ :param limit: Limit to this many users.
+ :type limit: int
+ :param offset: Page through records
+ :type offset: int
+ """
+ req = {
+ 'limit': limit,
+ 'offset': offset,
}
- return self.do("GET", "/api/1/withdrawals/{id}", req=req, auth=True)
+ return self.do('GET', '/api/1/users/linked', req=req, auth=False)
def list_beneficiaries(self, bank_recipient=None):
- """Make a call to GET /api/1/beneficiaries.
+ """Makes a call to GET /api/1/beneficiaries.
- Return a list of bank beneficiaries.
+ Returns a list of bank beneficiaries.
Permissions required: Perm_R_Beneficiaries
- :param bank_recipient: :type bank_recipient: str
+ :param bank_recipient: Bank Recipient name of the beneficiary. The wildcard character * can be used. Example: John* or *Smith or *John*
+ :type bank_recipient: str
"""
req = {
- "bank_recipient": bank_recipient,
+ 'bank_recipient': bank_recipient,
}
- return self.do("GET", "/api/1/beneficiaries", req=req, auth=True)
+ return self.do('GET', '/api/1/beneficiaries', req=req, auth=True)
def list_moves(self, before=None, limit=None):
- """Make a call to GET /api/exchange/1/move/list_moves.
+ """Makes a call to GET /api/exchange/1/move/list_moves.
- Return a list of the most recent moves ordered from newest to oldest.
+ Returns a list of the most recent moves ordered from newest to oldest.
This endpoint will list up to 100 most recent moves by default.
Permissions required: MP_None
@@ -445,15 +497,15 @@ def list_moves(self, before=None, limit=None):
:type limit: int
"""
req = {
- "before": before,
- "limit": limit,
+ 'before': before,
+ 'limit': limit,
}
- return self.do("GET", "/api/exchange/1/move/list_moves", req=req, auth=True)
+ return self.do('GET', '/api/exchange/1/move/list_moves', req=req, auth=True)
- def list_orders(self, created_before=None, limit=None, pair=None, state=None):
- """Make a call to GET /api/1/listorders.
+ def list_orders(self, created_before=None, limit=None, margin_only=None, pair=None, state=None):
+ """Makes a call to GET /api/1/listorders.
- Return a list of the most recently placed Orders.
+ Returns a list of the most recently placed Orders.
Users can specify an optional state=PENDING parameter to restrict the results to only open Orders.
Users can also specify the market by using the optional currency pair parameter.
@@ -463,23 +515,26 @@ def list_orders(self, created_before=None, limit=None, pair=None, state=None):
:type created_before: int
:param limit: Limit to this many orders
:type limit: int
+ :param margin_only: Filter to only orders placed using spot margin wallets.
+ :type margin_only: bool
:param pair: Filter to only orders of this currency pair
:type pair: str
:param state: Filter to only orders of this state
:type state: str
"""
req = {
- "created_before": created_before,
- "limit": limit,
- "pair": pair,
- "state": state,
+ 'created_before': created_before,
+ 'limit': limit,
+ 'margin_only': margin_only,
+ 'pair': pair,
+ 'state': state,
}
- return self.do("GET", "/api/1/listorders", req=req, auth=True)
+ return self.do('GET', '/api/1/listorders', req=req, auth=True)
- def list_orders_v2(self, closed=None, created_before=None, limit=None, pair=None):
- """Make a call to GET /api/exchange/2/listorders.
+ def list_orders_v2(self, closed=None, created_before=None, limit=None, pair=None, settlement_currency=None):
+ """Makes a call to GET /api/exchange/2/listorders.
- Return a list of the most recently placed orders ordered from newest to
+ Returns a list of the most recently placed orders ordered from newest to
oldest. This endpoint will list up to 100 most recent open orders by
default.
@@ -495,17 +550,22 @@ def list_orders_v2(self, closed=None, created_before=None, limit=None, pair=None
:type limit: int
:param pair: Filter to only orders of this currency pair.
:type pair: str
+ :param settlement_currency: Filter to only orders that settle in this currency.
+
+ Orders placed before the settlement currency was recorded are excluded, even if they settled in this currency.
+ :type settlement_currency: str
"""
req = {
- "closed": closed,
- "created_before": created_before,
- "limit": limit,
- "pair": pair,
+ 'closed': closed,
+ 'created_before': created_before,
+ 'limit': limit,
+ 'pair': pair,
+ 'settlement_currency': settlement_currency,
}
- return self.do("GET", "/api/exchange/2/listorders", req=req, auth=True)
+ return self.do('GET', '/api/exchange/2/listorders', req=req, auth=True)
def list_pending_transactions(self, id):
- """Make a call to GET /api/1/accounts/{id}/pending.
+ """Makes a call to GET /api/1/accounts/{id}/pending.
Return a list of all transactions that have not completed for the Account.
@@ -517,14 +577,14 @@ def list_pending_transactions(self, id):
:type id: int
"""
req = {
- "id": id,
+ 'id': id,
}
- return self.do("GET", "/api/1/accounts/{id}/pending", req=req, auth=True)
+ return self.do('GET', '/api/1/accounts/{id}/pending', req=req, auth=True)
def list_trades(self, pair, since=None):
- """Make a call to GET /api/1/trades.
+ """Makes a call to GET /api/1/trades.
- Return a list of recent trades for the specified currency pair. At most
+ Returns a list of recent trades for the specified currency pair. At most
100 trades are returned per call and never trades older than 24h. The
trades are sorted from newest to oldest.
@@ -539,13 +599,13 @@ def list_trades(self, pair, since=None):
:type since: int
"""
req = {
- "pair": pair,
- "since": since,
+ 'pair': pair,
+ 'since': since,
}
- return self.do("GET", "/api/1/trades", req=req, auth=False)
+ return self.do('GET', '/api/1/trades', req=req, auth=False)
def list_transactions(self, id, max_row, min_row):
- """Make a call to GET /api/1/accounts/{id}/transactions.
+ """Makes a call to GET /api/1/accounts/{id}/transactions.
Return a list of transaction entries from an account.
@@ -568,16 +628,16 @@ def list_transactions(self, id, max_row, min_row):
:type min_row: int
"""
req = {
- "id": id,
- "max_row": max_row,
- "min_row": min_row,
+ 'id': id,
+ 'max_row': max_row,
+ 'min_row': min_row,
}
- return self.do("GET", "/api/1/accounts/{id}/transactions", req=req, auth=True)
+ return self.do('GET', '/api/1/accounts/{id}/transactions', req=req, auth=True)
def list_transfers(self, account_id, before=None, limit=None):
- """Make a call to GET /api/exchange/1/transfers.
+ """Makes a call to GET /api/exchange/1/transfers.
- Return a list of the most recent confirmed transfers ordered from newest to
+ Returns a list of the most recent confirmed transfers ordered from newest to
oldest.
This includes bank transfers, card payments, or on-chain transactions that
have been reflected on your account available balance.
@@ -601,32 +661,22 @@ def list_transfers(self, account_id, before=None, limit=None):
:type limit: int
"""
req = {
- "account_id": account_id,
- "before": before,
- "limit": limit,
+ 'account_id': account_id,
+ 'before': before,
+ 'limit': limit,
}
- return self.do("GET", "/api/exchange/1/transfers", req=req, auth=True)
-
- def list_user_trades(
- self,
- pair,
- after_seq=None,
- before=None,
- before_seq=None,
- limit=None,
- since=None,
- sort_desc=None,
- ):
- """Make a call to GET /api/1/listtrades.
-
- Return a list of the recent Trades for a given currency pair for this user, sorted by oldest first.
+ return self.do('GET', '/api/exchange/1/transfers', req=req, auth=True)
+
+ def list_user_trades(self, pair, after_seq=None, before=None, before_seq=None, limit=None, since=None, sort_desc=None):
+ """Makes a call to GET /api/1/listtrades.
+
+ Returns a list of the recent Trades for a given currency pair for this user, sorted by oldest first.
If before is specified, then Trades are returned sorted by most-recent first.
type in the response indicates the type of Order that was placed to participate in the trade.
Possible types: BID, ASK.
- If is_buy in the response is true, then the Order which completed the trade (market taker) was a
- Bid Order.
+ If is_buy in the response is true, then the Order which completed the trade (market taker) was a Bid Order.
Results of this query may lag behind the latest data.
@@ -651,20 +701,20 @@ def list_user_trades(
:type sort_desc: bool
"""
req = {
- "pair": pair,
- "after_seq": after_seq,
- "before": before,
- "before_seq": before_seq,
- "limit": limit,
- "since": since,
- "sort_desc": sort_desc,
+ 'pair': pair,
+ 'after_seq': after_seq,
+ 'before': before,
+ 'before_seq': before_seq,
+ 'limit': limit,
+ 'since': since,
+ 'sort_desc': sort_desc,
}
- return self.do("GET", "/api/1/listtrades", req=req, auth=True)
+ return self.do('GET', '/api/1/listtrades', req=req, auth=True)
def list_withdrawals(self, before_id=None, limit=None):
- """Make a call to GET /api/1/withdrawals.
+ """Makes a call to GET /api/1/withdrawals.
- Return a list of withdrawal requests.
+ Returns a list of withdrawal requests.
Permissions required: Perm_R_Withdrawals
@@ -675,13 +725,13 @@ def list_withdrawals(self, before_id=None, limit=None):
:type limit: int
"""
req = {
- "before_id": before_id,
- "limit": limit,
+ 'before_id': before_id,
+ 'limit': limit,
}
- return self.do("GET", "/api/1/withdrawals", req=req, auth=True)
+ return self.do('GET', '/api/1/withdrawals', req=req, auth=True)
def markets(self, pair=None):
- """Make a call to GET /api/exchange/1/markets.
+ """Makes a call to GET /api/exchange/1/markets.
List all supported markets parameter information like price scale, min and
max order volumes and market ID.
@@ -690,12 +740,12 @@ def markets(self, pair=None):
:type pair: list
"""
req = {
- "pair": pair,
+ 'pair': pair,
}
- return self.do("GET", "/api/exchange/1/markets", req=req, auth=False)
+ return self.do('GET', '/api/exchange/1/markets', req=req, auth=False)
def move(self, amount, credit_account_id, debit_account_id, client_move_id=None):
- """Make a call to POST /api/exchange/1/move.
+ """Makes a call to POST /api/exchange/1/move.
Move funds between two of your transactional accounts with the same currency
The funds may not be moved by the time the request returns. The GET method
@@ -712,39 +762,22 @@ def move(self, amount, credit_account_id, debit_account_id, client_move_id=None)
:param debit_account_id: The account to debit the funds from.
:type debit_account_id: int
:param client_move_id: Client move ID.
- May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -).
- Maximum length: 255. It will be available in read endpoints, so you can use it to avoid
- duplicate moves between the same accounts. Values must be unique across all your
- successful calls of this endpoint; trying to create a move request with the same
- `client_move_id` as one of your past move requests will result in a HTTP 409 Conflict
- response.
+ May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -). Maximum length: 255.
+ It will be available in read endpoints, so you can use it to avoid duplicate moves between the same accounts.
+ Values must be unique across all your successful calls of this endpoint; trying to create a move request
+ with the same `client_move_id` as one of your past move requests will result in a HTTP 409 Conflict response.
:type client_move_id: str
"""
req = {
- "amount": amount,
- "credit_account_id": credit_account_id,
- "debit_account_id": debit_account_id,
- "client_move_id": client_move_id,
+ 'amount': amount,
+ 'credit_account_id': credit_account_id,
+ 'debit_account_id': debit_account_id,
+ 'client_move_id': client_move_id,
}
- return self.do("POST", "/api/exchange/1/move", req=req, auth=True)
-
- def post_limit_order(
- self,
- pair,
- price,
- type,
- volume,
- base_account_id=None,
- client_order_id=None,
- counter_account_id=None,
- post_only=None,
- stop_direction=None,
- stop_price=None,
- time_in_force=None,
- timestamp=None,
- ttl=None,
- ):
- """Make a call to POST /api/1/postorder.
+ return self.do('POST', '/api/exchange/1/move', req=req, auth=True)
+
+ def post_limit_order(self, pair, price, type, volume, base_account_id=None, client_order_id=None, counter_account_id=None, post_only=None, settlement_currency=None, stop_direction=None, stop_price=None, time_in_force=None, timestamp=None, ttl=None):
+ """Makes a call to POST /api/1/postorder.
Warning! Orders cannot be reversed once they have executed.
Please ensure your program has been thoroughly tested before submitting Orders.
@@ -753,6 +786,9 @@ def post_limit_order(
your default base currency or counter currency account will be used.
You can find your Account IDs by calling the Balances API.
+ For a pair that settles in more than one asset, set settlement_currency to choose the counter asset
+ of the default account. If you also set counter_account_id, that account must be in this asset.
+
Permissions required: Perm_W_Orders
:param pair: The currency pair to trade.
@@ -767,38 +803,38 @@ def post_limit_order(
:param base_account_id: The base currency Account to use in the trade.
:type base_account_id: int
:param client_order_id: Client order ID.
- May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -).
- Maximum length: 255. It will be available in read endpoints, so you can use it to
- reconcile Luno with your internal system. Values must be unique across all your
- successful order creation endpoint calls; trying to create an order with the same
- `client_order_id` as one of your past orders will result in a HTTP 409 Conflict
- response.
+ May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -). Maximum length: 100.
+ It will be available in read endpoints, so you can use it to reconcile Luno with your internal system.
+ Values must be unique across all your successful order creation endpoint calls; trying to create an order
+ with the same `client_order_id` as one of your past orders will result in a HTTP 409 Conflict response.
:type client_order_id: str
:param counter_account_id: The counter currency Account to use in the trade.
:type counter_account_id: int
- :param post_only: Post-only Orders will be cancelled if they would otherwise have traded immediately.
+ :param post_only: Post-only Orders will be cancelled if they would otherwise have traded
+ immediately.
For example, if there's a bid at ZAR 100,000 and you place a post-only ask at ZAR 100,000,
your order will be cancelled instead of trading.
If the best bid is ZAR 100,000 and you place a post-only ask at ZAR 101,000,
your order won't trade but will go into the order book.
:type post_only: bool
- :param stop_direction: Side of the trigger price to activate the order. This should be set if `stop_price` is
- also set.
-
- `RELATIVE_LAST_TRADE` will automatically infer the direction based on the last trade
- price and the stop price. If last trade price is less than stop price then stop direction
- is ABOVE otherwise is BELOW.
+ :param settlement_currency: The asset the order settles in, for a pair that settles in more than one asset (for example `ZAR` or `ZARU`).
+ If omitted and no `counter_account_id` is given, the default wallet in the pair's counter currency is used.
+ If `counter_account_id` is also given, that account must be in this asset.
+ :type settlement_currency: str
+ :param stop_direction: Side of the trigger price to activate the order. This should be set if `stop_price` is also
+ set.
+
+ `RELATIVE_LAST_TRADE` will automatically infer the direction based on the last
+ trade price and the stop price. If last trade price is less than stop price then stop
+ direction is ABOVE otherwise is BELOW.
:type stop_direction: str
:param stop_price: Trigger trade price to activate this order as a decimal string. If this
is set then this is treated as a Stop Limit Order and `stop_direction`
is expected to be set too.
:type stop_price: float
- :param time_in_force: GTC Good 'Til Cancelled. The order remains open until it is filled or
- cancelled by the user.
- IOC Immediate Or Cancel. The part of the order that cannot be filled
- immediately will be cancelled. Cannot be post-only.
- FOK Fill Or Kill. If the order cannot be filled immediately and completely it
- will be cancelled before any trade. Cannot be post-only.
+ :param time_in_force: GTC Good 'Til Cancelled. The order remains open until it is filled or cancelled by the user.
+ IOC Immediate Or Cancel. The part of the order that cannot be filled immediately will be cancelled. Cannot be post-only.
+ FOK Fill Or Kill. If the order cannot be filled immediately and completely it will be cancelled before any trade. Cannot be post-only.
:type time_in_force: str
:param timestamp: Unix timestamp in milliseconds of when the request was created and sent.
:type timestamp: int
@@ -807,45 +843,36 @@ def post_limit_order(
:type ttl: int
"""
req = {
- "pair": pair,
- "price": price,
- "type": type,
- "volume": volume,
- "base_account_id": base_account_id,
- "client_order_id": client_order_id,
- "counter_account_id": counter_account_id,
- "post_only": post_only,
- "stop_direction": stop_direction,
- "stop_price": stop_price,
- "time_in_force": time_in_force,
- "timestamp": timestamp,
- "ttl": ttl,
+ 'pair': pair,
+ 'price': price,
+ 'type': type,
+ 'volume': volume,
+ 'base_account_id': base_account_id,
+ 'client_order_id': client_order_id,
+ 'counter_account_id': counter_account_id,
+ 'post_only': post_only,
+ 'settlement_currency': settlement_currency,
+ 'stop_direction': stop_direction,
+ 'stop_price': stop_price,
+ 'time_in_force': time_in_force,
+ 'timestamp': timestamp,
+ 'ttl': ttl,
}
- return self.do("POST", "/api/1/postorder", req=req, auth=True)
-
- def post_market_order(
- self,
- pair,
- type,
- base_account_id=None,
- base_volume=None,
- client_order_id=None,
- counter_account_id=None,
- counter_volume=None,
- timestamp=None,
- ttl=None,
- ):
- """Make a call to POST /api/1/marketorder.
-
- A Market Order executes immediately, and either buys as much of the asset that can be bought for a set amount of
- fiat currency, or sells a set amount of the asset for as much as possible.
+ return self.do('POST', '/api/1/postorder', req=req, auth=True)
+
+ def post_market_order(self, pair, type, base_account_id=None, base_volume=None, client_order_id=None, counter_account_id=None, counter_volume=None, settlement_currency=None, timestamp=None, ttl=None):
+ """Makes a call to POST /api/1/marketorder.
+
+ A Market Order executes immediately, and either buys as much of the asset that can be bought for a set amount of fiat currency, or sells a set amount of the asset for as much as possible.
Warning! Orders cannot be reversed once they have executed.
Please ensure your program has been thoroughly tested before submitting Orders.
- If no base_account_id or counter_account_id are specified, the default base
- currency or counter currency account will be used. Users can find their account IDs by calling the
- Balances request.
+ If no base_account_id or counter_account_id are specified, the default base currency or counter currency account will be used.
+ Users can find their account IDs by calling the Balances request.
+
+ For a pair that settles in more than one asset, set settlement_currency to choose the counter asset
+ of the default account. If you also set counter_account_id, that account must be in this asset.
Permissions required: Perm_W_Orders
@@ -856,22 +883,22 @@ def post_market_order(
:type type: str
:param base_account_id: The base currency account to use in the trade.
:type base_account_id: int
- :param base_volume: For a SELL order: amount of the base currency to use (e.g. how much BTC to sell
- for EUR in the BTC/EUR market)
+ :param base_volume: For a SELL order: amount of the base currency to use (e.g. how much BTC to sell for EUR in the BTC/EUR market)
:type base_volume: float
:param client_order_id: Client order ID.
- May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -).
- Maximum length: 255. It will be available in read endpoints, so you can use it to
- reconcile Luno with your internal system. Values must be unique across all your
- successful order creation endpoint calls; trying to create an order with the same
- `client_order_id` as one of your past orders will result in a HTTP 409 Conflict
- response.
+ May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -). Maximum length: 100.
+ It will be available in read endpoints, so you can use it to reconcile Luno with your internal system.
+ Values must be unique across all your successful order creation endpoint calls; trying to create an order
+ with the same `client_order_id` as one of your past orders will result in a HTTP 409 Conflict response.
:type client_order_id: str
:param counter_account_id: The counter currency account to use in the trade.
:type counter_account_id: int
- :param counter_volume: For a BUY order: amount of the counter currency to use (e.g. how much EUR to
- use to buy BTC in the BTC/EUR market)
+ :param counter_volume: For a BUY order: amount of the counter currency to use (e.g. how much EUR to use to buy BTC in the BTC/EUR market)
:type counter_volume: float
+ :param settlement_currency: The asset the order settles in, for a pair that settles in more than one asset (for example `ZAR` or `ZARU`).
+ If omitted and no `counter_account_id` is given, the default wallet in the pair's counter currency is used.
+ If `counter_account_id` is also given, that account must be in this asset.
+ :type settlement_currency: str
:param timestamp: Unix timestamp in milliseconds of when the request was created and sent.
:type timestamp: int
:param ttl: Specifies the number of milliseconds after timestamp the request is valid for.
@@ -879,38 +906,23 @@ def post_market_order(
:type ttl: int
"""
req = {
- "pair": pair,
- "type": type,
- "base_account_id": base_account_id,
- "base_volume": base_volume,
- "client_order_id": client_order_id,
- "counter_account_id": counter_account_id,
- "counter_volume": counter_volume,
- "timestamp": timestamp,
- "ttl": ttl,
+ 'pair': pair,
+ 'type': type,
+ 'base_account_id': base_account_id,
+ 'base_volume': base_volume,
+ 'client_order_id': client_order_id,
+ 'counter_account_id': counter_account_id,
+ 'counter_volume': counter_volume,
+ 'settlement_currency': settlement_currency,
+ 'timestamp': timestamp,
+ 'ttl': ttl,
}
- return self.do("POST", "/api/1/marketorder", req=req, auth=True)
-
- def send(
- self,
- address,
- amount,
- currency,
- account_id=None,
- description=None,
- destination_tag=None,
- external_id=None,
- forex_notice_self_declaration=None,
- has_destination_tag=None,
- is_drb=None,
- is_forex_send=None,
- memo=None,
- message=None,
- ):
- """Make a call to POST /api/1/send.
-
- Send assets from an Account. Please note that the asset type sent must match the receive address of the same
- cryptocurrency of the same type - Bitcoin to Bitcoin, Ethereum to Ethereum, etc.
+ return self.do('POST', '/api/1/marketorder', req=req, auth=True)
+
+ def send(self, address, amount, currency, account_id=None, description=None, destination_tag=None, external_id=None, forex_notice_self_declaration=None, has_destination_tag=None, is_drb=None, is_forex_send=None, memo=None, message=None, network=None):
+ """Makes a call to POST /api/1/send.
+
+ Send assets from an Account. Please note that the asset type sent must match the receive address of the same cryptocurrency of the same type - Bitcoin to Bitcoin, Ethereum to Ethereum, etc.
Sends can be made to cryptocurrency receive addresses.
@@ -923,8 +935,7 @@ def send(
Note:
MP_None
+
+ :param currency: Currency to send
+ :type currency: str
+ """
+ req = {
+ 'currency': currency,
}
- return self.do("GET", "/api/1/send_fee", req=req, auth=True)
+ return self.do('GET', '/api/1/send/networks', req=req, auth=True)
def stop_order(self, order_id):
- """Make a call to POST /api/1/stoporder.
+ """Makes a call to POST /api/1/stoporder.
Request to cancel an Order.
@@ -1027,12 +1047,12 @@ def stop_order(self, order_id):
:type order_id: str
"""
req = {
- "order_id": order_id,
+ 'order_id': order_id,
}
- return self.do("POST", "/api/1/stoporder", req=req, auth=True)
+ return self.do('POST', '/api/1/stoporder', req=req, auth=True)
def update_account_name(self, id, name):
- """Make a call to PUT /api/1/accounts/{id}/name.
+ """Makes a call to PUT /api/1/accounts/{id}/name.
Update the name of an account with a given ID.
@@ -1044,112 +1064,151 @@ def update_account_name(self, id, name):
:type name: str
"""
req = {
- "id": id,
- "name": name,
+ 'id': id,
+ 'name': name,
}
- return self.do("PUT", "/api/1/accounts/{id}/name", req=req, auth=True)
-
- def validate(
- self,
- address,
- currency,
- address_name=None,
- beneficiary_name=None,
- country=None,
- date_of_birth=None,
- destination_tag=None,
- has_destination_tag=None,
- institution_name=None,
- is_legal_entity=None,
- is_private_wallet=None,
- is_self_send=None,
- memo=None,
- nationality=None,
- physical_address=None,
- wallet_name=None,
- ):
- """Make a call to POST /api/1/address/validate.
-
- Validate receive addresses, to which a customer wishes to make cryptocurrency sends, are verified under covering
- regulatory requirements for the customer such as travel rules.
+ return self.do('PUT', '/api/1/accounts/{id}/name', req=req, auth=True)
+
+ def validate(self, address=None, address_name=None, beneficiary_name=None, country=None, currency=None, date_of_birth=None, destination_tag=None, exchange_name=None, has_destination_tag=None, institution_name=None, is_legal_entity=None, is_private_wallet=None, is_self_send=None, memo=None, nationality=None, payment_id=None, physical_address=None, type=None, wallet_name=None):
+ """Makes a call to POST /api/1/address/validate.
+
+ Validates a counterparty against regulatory requirements such as travel rules. With type "send" (the
+ default), this screens and registers the counterparty's address as the destination of an
+ outgoing send. With type "receive", this submits originator identity information to resolve a quarantined deposit;
+ A 200 response confirms the validation request has been received.
Permissions required: Perm_W_Send
:param address: Destination address or email address.
+ Required for send requests.
+
Note:
send requests only.
:type address_name: str
- :param beneficiary_name: BeneficiaryName is the name of the beneficial owner if is it is a private address
+ :param beneficiary_name: BeneficiaryName is the name of the counterparty if is it is a private address.
+ Required when is_legal_entity is false, depending on your account's compliance
+ requirements.
+
+ Applies to both send and receive requests.
:type beneficiary_name: str
- :param country: Country is the ISO 3166-1 country code of the beneficial owner of the address
+ :param country: Country is the ISO 3166-1 country code of the counterparty. Required
+ depending on your account's compliance requirements.
+
+ Applies to both send and receive requests.
:type country: str
- :param date_of_birth: DateOfBirth is the date of birth of the (non-institutional) beneficial owner of the
- address in the form "YYYY-MM-DD"
+ :param currency: Currency is the currency associated with the address.
+
+ Applies to send requests only.
+ :type currency: str
+ :param date_of_birth: DateOfBirth is the date of birth of the (non-institutional) counterparty
+ in the form "YYYY-MM-DD". Required when is_legal_entity is false, depending on
+ your account's compliance requirements.
+
+ Applies to both send and receive requests.
:type date_of_birth: str
- :param destination_tag: Optional XRP destination tag. Note that HasDestinationTag must be true if this value is
- provided.
+ :param destination_tag: Optional XRP destination tag. Note that HasDestinationTag must be true if this value is provided.
+ Required when currency is XRP.
+
+ Applies to send requests only.
:type destination_tag: int
- :param has_destination_tag: Optional boolean flag indicating that a XRP destination tag is provided (even if
- zero).
+ :param exchange_name: ExchangeName is the name of the exchange that the funds were sent from.
+
+ Applies to receive requests only. Required when is_private_wallet is false.
+ :type exchange_name: str
+ :param has_destination_tag: Optional boolean flag indicating that a XRP destination tag is provided (even if zero).
+ Required when currency is XRP.
+
+ Applies to send requests only.
:type has_destination_tag: bool
- :param institution_name: InstitutionName is the name of the beneficial owner if is it is a legal entities
- address
+ :param institution_name: InstitutionName is the name of the counterparty if is it is a legal entities address.
+ Required when is_legal_entity is true, depending on your account's compliance
+ requirements.
+
+ Applies to both send and receive requests.
:type institution_name: str
- :param is_legal_entity: IsLegalEntity indicates if the address is for a legal entity and not a private
- beneficiary. If this field is true then the fields BeneficiaryName, Nationality &
- DateOfBirth should be empty but the fields InstitutionName and Country should be
- populated. If this field is false and IsSelfSend is false (or empty) then the field
- InstitutionName should be empty but the fields BeneficiaryName, Nationality &
- DateOfBirth and Country should be populated.
+ :param is_legal_entity: IsLegalEntity indicates if the address is for a legal entity and not a private counterparty.
+ If this field is true then the fields BeneficiaryName, Nationality & DateOfBirth should be empty but the
+ fields InstitutionName and Country should be populated.
+ If this field is false and IsSelfSend is false (or empty) then the field InstitutionName should be empty but the
+ fields BeneficiaryName, Nationality & DateOfBirth and Country should be populated.
+
+ Applies to both send and receive requests.
:type is_legal_entity: bool
- :param is_private_wallet: IsPrivateWallet indicates if the address is for private wallet and not held at an
- exchange.
+ :param is_private_wallet: IsPrivateWallet indicates if the address is for private wallet and not held at an exchange.
+
+ Applies to both send and receive requests.
:type is_private_wallet: bool
:param is_self_send: IsSelfSend to indicate that the address belongs to the customer.
- If this field is true then the remaining omitempty fields should not
+ If this field is true then the remaining optional fields should not
be populated.
+
+ Applies to both send and receive requests.
:type is_self_send: bool
- :param memo: Optional memo string used to provide account information for ATOM, etc. where it holds "account"
- information for a generic address.
+ :param memo: Optional memo string used to provide account information for ATOM, etc. where it holds "account" information
+ for a generic address. Required for currencies that use memo-based addressing.
+
+ Applies to send requests only.
:type memo: str
- :param nationality: Nationality ISO 3166-1 country code of the nationality of the (non-institutional) beneficial
- owner of the address
+ :param nationality: Nationality ISO 3166-1 country code of the nationality of the (non-institutional)
+ counterparty. Required when is_legal_entity is false, depending on
+ your account's compliance requirements.
+
+ Applies to both send and receive requests.
:type nationality: str
- :param physical_address: PhysicalAddress is the legal physical address of the beneficial owner of the crypto
- address
+ :param payment_id: PaymentID is the Luno payment id of a transaction that has been quarantined.
+
+ This field is required only for receive validation requests.
+
+ PaymentID is discoverable through the `List pending transactions` request.
+ :type payment_id: int
+ :param physical_address: PhysicalAddress is the legal physical address of the counterparty's crypto
+ address. Required depending on your account's compliance requirements.
+
+ Applies to both send and receive requests.
:type physical_address: str
- :param wallet_name: PrivateWalletName is the name of the private wallet
+ :param type: Type is the optional input for the direction of the payment, send or receive.
+
+ send screens and registers the counterparty's address as the destination of an outgoing send (the default).
+
+ receive submits originator identity information to resolve a quarantined deposit.
+ :type type: str
+ :param wallet_name: PrivateWalletName is the name of the private wallet. Required when is_private_wallet is
+ true, depending on your account's compliance requirements.
+
+ Applies to both send and receive requests.
:type wallet_name: str
"""
req = {
- "address": address,
- "currency": currency,
- "address_name": address_name,
- "beneficiary_name": beneficiary_name,
- "country": country,
- "date_of_birth": date_of_birth,
- "destination_tag": destination_tag,
- "has_destination_tag": has_destination_tag,
- "institution_name": institution_name,
- "is_legal_entity": is_legal_entity,
- "is_private_wallet": is_private_wallet,
- "is_self_send": is_self_send,
- "memo": memo,
- "nationality": nationality,
- "physical_address": physical_address,
- "wallet_name": wallet_name,
+ 'address': address,
+ 'address_name': address_name,
+ 'beneficiary_name': beneficiary_name,
+ 'country': country,
+ 'currency': currency,
+ 'date_of_birth': date_of_birth,
+ 'destination_tag': destination_tag,
+ 'exchange_name': exchange_name,
+ 'has_destination_tag': has_destination_tag,
+ 'institution_name': institution_name,
+ 'is_legal_entity': is_legal_entity,
+ 'is_private_wallet': is_private_wallet,
+ 'is_self_send': is_self_send,
+ 'memo': memo,
+ 'nationality': nationality,
+ 'payment_id': payment_id,
+ 'physical_address': physical_address,
+ 'type': type,
+ 'wallet_name': wallet_name,
}
- return self.do("POST", "/api/1/address/validate", req=req, auth=True)
+ return self.do('POST', '/api/1/address/validate', req=req, auth=True)
# vi: ft=python
diff --git a/tests/test_client.py b/tests/test_client.py
index 7d17d41..85f2444 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -139,6 +139,21 @@ def test_get_balances_without_account_id():
assert len(result["balance"]) == 3
+def test_get_balances_with_account_type_filter():
+ """Test get_balances passes multiple account_type values as repeated query params."""
+ c = Client()
+ c.set_base_url("http://test/")
+
+ adapter = requests_mock.Adapter()
+ c.session.mount("http://", adapter)
+
+ adapter.register_uri("GET", "http://test/api/1/balance", json=MOCK_BALANCES_RESPONSE)
+
+ result = c.get_balances(account_type=["SPOT", "SPOT_MARGIN"])
+ assert result == MOCK_BALANCES_RESPONSE
+ assert adapter.last_request.qs["account_type"] == ["spot", "spot_margin"]
+
+
def test_get_balances_with_valid_account_id():
"""Test get_balances with valid account_id parameter."""
c = Client()