buycoins_sdk.core package

Submodules

buycoins_sdk.core.main_buycoins_sdk module

class BuycoinsSDK(public_key: str, secret_key: str)

Bases: object

BuycoinsSDK is the entry point of the Buycoins SDK

All calls to the Buycoins GraphQL API should be done using this class

client

A BuycoinsGraphqlClient object where the actual GraphQL queries and mutations are made

buy(price_id: str, coin_amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>)buycoins_sdk.core.types.Order

Buy supported cryptocurrencies

Parameters
  • price_id – Global ID of a retrieved price

  • coin_amount – Amount of coins to buy

  • cryptocurrency – type of cryptocurrency

Returns

An Order object representing the GraphQL response

Raises
cancel_withdrawal(payment_id: str)buycoins_sdk.core.types.Payment

Cancel initiated withdrawal

Parameters

payment_id – the ID of the Payment node for the withdrawal

Returns

A Payment object representing the GraphQL response

Raises
create_address(cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>)buycoins_sdk.core.types.Address

Create address to receive supported cryptocurrencies

Parameters

cryptocurrency – cryptocurrency of address to create

Returns

An Address object representing the GraphQL response

Raises

BuycoinsException – An error occurred

create_deposit_account(account_name: str)buycoins_sdk.core.types.DepositAccount

Generate deposit bank accounts to top up your NGNT account with Naira

Parameters

account_name – name of the account

Returns

A DepositAccount object representing the GraphQL response

Raises

BuycoinsException – An error occurred

create_withdrawal(bank_account_id: str, amount: str)buycoins_sdk.core.types.Payment

Create a new withdrawal

Parameters
  • bank_account_id – Global object ID of bank account node to withdraw to

  • amount – amount to withdraw in naira

Returns

A Payment object representing the GraphQL response

Raises

BuycoinsException – An error occurred

get_balances(cryptocurrency: Optional[buycoins_sdk.commons.enums.Cryptocurrency] = None) → Union[List[buycoins_sdk.core.types.Account], buycoins_sdk.core.types.Account]

Retrieve supported cryptocurrencies account balance(s)

Parameters

cryptocurrency – A Cryptocurrency enum representing the cryptocurrency to query.

Returns

An array of Account or a single Account object. An array of Accounts is returned when no cryptocurrency is specified

Raises

BuycoinsException – An error occurred

get_bank_accounts(account_number: Optional[str] = None) → Union[List[buycoins_sdk.core.types.BankAccount], buycoins_sdk.core.types.BankAccount]

Retrieve bank accounts

Parameters

account_number – A string representing the account number to get.

Returns

An array of BankAccount objects or a single BankAccount object. An array of BankAccount objects is returned when no account number is specified

Raises

BuycoinsException – An error occurred

get_estimated_network_fee(amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>)buycoins_sdk.core.types.EstimatedFee

Retrieve estimated network fee to send supported cryptocurrencies

Parameters
  • amount – A string representing the amount of coins to calculate network fee for

  • cryptocurrency – type of cryptocurrency.

Returns

An EstimatedFee object

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'>)buycoins_sdk.core.types.PostOrders

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'>)buycoins_sdk.core.types.PostOrders

Retrieve open orders

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 PostOrders object representing the PostOrders type returned by the GraphQL API

Raises

BuycoinsException – An error occurred

get_payments(after: Optional[str] = None, before: Optional[str] = None, first: Optional[int] = None, last: Optional[int] = None)buycoins_sdk.core.types.PaymentConnection

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) → Union[List[buycoins_sdk.core.types.BuycoinsPrice], buycoins_sdk.core.types.BuycoinsPrice]

Retrieve buy/sell price(s) for supported cryptocurrencies

Parameters

cryptocurrency – the type of cryptocurrency to query for

Returns

A array of BuycoinsPrice objects or a single BuycoinsPrice object. An array of Buycoins Objects is returned when no cryptocurrency is specified

Raises

BuycoinsException – An error occurred

node(node_id: str, gql_type: buycoins_sdk.commons.enums.BuycoinsType) → dict

Fetches an object given its ID.

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
nodes(ids: List[str], gql_types: List[buycoins_sdk.commons.enums.BuycoinsType]) → dict

Fetches a list of objects given a list of IDs

Parameters
  • ids – the list of node IDs

  • gql_types – the list of node types

Returns

A dict representing the GraphQL response

Raises
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'>)buycoins_sdk.core.types.PostOrder

Create a new limit order

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 PostOrder object 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'>)buycoins_sdk.core.types.PostOrder

Create a new market order

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 PostOrder object 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'>)buycoins_sdk.core.types.Order

Sell supported cryptocurrencies

Parameters
  • price_id – Global ID of a retrieved price

  • coin_amount – Amount of coins to sell

  • cryptocurrency – type of cryptocurrency

Returns

An Order object representing the GraphQL response

Raises
send(address: str, amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>)buycoins_sdk.core.types.OnchainTransferRequest

Send supported cryptocurrencies to external address

Parameters
  • address – cryptocurrency address of recipient

  • amount – amount of cryptocurrency to send

  • cryptocurrency – cryptocurrency to send

Returns

An OnchainTransferRequest object representing the GraphQL response

Raises

BuycoinsException – An error occurred

send_offchain(recipient: str, amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → bool

Send supported cryptocurrencies to internal BuyCoins users

Parameters
  • recipient – username of recipient

  • amount – amount of cryptocurrency to send

  • cryptocurrency – cryptocurrency to send

Returns

A boolean indicating whether or not the transfer was successfully initiated

Raises

BuycoinsException – An error occurred

buycoins_sdk.core.types module

class Account(node_id: str, cryptocurrency: str, confirmed_balance: str)

Bases: object

This class represents the Buycoins Account type

id

a string representing the id of the Account

cryptocurrency

the cryptocurrency field of the Account type

confirmed_balance

the confirmed balance field of the Account type

static from_dict(fields: dict)
This allows you to create an Account object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

An Account object

class Address(node_id: str, address: str, created_at: int, cryptocurrency: str)

Bases: object

This class represents the Buycoins Address type

id

the id field of the Address object

address

the address field of the Address object

created_at

the createdAt field of the Address object

cryptocurrency

the cryptocurrency field of the Address object

static from_dict(fields: dict)
This allows you to create an Address object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

An Address object

class BankAccount(node_id: str, account_name: str, account_number: str, account_reference: str, account_type: str, bank_name: str)

Bases: object

This class represents the Buycoins BankAccount type

id

the id of the BankAccount

account_name

the Account name field of the BankAccount type

account_number

the account number field of the BankAccount type

account_reference

the account reference field of the BankAccount type

account_type

the account type field of the BankAccount type

bank_name

the bank name field of the BankAccount type

static from_dict(fields: dict)
This allows you to create a BankAccount object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A BankAccount object

class BuycoinsPrice(node_id: str, buy_price_per_coin: str, cryptocurrency: str, expires_at: int, max_buy: str, max_sell: str, min_buy: str, min_coin_amount: str, min_sell: str, sell_price_per_coin: str, status: str)

Bases: object

This class represents the Buycoins BuycoinsPrice type

id

the id field of the BuycoinsPrice type

buy_price_per_coin

the buyPricePerCoin field of the BuycoinsPrice type

cryptocurrency

the cryptocurrency field of the BuycoinsPrice type

expires_at

the expiresAt field of the BuycoinsPrice type

max_buy

the maxBuy field of the BuycoinsPrice type

max_sell

the maxSel field of the BuycoinsPrice type

min_buy

the minBuy field of the BuycoinsPrice type

min_coin_amount

the minCoinAmount field of the BuycoinsPrice type

min_sell

the minSell field of the BuycoinsPrice type

sell_price_per_coin

the sellPricePerCoin field of the BuycoinsPrice type

status

the status field of the BuycoinsPrice type

static from_dict(fields: dict)
This allows you to create a BuycoinsPrice object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods. Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A BuycoinsPrice object

class DepositAccount(node_id: str, account_name: str, account_number: str, account_reference: str, account_type: str, bank_name: str)

Bases: object

This class represents the Buycoins DepositAccount type

id

the id field of the DepositAccount object

account_name

the accountName field of the DepositAccount object

account_number

the accountNumber field of the DepositAccount object

account_reference

the accountReference field of the DepositAccount object

account_type

the accountType field of the DepositAccount object

bank_name

the bankName field of the DepositAccount object

static from_dict(fields: dict)
This allows you to create a DepositAccount object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A DepositAccount object

class EstimatedFee(estimated_fee: str, total: str)

Bases: object

This class represents the Buycoins EstimatedFee type

estimated_fee

Estimated network fee for send

total

Sum of amount and estimated network fee

static from_dict(fields: dict)
This allows you to create an EstimatedFee object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

An EstimatedFee object

class OnchainTransferRequest(node_id: str, address: str, amount: str, created_at: int, cryptocurrency: str, fee: str, status: str, transaction_id: str)

Bases: object

This class represents the Buycoins OnchainTransferRequest type

id

the id field of the OnchainTransferRequest type

address

the address field of the OnchainTransferRequest type

amount

the amount field of the OnchainTransferRequest type

created_at

the createdAt field of the OnchainTransferRequest type

cryptocurrency

the cryptocurrency field of the OnchainTransferRequest type

fee

the fee field of the OnchainTransferRequest type

status

the status field of the OnchainTransferRequest type

transaction_id

the id of the transaction of the OnchainTransferRequest type

static from_dict(fields: dict)
This allows you to create an OnchainTransferRequest object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

An OnchainTransferRequest object

class Order(node_id: str, created_at: int, cryptocurrency: str, filled_coin_amount: str, price: buycoins_sdk.core.types.BuycoinsPrice, side: str, status: str, total_coin_amount: str)

Bases: object

This class represents the Buycoins Order type

id

the id field of the Order object

created_at

the createdAt field of the Order object

cryptocurrency

the cryptocurrency field of the Order object

filled_coin_amount

the filledCoinAmount field of the Order object

price

the price field of the Order object

side

the side field of the Order object

status

the status field of the Order object

total_coin_amount

the totalCoinAmount field of the Order object

static from_dict(fields: dict)
This allows you to create an Order object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

An Order object

class PageInfo(end_cursor: str, has_next_page: bool, has_previous_page: bool, start_cursor: str)

Bases: object

This class represents the Buycoins PageInfo type

end_cursor

a string representing the last cursor of the PageInfo

has_next_page

boolean stating whether or not a next page exists

has_previous_page

boolean stating whether or not a previous page exists

start_cursor

start cursor of PageInfo object

static from_dict(fields: dict)
This allows you to create a PageInfo object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A PageInfo object

class Payment(node_id: str, amount: str, created_at: int, fee: str, reference: str, status: str, total_amount: str, payment_type: str)

Bases: object

This class represents the Buycoins Payment type

id

the id field of the Payment type

amount

the amount field of the Payment type

created_at

the createdAt field of the Payment type

fee

the fee field of the Payment type

reference

the reference field of the Payment type

status

the status field of the Payment type

total_amount

the total_amount field of the Payment type

payment_type

the payment_type field of the Payment type

static from_dict(fields: dict)
This allows you to create a Payment object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods. Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A Payment object

class PaymentConnection(payment_edges: List[buycoins_sdk.core.types.PaymentEdge], page_info: buycoins_sdk.core.types.PageInfo)

Bases: object

This class represents the connection type for Buycoins Payment type.

payment_edges

a list of PaymentEdge objects

page_info

a PageInfo object containing pagination details about the payment_edges attribute

static from_dict(fields: dict)
This allows you to create a PaymentConnection object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A PaymentConnection object

class PaymentEdge(cursor: str, payment: buycoins_sdk.core.types.Payment)

Bases: object

This class represents the Buycoins PaymentEdge type

cursor

a string representing the cursor for the PaymentEdge object

payment

a Payment object representing the Payment node

class PostOrder(node_id: str, coin_amount: str, created_at: int, cryptocurrency: str, dynamic_exchange_rate: str, price_per_coin: str, price_type: str, side: str, static_price: str, status: str)

Bases: object

This class represents the Buycoins PostOrder type .. attribute:: id

the id field of the PostOrder type

coin_amount

the coin amount field of the PostOrder type

created_at

the createdAt field of the PostOrder type

cryptocurrency

the cryptocurrency field of the PostOrder type

dynamic_exchange_rate

the dynamic exchange rate field of the PostOrder type

price_per_coin

the price per coin field of the PostOrder type

price_type

the price type field of the PostOrder type

side

the side field of the PostOrder type

static_price

the static price field of the PostOrder type

status

the status field of the PostOrder type

static from_dict(fields: dict)
This allows you to create a PostOrder object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods. Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A PostOrder object

class PostOrderEdge(cursor: str, post_order: buycoins_sdk.core.types.PostOrder)

Bases: object

This class represents the Buycoins PostOrderEdge type

cursor

a string representing the cursor for the PostOrderEdge object

post_order

a PostOrder object representing the PostOrder node

class PostOrders(dynamic_price_expiry: str, page_info: buycoins_sdk.core.types.PageInfo, post_order_edges: List[buycoins_sdk.core.types.PostOrderEdge])

Bases: object

This class represents the Buycoins PostOrders type

dynamic_price_expiry
page_info

a PageInfo object containing pagination details about the post_order_edges attribute

post_order_edges

a list of PostOrderEdge objects

static from_dict(fields: dict)
This allows you to create a PostOrders object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A PostOrders object

class Transaction(node_id: str, address: buycoins_sdk.core.types.Address, amount: str, confirmed: bool, created_at: int, cryptocurrency: str, direction: str, onchain_transfer_request_id: str, tx_hash: str)

Bases: object

This class represents the Buycoins Transaction type

node_id

the id field of the Transaction type

address

the address field of the Transaction type

amount

the amount field of the Transaction type

confirmed

the confirmed field of the Transaction type

created_at

the createdAt field of the Transaction type

cryptocurrency

the cryptocurrency field of the Transaction type

direction

the direction field of the Transaction type

onchain_transfer_request_id

the id field of the onchainTransferRequest field of the Transaction type

tx_hash

the txHash field of the Transaction type

static from_dict(fields: dict)
This allows you to create a Transaction object using the fields in the data attribute of the dicts returned

from BuycoinsGraphqlClient’s methods.Study the methods of BuycoinsSDK to know how this is used

Parameters

fields – the fields of the data property of a dict returned from a BuycoinsGraphqlClient method

Returns

A Transaction object

Module contents

class BuycoinsSDK(public_key: str, secret_key: str)

Bases: object

BuycoinsSDK is the entry point of the Buycoins SDK

All calls to the Buycoins GraphQL API should be done using this class

client

A BuycoinsGraphqlClient object where the actual GraphQL queries and mutations are made

buy(price_id: str, coin_amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>)buycoins_sdk.core.types.Order

Buy supported cryptocurrencies

Parameters
  • price_id – Global ID of a retrieved price

  • coin_amount – Amount of coins to buy

  • cryptocurrency – type of cryptocurrency

Returns

An Order object representing the GraphQL response

Raises
cancel_withdrawal(payment_id: str)buycoins_sdk.core.types.Payment

Cancel initiated withdrawal

Parameters

payment_id – the ID of the Payment node for the withdrawal

Returns

A Payment object representing the GraphQL response

Raises
create_address(cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>)buycoins_sdk.core.types.Address

Create address to receive supported cryptocurrencies

Parameters

cryptocurrency – cryptocurrency of address to create

Returns

An Address object representing the GraphQL response

Raises

BuycoinsException – An error occurred

create_deposit_account(account_name: str)buycoins_sdk.core.types.DepositAccount

Generate deposit bank accounts to top up your NGNT account with Naira

Parameters

account_name – name of the account

Returns

A DepositAccount object representing the GraphQL response

Raises

BuycoinsException – An error occurred

create_withdrawal(bank_account_id: str, amount: str)buycoins_sdk.core.types.Payment

Create a new withdrawal

Parameters
  • bank_account_id – Global object ID of bank account node to withdraw to

  • amount – amount to withdraw in naira

Returns

A Payment object representing the GraphQL response

Raises

BuycoinsException – An error occurred

get_balances(cryptocurrency: Optional[buycoins_sdk.commons.enums.Cryptocurrency] = None) → Union[List[buycoins_sdk.core.types.Account], buycoins_sdk.core.types.Account]

Retrieve supported cryptocurrencies account balance(s)

Parameters

cryptocurrency – A Cryptocurrency enum representing the cryptocurrency to query.

Returns

An array of Account or a single Account object. An array of Accounts is returned when no cryptocurrency is specified

Raises

BuycoinsException – An error occurred

get_bank_accounts(account_number: Optional[str] = None) → Union[List[buycoins_sdk.core.types.BankAccount], buycoins_sdk.core.types.BankAccount]

Retrieve bank accounts

Parameters

account_number – A string representing the account number to get.

Returns

An array of BankAccount objects or a single BankAccount object. An array of BankAccount objects is returned when no account number is specified

Raises

BuycoinsException – An error occurred

get_estimated_network_fee(amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>)buycoins_sdk.core.types.EstimatedFee

Retrieve estimated network fee to send supported cryptocurrencies

Parameters
  • amount – A string representing the amount of coins to calculate network fee for

  • cryptocurrency – type of cryptocurrency.

Returns

An EstimatedFee object

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'>)buycoins_sdk.core.types.PostOrders

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'>)buycoins_sdk.core.types.PostOrders

Retrieve open orders

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 PostOrders object representing the PostOrders type returned by the GraphQL API

Raises

BuycoinsException – An error occurred

get_payments(after: Optional[str] = None, before: Optional[str] = None, first: Optional[int] = None, last: Optional[int] = None)buycoins_sdk.core.types.PaymentConnection

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) → Union[List[buycoins_sdk.core.types.BuycoinsPrice], buycoins_sdk.core.types.BuycoinsPrice]

Retrieve buy/sell price(s) for supported cryptocurrencies

Parameters

cryptocurrency – the type of cryptocurrency to query for

Returns

A array of BuycoinsPrice objects or a single BuycoinsPrice object. An array of Buycoins Objects is returned when no cryptocurrency is specified

Raises

BuycoinsException – An error occurred

node(node_id: str, gql_type: buycoins_sdk.commons.enums.BuycoinsType) → dict

Fetches an object given its ID.

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
nodes(ids: List[str], gql_types: List[buycoins_sdk.commons.enums.BuycoinsType]) → dict

Fetches a list of objects given a list of IDs

Parameters
  • ids – the list of node IDs

  • gql_types – the list of node types

Returns

A dict representing the GraphQL response

Raises
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'>)buycoins_sdk.core.types.PostOrder

Create a new limit order

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 PostOrder object 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'>)buycoins_sdk.core.types.PostOrder

Create a new market order

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 PostOrder object 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'>)buycoins_sdk.core.types.Order

Sell supported cryptocurrencies

Parameters
  • price_id – Global ID of a retrieved price

  • coin_amount – Amount of coins to sell

  • cryptocurrency – type of cryptocurrency

Returns

An Order object representing the GraphQL response

Raises
send(address: str, amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>)buycoins_sdk.core.types.OnchainTransferRequest

Send supported cryptocurrencies to external address

Parameters
  • address – cryptocurrency address of recipient

  • amount – amount of cryptocurrency to send

  • cryptocurrency – cryptocurrency to send

Returns

An OnchainTransferRequest object representing the GraphQL response

Raises

BuycoinsException – An error occurred

send_offchain(recipient: str, amount: str, cryptocurrency: buycoins_sdk.commons.enums.Cryptocurrency = <Cryptocurrency.BITCOIN: 'bitcoin'>) → bool

Send supported cryptocurrencies to internal BuyCoins users

Parameters
  • recipient – username of recipient

  • amount – amount of cryptocurrency to send

  • cryptocurrency – cryptocurrency to send

Returns

A boolean indicating whether or not the transfer was successfully initiated

Raises

BuycoinsException – An error occurred