-
Notifications
You must be signed in to change notification settings - Fork 7
Add documentation to README #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,21 +10,134 @@ An unofficial, experimental Python client library for the [TransferWise API](htt | |||||
| # Within your project directory | ||||||
| pip install pywisetransfer | ||||||
| ``` | ||||||
| After installation, you should be able to import the package. | ||||||
|
|
||||||
| ```python | ||||||
| import pywisetransfer | ||||||
| ``` | ||||||
|
|
||||||
| ## Usage | ||||||
|
|
||||||
| Wise provides [two APIs](https://docs.wise.com/api-docs/api-reference#environments): `live` and `sandbox`. | ||||||
| You can use either of these environments with this library. | ||||||
|
|
||||||
| ### API Key | ||||||
|
|
||||||
| In order to use the API, you need to obtain an API key. | ||||||
| This key looks like this: `12345678-1234-1234-1234-123456789abcde` | ||||||
|
|
||||||
| To use the sandbox API, log into [sandbox.transferwise.tech]. | ||||||
| Then, go to Settings 🠚 Developer Tools 🠚 API-Tokens. | ||||||
| Create and copy a new API key. | ||||||
|
|
||||||
| To use your own account, log into [wise.com](https://wise.com). | ||||||
| Then click on your account at the top right 🠚 Integrations and Tools 🠚 Developer Tools 🠚 API Tokens and add a new token. | ||||||
|
|
||||||
| [sandbox.transferwise.tech]: https://sandbox.transferwise.tech | ||||||
|
|
||||||
| ### API Requests | ||||||
|
|
||||||
| The API requests are made using the [requests](https://requests.readthedocs.io/en/latest/) library. | ||||||
| First of all, you create a `Client` object: | ||||||
|
|
||||||
| - Create a `Client` object with your API key for the `live` environment: | ||||||
|
|
||||||
| ```python | ||||||
| client = pywisetransfer.Client(api_key="your-api-key-here", environment="live") | ||||||
| ``` | ||||||
|
|
||||||
| - Create a `Client` object with your API key for the `sandbox` environment: | ||||||
|
|
||||||
| ```python | ||||||
| client = pywisetransfer.Client(api_key="your-api-key-here") | ||||||
| ``` | ||||||
|
Comment on lines
+45
to
+53
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally I think we should make this readme friendly to newcomers, but I also want to balance that against how safe and mature the code is (I'll be more comfortable if we can reduce the number of external dependencies, for example). Even when we're very confident about the safety and quality of the code, we should still write the documentation in a way that requires people to be very careful to enable production usage. So: at the very least we should present the |
||||||
|
|
||||||
| ## Examples | ||||||
|
|
||||||
| This section provides a few examples of how to use this package. | ||||||
|
|
||||||
| ### Profiles | ||||||
|
|
||||||
| This library follows the **[Wise API Reference]**. | ||||||
| So, if you find e.g. profile here, you can look up all the values of it in the [Wise API Reference]. | ||||||
|
|
||||||
| If you create a sandbox account, you should have two profiles: `business` and `personal`. | ||||||
|
|
||||||
| ```python | ||||||
| import pywisetransfer | ||||||
| >>> for profile in client.profiles.list(): | ||||||
| ... print(f"id: {profile.id}") | ||||||
| ... print(f"type: {profile.type}") | ||||||
| ... if profile.type == "personal": | ||||||
| ... print(f"name: {profile.details.firstName} {profile.details.lastName}") | ||||||
| ... else: | ||||||
| ... print(f"name: {profile.details.name}") | ||||||
| ... print() | ||||||
| ... | ||||||
| id: 28577318 | ||||||
| type: personal | ||||||
| name: Teresa Adams | ||||||
|
|
||||||
| id: 28577319 | ||||||
| type: business | ||||||
| name: Law and Daughters 6423 | ||||||
| ``` | ||||||
|
|
||||||
| ### Receive Money | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| One profile can have several accounts in different currencies. | ||||||
| This shows which currencies are accepted and how to receive money. | ||||||
|
|
||||||
| ```python | ||||||
| >>> for profile in client.profiles.list(): | ||||||
| ... accounts = client.account_details.list(profile_id=profile.id) | ||||||
| ... print(f"\ntype: {profile.type}") | ||||||
| ... for account in accounts: | ||||||
| ... print( | ||||||
| ... f" currency: {account.currency.code}" | ||||||
| ... f" receive with: {', '.join(feature.title for feature in account.bankFeatures if feature.supported)}") | ||||||
| ... | ||||||
|
|
||||||
| client = pywisetransfer.Client(api_key="your-api-key-here") | ||||||
| type: personal | ||||||
| currency: EUR receive with: Receive locally, Receive internationally (Swift), Set up Direct Debits, Receive from PayPal and Stripe | ||||||
| currency: GBP receive with: Receive locally, Receive internationally (Swift), Set up Direct Debits, Receive from PayPal and Stripe | ||||||
| currency: USD receive with: Receive locally, Receive internationally (Swift), Set up Direct Debits, Receive from PayPal and Stripe | ||||||
| currency: AUD receive with: Receive locally, Set up Direct Debits | ||||||
| currency: NZD receive with: Receive locally | ||||||
| currency: CAD receive with: Receive locally, Set up Direct Debits | ||||||
| currency: HUF receive with: Receive locally | ||||||
| currency: MYR receive with: | ||||||
| currency: RON receive with: Receive locally | ||||||
| currency: SGD receive with: Receive locally | ||||||
| currency: TRY receive with: Receive locally | ||||||
|
|
||||||
| type: business | ||||||
| currency: EUR receive with: Receive locally, Receive internationally (Swift), Set up Direct Debits, Receive from PayPal and Stripe | ||||||
| currency: GBP receive with: Receive locally, Receive internationally (Swift), Set up Direct Debits, Receive from PayPal and Stripe | ||||||
| currency: USD receive with: Receive locally, Receive internationally (Swift), Set up Direct Debits, Receive from PayPal and Stripe | ||||||
| currency: AUD receive with: Receive locally, Set up Direct Debits | ||||||
| currency: NZD receive with: Receive locally | ||||||
| currency: CAD receive with: Receive locally, Set up Direct Debits | ||||||
| currency: HUF receive with: Receive locally | ||||||
| currency: MYR receive with: | ||||||
| currency: RON receive with: Receive locally | ||||||
| currency: SGD receive with: Receive locally | ||||||
| currency: TRY receive with: Receive locally | ||||||
|
|
||||||
| ``` | ||||||
|
|
||||||
| [Wise API Reference]: https://docs.wise.com/api-docs/api-reference | ||||||
|
|
||||||
| ### Balance | ||||||
|
|
||||||
| This code retrieves the balance for each currency in each account. | ||||||
|
|
||||||
| ```python | ||||||
| >>> for profile in client.profiles.list(): | ||||||
| ... print(f"type: {profile.type} {', '.join(f'{balance.totalWorth.value}{balance.totalWorth.currency}' for balance in client.balances.list(profile_id=profile.id))}") | ||||||
| ... | ||||||
| type: personal 1000000.0GBP, 1000000.0EUR, 1000000.0USD, 1000000.0AUD | ||||||
| type: business 1000000.0GBP, 1000000.0EUR, 1000000.0USD, 1000000.0AUD | ||||||
|
|
||||||
| for profile in client.profiles.list(): | ||||||
| accounts = client.borderless_accounts.list(profile_id=profile.id) | ||||||
| for account in accounts: | ||||||
| currencies = [balance.currency for balance in account.balances] | ||||||
| print(f"AccountID={account.id}, Currencies={currencies}") | ||||||
| ``` | ||||||
|
|
||||||
| ### Webhook signature verification | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's omit this; the package is a simple one, and provided that the installation process succeeds, this should too.
We should consider including it in complete code examples, however also avoid too much repetition.