Provides access to Private Endpoints on the cbpro API. All requests default to the live `api_url`: 'https://api.pro.coinbase.com'. To test your application using the sandbox modify the `api_url`. Attributes: url (str): The api url for this client instance to use. auth
| 16 | |
| 17 | |
| 18 | class AuthenticatedClient(PublicClient): |
| 19 | """ Provides access to Private Endpoints on the cbpro API. |
| 20 | |
| 21 | All requests default to the live `api_url`: 'https://api.pro.coinbase.com'. |
| 22 | To test your application using the sandbox modify the `api_url`. |
| 23 | |
| 24 | Attributes: |
| 25 | url (str): The api url for this client instance to use. |
| 26 | auth (CBProAuth): Custom authentication handler for each request. |
| 27 | session (requests.Session): Persistent HTTP connection object. |
| 28 | """ |
| 29 | def __init__(self, key, b64secret, passphrase, |
| 30 | api_url="https://api.pro.coinbase.com"): |
| 31 | """ Create an instance of the AuthenticatedClient class. |
| 32 | |
| 33 | Args: |
| 34 | key (str): Your API key. |
| 35 | b64secret (str): The secret key matching your API key. |
| 36 | passphrase (str): Passphrase chosen when setting up key. |
| 37 | api_url (Optional[str]): API URL. Defaults to cbpro API. |
| 38 | """ |
| 39 | super(AuthenticatedClient, self).__init__(api_url) |
| 40 | self.auth = CBProAuth(key, b64secret, passphrase) |
| 41 | self.session = requests.Session() |
| 42 | |
| 43 | def get_account(self, account_id): |
| 44 | """ Get information for a single account. |
| 45 | |
| 46 | Use this endpoint when you know the account_id. |
| 47 | |
| 48 | Args: |
| 49 | account_id (str): Account id for account you want to get. |
| 50 | |
| 51 | Returns: |
| 52 | dict: Account information. Example:: |
| 53 | { |
| 54 | "id": "a1b2c3d4", |
| 55 | "balance": "1.100", |
| 56 | "holds": "0.100", |
| 57 | "available": "1.00", |
| 58 | "currency": "USD" |
| 59 | } |
| 60 | """ |
| 61 | return self._send_message('get', '/accounts/' + account_id) |
| 62 | |
| 63 | def get_accounts(self): |
| 64 | """ Get a list of trading all accounts. |
| 65 | |
| 66 | When you place an order, the funds for the order are placed on |
| 67 | hold. They cannot be used for other orders or withdrawn. Funds |
| 68 | will remain on hold until the order is filled or canceled. The |
| 69 | funds on hold for each account will be specified. |
| 70 | |
| 71 | Returns: |
| 72 | list: Info about all accounts. Example:: |
| 73 | [ |
| 74 | { |
| 75 | "id": "71452118-efc7-4cc4-8780-a5e22d4baa53", |