Skip to content

Accounts

poloniex-sdk edited this page Jan 10, 2023 · 5 revisions

Account Information

get_accounts

get_accounts()

Get a list of all accounts of a user.

Returns:

A list of json objects with account information:

{
    'accountId': (str) Account ID,
    'accountType': (str) Account type. Currently only SPOT is supported,
    'accountState': (str) Account's state, e.g. NORMAL, LOCKED
}

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.accounts().get_accounts()
print(response)

Account Balances

get_balances

get_balances(account_type=None)

Get a list of all accounts of a user with each account’s id, type and balances (assets).

Args:

  • account_type (str, optional): The account type. e.g. SPOT. Default will show all account types if not specified. Currently only SPOT is supported.

Returns:

A list of json objects with account information:

[
    {
        'accountId': (str) Account ID,
        'accountType': (str) Account type. Currently only SPOT is supported,
        'balances':
        [
            {
                'currencyId': (str) Currency id,
                'currency': (str) Currency name,
                'available': (str) Available amount for the currency,
                'hold': (str) Frozen amount for the currency
            },
            {...}
        ]
    },
    {...},
    ...
]

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.accounts().get_balances()
print(response)

get_account_balances

get_account_balances(account_id)

Get the full details for a single account with its balances: free (available) and locked (hold) for each currency.

Args:

  • account_id (int): Account id, data from /accounts.

Returns:

A list of json objects with account information:

[
    {
        'accountId': (str) Account ID,
        'accountType': (str) Account type. Currently only SPOT is supported,
        'balances':
        [
            {
                'currencyId': (str) Currency id,
                'currency': (str) Currency name,
                'available': (str) Available amount for the currency,
                'hold': (str) Frozen amount for the currency
            },
            {...}
        ]
    }
]

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.accounts().get_account_balances(<accountId>)
print(response)

Account Activity

get_activity

get_activity(start_time=None, end_time=None, activity_type=None, begins_from=None, **kwargs)

Get a list of activities such as airdrop, rebates, staking, credit/debit adjustments, and other (historical adjustments).

Args start_time (int, optional): Trades filled before startTime will not be retrieved.(milliseconds since UNIX epoch) end_time (int, optional): Trades filled after endTime will not be retrieved.(milliseconds since UNIX epoch) activity_type (int, optional): Type of activity: ALL: 200, AIRDROP: 201, COMMISSION_REBATE: 202, STAKING: 203, REFERAL_REBATE: 204, CREDIT_ADJUSTMENT: 104, DEBIT_ADJUSTMENT: 105, OTHER: 199. Must use numeric code. begins_from (int, optional): It is 'id'. The query begin at ‘from', and the default is 0.

Keyword Args:

  • limit (int, optional): The max number of records could be returned. Default is 100 and max is 1000.
  • direction (str, optional): PRE, NEXT, default is NEXT.
  • currency (str, optional): The transferred currency, like USDT. Default is for all currencies, if not specified.

Returns:

List of json objects with account activity information:

[
    {
        'id': (str) Activity ID,
        'currency': (str) Currency like BTC, ETH etc,
        'amount': (str) Amount of the activity (can be negative),
        'state': (str) State of the activity (ex. SUCCESS),
        'createTime': (int) Datetime of the activity,
        'description': (str) Activity details,
        'activityType': (int) type of activity
    },
    {...},
    ...
]

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.accounts().get_activity()
print(response)

Transfer Balances

transfer

transfer(currency, amount, from_account, to_account)

Transfer amount of currency from an account to another account for a user.

Args:

  • currency (str, required): The currency to transfer, like USDT.
  • amount (str, required): The amount to transfer.
  • from_account (str, required): The account, from which the currency is transferred.
  • to_account (str, required): The account, to which the currency is transferred.

Returns:

Reference Transfer Id:

{
    'transferId': (str) Transfer ID
}

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.accounts().transfer('USDT', '10.5', 'SPOT', 'FUTURES')
print(response)

Transfer Activity

get_transfers

get_transfers(begins_from=None, start_time=None, end_time=None, **kwargs)

Get a list of transfer records of a user.

Args:

  • begins_from (int, optional): It is 'transferId'. The query begin at ‘from', and the default is 0.
  • start_time (int, optional): Transfers before start time will not be retrieved. (milliseconds since UNIX epoch)
  • end_time (int, optional): Transfers after end time will not be retrieved. (milliseconds since UNIX epoch)

Keyword Args:

  • limit (int, optional): The max number of records could be returned.
  • direction (str, optional): PRE, NEXT, default is NEXT.
  • currency (str, optional): The transferred currency, like USDT. Default is for all currencies, if not specified.

Returns:

List of json objects with account transfer information:

[
    {
        'id': (str) Transfer ID,
        'fromAccount': (str) The account, from which the currency is transferred,
        'toAccount': (str) The account, to which the currency is transferred,
        'currency': (str) The transferred currency,
        'amount': (str) The transferred amount,
        'state': (str) The state of transfer operation. (SUCCESS),
        'createTime': (int) The datetime of transfer operation
    },
    {...},
    ...
]

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.accounts().get_transfers()
print(response)

get_transfer

get_transfer(transfer_id)

Get a transfer record of a user by id.

Args:

  • transfer_id (str, required): Transfer ID.

Returns:

Json object with account transfer information:

{
    'id': (str) Transfer ID,
    'fromAccount': (str) The account, from which the currency is transferred,
    'toAccount': (str) The account, to which the currency is transferred,
    'currency': (str) The transferred currency,
    'amount': (str) The transferred amount,
    'state': (str) The state of transfer operation. (SUCCESS),
    'createTime': (int) The datetime of transfer operation
}

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.accounts().get_transfer('501')
print(response)

Fee Info

get_fee_info

get_fee_info()

Get fee rate for an account.

Returns:

A list of json objects with account information:

{
    'trxDiscount': (boolean) Discount exists if using TRX,
    'makerRate': (str) Maker rate,
    'takerRate': (str) Taker rate,
    'volume30D': (str) 30 days volume in USDT
}

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.accounts().get_fee_info()
print(response)