belvo.client
1import os 2 3from . import resources 4from .enums import Environment 5from .exceptions import BelvoAPIException 6from .http import APISession 7 8 9class Client: 10 def __init__(self, secret_key_id: str, secret_key_password: str, url: str = None) -> None: 11 """# Connect to the Belvo API 12 13 In order to use Belvo API, you will have to login into a new session by using 14 a _secret key_. 15 16 Secret keys are generated from the Belvo API dashboard. For more information, please visit 17 [our Developers portal](https://developers.belvo.com/docs/get-your-belvo-api-keys) 18 19 ### Method 20 21 ```python 22 def __init__(secret_key_id: str, secret_key_password: str, url: str = None) -> None: 23 ... 24 ``` 25 26 You **must** provide your `secret_key_id` and `secret_key_password`. 27 28 The `url` tells the client to which Belvo API host should attempt to connect, 29 this allows you to switch from a sandbox to a production environment. 30 31 You can also set which Belvo API host to use, by setting the `BELVO_API_URL` 32 environment variable. 33 34 When creating a new instance of `Client`, it will automatically perform a login 35 and create a `JWTSession` (if the credentials are valid). 36 37 38 ### Example 39 ```python 40 # Creating a client instance to connect to Belvo API 41 from belvo.client import Client 42 43 my_client = Client( 44 "your-secret-key-id", 45 "your-secret-key-password", 46 "https://api.belvo.com" 47 ) 48 49 50 # Creating a client that takes url from the environment. 51 # We assume that you have set BELVO_API_URL before 52 # (e.g. export BELVO_API_URL=https://sandbox.belvo.com 53 my_client = Client( 54 "your-secret-key-id", 55 "your-secret-key-password" 56 ) 57 ``` 58 59 ## Nested resources 60 61 All resources in the Belvo API are nested attributes in your client instance, 62 these resources are available **only** if you provide valid credentials. 63 64 Args: 65 secret_key_id (str): Your Belvo secret ID. 66 secret_key_password (str): Your Belvo secret password. 67 url (str, optional): The URL of the environment you want to connect to. 68 69 Raises: 70 BelvoAPIException 71 """ 72 if url is None: 73 url = os.getenv("BELVO_API_URL") 74 75 url = Environment.get_url(url) 76 if not url: 77 raise BelvoAPIException("You need to provide a URL or a valid environment.") 78 79 self.session = APISession(url) 80 81 if not self.session.login(secret_key_id, secret_key_password): 82 raise BelvoAPIException("Login failed.") 83 84 self._links = resources.Links(self.session) 85 self._accounts = resources.Accounts(self.session) 86 self._transactions = resources.Transactions(self.session) 87 self._balances = resources.Balances(self.session) 88 self._institutions = resources.Institutions(self.session) 89 self._incomes = resources.Incomes(self.session) 90 self._owners = resources.Owners(self.session) 91 self._invoices = resources.Invoices(self.session) 92 self._recurring_expenses = resources.RecurringExpenses(self.session) 93 self._risk_insights = resources.RiskInsights(self.session) 94 self._tax_returns = resources.TaxReturns(self.session) 95 self._tax_declarations = resources.TaxDeclarations(self.session) 96 self._tax_status = resources.TaxStatus(self.session) 97 self._tax_compliance_status = resources.TaxComplianceStatus(self.session) 98 self._tax_retentions = resources.TaxRetentions(self.session) 99 self._statements = resources.Statements(self.session) 100 self._widget_token = resources.WidgetToken(self.session) 101 self._investments_portfolios = resources.InvestmentsPortfolios(self.session) 102 self._employment_records = resources.EmploymentRecords(self.session) 103 104 @property 105 def Links(self): 106 return self._links 107 108 @property 109 def Accounts(self): 110 return self._accounts 111 112 @property 113 def Transactions(self): 114 return self._transactions 115 116 @property 117 def Balances(self): 118 return self._balances 119 120 @property 121 def Institutions(self): 122 return self._institutions 123 124 @property 125 def Incomes(self): 126 return self._incomes 127 128 @property 129 def Owners(self): 130 return self._owners 131 132 @property 133 def Invoices(self): 134 return self._invoices 135 136 @property 137 def RecurringExpenses(self): 138 return self._recurring_expenses 139 140 @property 141 def RiskInsights(self): 142 return self._risk_insights 143 144 @property 145 def TaxReturns(self): 146 return self._tax_returns 147 148 @property 149 def TaxDeclarations(self): 150 return self._tax_declarations 151 152 @property 153 def TaxComplianceStatus(self): 154 return self._tax_compliance_status 155 156 @property 157 def TaxStatus(self): 158 return self._tax_status 159 160 @property 161 def TaxRetentions(self): 162 return self._tax_retentions 163 164 @property 165 def Statements(self): 166 return self._statements 167 168 @property 169 def WidgetToken(self): 170 return self._widget_token 171 172 @property 173 def InvestmentsPortfolios(self): 174 return self._investments_portfolios 175 176 @property 177 def EmploymentRecords(self): 178 return self._employment_records
10class Client: 11 def __init__(self, secret_key_id: str, secret_key_password: str, url: str = None) -> None: 12 """# Connect to the Belvo API 13 14 In order to use Belvo API, you will have to login into a new session by using 15 a _secret key_. 16 17 Secret keys are generated from the Belvo API dashboard. For more information, please visit 18 [our Developers portal](https://developers.belvo.com/docs/get-your-belvo-api-keys) 19 20 ### Method 21 22 ```python 23 def __init__(secret_key_id: str, secret_key_password: str, url: str = None) -> None: 24 ... 25 ``` 26 27 You **must** provide your `secret_key_id` and `secret_key_password`. 28 29 The `url` tells the client to which Belvo API host should attempt to connect, 30 this allows you to switch from a sandbox to a production environment. 31 32 You can also set which Belvo API host to use, by setting the `BELVO_API_URL` 33 environment variable. 34 35 When creating a new instance of `Client`, it will automatically perform a login 36 and create a `JWTSession` (if the credentials are valid). 37 38 39 ### Example 40 ```python 41 # Creating a client instance to connect to Belvo API 42 from belvo.client import Client 43 44 my_client = Client( 45 "your-secret-key-id", 46 "your-secret-key-password", 47 "https://api.belvo.com" 48 ) 49 50 51 # Creating a client that takes url from the environment. 52 # We assume that you have set BELVO_API_URL before 53 # (e.g. export BELVO_API_URL=https://sandbox.belvo.com 54 my_client = Client( 55 "your-secret-key-id", 56 "your-secret-key-password" 57 ) 58 ``` 59 60 ## Nested resources 61 62 All resources in the Belvo API are nested attributes in your client instance, 63 these resources are available **only** if you provide valid credentials. 64 65 Args: 66 secret_key_id (str): Your Belvo secret ID. 67 secret_key_password (str): Your Belvo secret password. 68 url (str, optional): The URL of the environment you want to connect to. 69 70 Raises: 71 BelvoAPIException 72 """ 73 if url is None: 74 url = os.getenv("BELVO_API_URL") 75 76 url = Environment.get_url(url) 77 if not url: 78 raise BelvoAPIException("You need to provide a URL or a valid environment.") 79 80 self.session = APISession(url) 81 82 if not self.session.login(secret_key_id, secret_key_password): 83 raise BelvoAPIException("Login failed.") 84 85 self._links = resources.Links(self.session) 86 self._accounts = resources.Accounts(self.session) 87 self._transactions = resources.Transactions(self.session) 88 self._balances = resources.Balances(self.session) 89 self._institutions = resources.Institutions(self.session) 90 self._incomes = resources.Incomes(self.session) 91 self._owners = resources.Owners(self.session) 92 self._invoices = resources.Invoices(self.session) 93 self._recurring_expenses = resources.RecurringExpenses(self.session) 94 self._risk_insights = resources.RiskInsights(self.session) 95 self._tax_returns = resources.TaxReturns(self.session) 96 self._tax_declarations = resources.TaxDeclarations(self.session) 97 self._tax_status = resources.TaxStatus(self.session) 98 self._tax_compliance_status = resources.TaxComplianceStatus(self.session) 99 self._tax_retentions = resources.TaxRetentions(self.session) 100 self._statements = resources.Statements(self.session) 101 self._widget_token = resources.WidgetToken(self.session) 102 self._investments_portfolios = resources.InvestmentsPortfolios(self.session) 103 self._employment_records = resources.EmploymentRecords(self.session) 104 105 @property 106 def Links(self): 107 return self._links 108 109 @property 110 def Accounts(self): 111 return self._accounts 112 113 @property 114 def Transactions(self): 115 return self._transactions 116 117 @property 118 def Balances(self): 119 return self._balances 120 121 @property 122 def Institutions(self): 123 return self._institutions 124 125 @property 126 def Incomes(self): 127 return self._incomes 128 129 @property 130 def Owners(self): 131 return self._owners 132 133 @property 134 def Invoices(self): 135 return self._invoices 136 137 @property 138 def RecurringExpenses(self): 139 return self._recurring_expenses 140 141 @property 142 def RiskInsights(self): 143 return self._risk_insights 144 145 @property 146 def TaxReturns(self): 147 return self._tax_returns 148 149 @property 150 def TaxDeclarations(self): 151 return self._tax_declarations 152 153 @property 154 def TaxComplianceStatus(self): 155 return self._tax_compliance_status 156 157 @property 158 def TaxStatus(self): 159 return self._tax_status 160 161 @property 162 def TaxRetentions(self): 163 return self._tax_retentions 164 165 @property 166 def Statements(self): 167 return self._statements 168 169 @property 170 def WidgetToken(self): 171 return self._widget_token 172 173 @property 174 def InvestmentsPortfolios(self): 175 return self._investments_portfolios 176 177 @property 178 def EmploymentRecords(self): 179 return self._employment_records
11 def __init__(self, secret_key_id: str, secret_key_password: str, url: str = None) -> None: 12 """# Connect to the Belvo API 13 14 In order to use Belvo API, you will have to login into a new session by using 15 a _secret key_. 16 17 Secret keys are generated from the Belvo API dashboard. For more information, please visit 18 [our Developers portal](https://developers.belvo.com/docs/get-your-belvo-api-keys) 19 20 ### Method 21 22 ```python 23 def __init__(secret_key_id: str, secret_key_password: str, url: str = None) -> None: 24 ... 25 ``` 26 27 You **must** provide your `secret_key_id` and `secret_key_password`. 28 29 The `url` tells the client to which Belvo API host should attempt to connect, 30 this allows you to switch from a sandbox to a production environment. 31 32 You can also set which Belvo API host to use, by setting the `BELVO_API_URL` 33 environment variable. 34 35 When creating a new instance of `Client`, it will automatically perform a login 36 and create a `JWTSession` (if the credentials are valid). 37 38 39 ### Example 40 ```python 41 # Creating a client instance to connect to Belvo API 42 from belvo.client import Client 43 44 my_client = Client( 45 "your-secret-key-id", 46 "your-secret-key-password", 47 "https://api.belvo.com" 48 ) 49 50 51 # Creating a client that takes url from the environment. 52 # We assume that you have set BELVO_API_URL before 53 # (e.g. export BELVO_API_URL=https://sandbox.belvo.com 54 my_client = Client( 55 "your-secret-key-id", 56 "your-secret-key-password" 57 ) 58 ``` 59 60 ## Nested resources 61 62 All resources in the Belvo API are nested attributes in your client instance, 63 these resources are available **only** if you provide valid credentials. 64 65 Args: 66 secret_key_id (str): Your Belvo secret ID. 67 secret_key_password (str): Your Belvo secret password. 68 url (str, optional): The URL of the environment you want to connect to. 69 70 Raises: 71 BelvoAPIException 72 """ 73 if url is None: 74 url = os.getenv("BELVO_API_URL") 75 76 url = Environment.get_url(url) 77 if not url: 78 raise BelvoAPIException("You need to provide a URL or a valid environment.") 79 80 self.session = APISession(url) 81 82 if not self.session.login(secret_key_id, secret_key_password): 83 raise BelvoAPIException("Login failed.") 84 85 self._links = resources.Links(self.session) 86 self._accounts = resources.Accounts(self.session) 87 self._transactions = resources.Transactions(self.session) 88 self._balances = resources.Balances(self.session) 89 self._institutions = resources.Institutions(self.session) 90 self._incomes = resources.Incomes(self.session) 91 self._owners = resources.Owners(self.session) 92 self._invoices = resources.Invoices(self.session) 93 self._recurring_expenses = resources.RecurringExpenses(self.session) 94 self._risk_insights = resources.RiskInsights(self.session) 95 self._tax_returns = resources.TaxReturns(self.session) 96 self._tax_declarations = resources.TaxDeclarations(self.session) 97 self._tax_status = resources.TaxStatus(self.session) 98 self._tax_compliance_status = resources.TaxComplianceStatus(self.session) 99 self._tax_retentions = resources.TaxRetentions(self.session) 100 self._statements = resources.Statements(self.session) 101 self._widget_token = resources.WidgetToken(self.session) 102 self._investments_portfolios = resources.InvestmentsPortfolios(self.session) 103 self._employment_records = resources.EmploymentRecords(self.session)
Connect to the Belvo API
In order to use Belvo API, you will have to login into a new session by using a _secret key_.
Secret keys are generated from the Belvo API dashboard. For more information, please visit our Developers portal
Method
def __init__(secret_key_id: str, secret_key_password: str, url: str = None) -> None:
...
You must provide your secret_key_id
and secret_key_password
.
The url
tells the client to which Belvo API host should attempt to connect,
this allows you to switch from a sandbox to a production environment.
You can also set which Belvo API host to use, by setting the BELVO_API_URL
environment variable.
When creating a new instance of Client
, it will automatically perform a login
and create a JWTSession
(if the credentials are valid).
Example
# Creating a client instance to connect to Belvo API
from belvo.client import Client
my_client = Client(
"your-secret-key-id",
"your-secret-key-password",
"https://api.belvo.com"
)
# Creating a client that takes url from the environment.
# We assume that you have set BELVO_API_URL before
# (e.g. export BELVO_API_URL=https://sandbox.belvo.com
my_client = Client(
"your-secret-key-id",
"your-secret-key-password"
)
Nested resources
All resources in the Belvo API are nested attributes in your client instance, these resources are available only if you provide valid credentials.
Arguments:
- secret_key_id (str): Your Belvo secret ID.
- secret_key_password (str): Your Belvo secret password.
- url (str, optional): The URL of the environment you want to connect to.
Raises:
- BelvoAPIException