buycoins_sdk.client package¶
Submodules¶
buycoins_sdk.client.client module¶
This module contains and exports the BuycoinsGraphqlClient class and a helper function
-
class
BuycoinsGraphqlClient(public_key: str, secret_key: str)¶ Bases:
objectThe BuycoinsGraphqlClient is a wrapper around GraphqlClient which takes in the user’s public and secret keys for making GraphQL queries.
-
client¶ A GraphqlClient used to make queries and mutations directly. Only use this when you want to write your own queries and mutations. Most times, you won’t need to do that yourself.
-
buy(price_id: str, coin_amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Execute the buy mutation
- Parameters
price_id – Global ID of a retrieved price
coin_amount – Amount of coins to buy
cryptocurrency – type of cryptocurrency
- Returns
A dict representing the GraphQL response
- Raises
InsufficientBalanceToBuyException – raised when user has insufficient balance to buy cryptocurrency
BuycoinsException – An error occurred
-
cancel_withdrawal(payment_id: str) → dict¶ Executes the cancelWithdrawal mutation
- Parameters
payment_id – the ID of the Payment node for the withdrawal
- Returns
A dict representing the GraphQL response
- Raises
WithdrawalCannotBeCanceledException – An error occurred because user tried to cancel already processed withdrawal
BuycoinsException – An error occurred
-
create_address(cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Executes the createAddress mutation
- Parameters
cryptocurrency – cryptocurrency of address to create
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
create_deposit_account(account_name: str) → dict¶ Executes the createDepositAccount mutation
- Parameters
account_name – name of the account
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
create_withdrawal(bank_account_id: str, amount: str)¶ Executes the createWithdrawal mutation
- Parameters
bank_account_id – Global object ID of bank account node to withdraw to
amount – amount to withdraw in naira
- Returns
A dict representing the GraphQL response
- Raises
InsufficientBalanceToWithdrawException – This is raised when a user tries withdrawing more naira than they have
BuycoinsException – An error occurred
-
get_balances(cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency) → dict¶ Executes the getBalances query
- Parameters
cryptocurrency – A Cryptocurrency enum representing the cryptocurrency to query.
- Returns
A dict representing the GraphQL response
- Raises
AuthenticationException – User provided wrong on invalid BuyCoins API credentials
BuycoinsException – An error occurred
-
get_bank_accounts(account_number=None) → dict¶ Executes the getBankAccounts query
- Parameters
account_number – A string representing the account number to get.
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
get_estimated_network_fee(amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Executes the getEstimatedNetworkFee query
- Parameters
amount – A string representing the amount of coins to calculate network fee for
cryptocurrency – type of cryptocurrency.
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
get_market_book(first: Optional[int] = None, last: Optional[int] = None, after: Optional[str] = None, before: Optional[str] = None, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Executes the getMarketBook query
- Parameters
first – For pagination. Returns the first n elements in a list.
last – For pagination. Returns the last n elements in a list.
after – A string representing a cursor. Returns the elements in the list that come after the specified cursor.
before – A string representing a cursor. Returns the elements in the list that come before the specified cursor.
cryptocurrency – type of cryptocurrency.
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
get_orders(status: buycoins_sdk.commons.enums.GetOrdersStatus, side: Optional[buycoins_sdk.commons.enums.OrderSide] = None, first: Optional[int] = None, last: Optional[int] = None, after: Optional[str] = None, before: Optional[str] = None, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Executes the getOrders query
- Parameters
status – the status of the orders to get
side – the side of the orders to get
first – For pagination. Returns the first n elements in a list.
last – For pagination. Returns the last n elements in a list.
after – A string representing a cursor. Returns the elements in the list that come after the specified cursor.
before – A string representing a cursor. Returns the elements in the list that come before the specified cursor.
cryptocurrency – type of cryptocurrency.
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
get_payments(after: Optional[str] = None, before: Optional[str] = None, first: Optional[int] = None, last: Optional[int] = None) → dict¶ Executes the getPayments GraphQL query
- Parameters
first – For pagination. Returns the first n elements in a list.
last – For pagination. Returns the last n elements in a list.
after – A string representing a cursor. Returns the elements in the list that come after the specified cursor.
before – A string representing a cursor. Returns the elements in the list that come before the specified cursor.
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
get_prices(cryptocurrency: Optional[buycoins_sdk.commons.enums.Cryptocurrency] = None) → dict¶ Executes the getPrices query
- Parameters
cryptocurrency – the type of cryptocurrency to query for
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
node(node_id: str, gql_type: buycoins_sdk.commons.enums.BuycoinsType) → dict¶ Executes the node Graphql query
- Parameters
node_id – the Global object ID of the node
gql_type – the GraphQL type of the Graphql node
- Returns
A dict representing the GraphQL response
- Raises
InvalidGraphQLNodeIDException – You tried to search for a node with the wrong ID or wrong GraphQL type
BuycoinsException – An unspecified error occurred
-
nodes(ids: List[str], gql_types: List[buycoins_sdk.commons.enums.BuycoinsType]) → dict¶ Executes the nodes GraphQL query
- Parameters
ids – the list of node IDs
gql_types – the list of node types
- Returns
A dict representing the GraphQL response
- Raises
InvalidGraphQLNodeIDException – You tried to search for a node with the wrong ID or wrong GraphQL type
BuycoinsException – An unspecified error occurred
-
post_limit_order(order_side: buycoins_sdk.commons.enums.OrderSide, coin_amount: str, static_price: str, price_type: buycoins_sdk.commons.enums.PriceType, dynamic_exchange_rate: Optional[str] = None, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Execute the postLimitOrder mutation
- Parameters
order_side – The order side either buy or sell
coin_amount – Amount of coins the user wants to trade
static_price – The static price in naira
price_type – The type of the price either dynamic or static
dynamic_exchange_rate – The dynamic exchange rate in naira
cryptocurrency – type of cryptocurrency
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
post_market_order(order_side: buycoins_sdk.commons.enums.OrderSide, coin_amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Execute the postMarketOrder mutation
- Parameters
order_side – The order side either buy or sell
coin_amount – Amount of coins the user wants to trade
cryptocurrency – type of cryptocurrency
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
sell(price_id: str, coin_amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Execute the sell mutation
- Parameters
price_id – Global ID of a retrieved price
coin_amount – Amount of coins to sell
cryptocurrency – type of cryptocurrency
- Returns
A dict representing the GraphQL response
- Raises
InsufficientAmountToSellException – raised when the user has insufficient amount of cryptocurrency to sell
BuycoinsException – An error occurred
-
send(address: str, amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Executes the send mutation
- Parameters
address – cryptocurrency address of recipient
amount – amount of cryptocurrency to send
cryptocurrency – cryptocurrency to send
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-
send_offchain(recipient: str, amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → dict¶ Executes the sendOffchain mutation
- Parameters
recipient – username of recipient
amount – amount of cryptocurrency to send
cryptocurrency – cryptocurrency to send
- Returns
A dict representing the GraphQL response
- Raises
BuycoinsException – An error occurred
-