Foreign Exchange Asynchronous Endpoints
This Foreign Exchange
endpoint provides asynchronous methods to interact with the foreign exchange of the authenticated user.
Example usage of the Foreign Exchange endpoint object:
import asyncio
from pyrevolut.client import AsyncClient
CREDS_JSON_LOC = "path/to/creds.json"
client = AsyncClient(
creds_loc=CREDS_JSON_LOC,
sandbox=True,
)
async def run():
async with client:
rate = await client.ForeignExchange.get_exchange_rate(
from_currency="USD",
to_currency="EUR",
amount=1.0,
)
print(rate)
asyncio.run(run())
EndpointForeignExchangeAsync
Bases: BaseEndpointAsync
The async Foreign Exchange API
Retrieve information on exchange rates between currencies, buy and sell currencies.
Source code in pyrevolut/api/foreign_exchange/endpoint/asynchronous.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
exchange_money(request_id, from_account_id, from_currency, to_account_id, to_currency, from_amount=None, to_amount=None, reference=None, **kwargs)
async
Exchange money using one of these methods:
Sell currency: You know the amount of currency to sell. For example, you want to exchange 135.5 USD to some EUR. Specify the amount in the from object.
Buy currency: You know the amount of currency to buy. For example, you want to exchange some USD to 200 EUR. Specify the amount in the to object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request_id |
str
|
The ID of the request, provided by you. It helps you identify the transaction in your system. To ensure that an exchange transaction is not processed multiple times if there are network or system errors, the same request_id should be used for requests related to the same transaction. |
required |
from_account_id |
UUID
|
The ID of the account to sell currency from. |
required |
from_currency |
str
|
The currency to sell in ISO 4217 format. |
required |
to_account_id |
UUID
|
The ID of the account to receive exchanged currency into. |
required |
to_currency |
str
|
The currency to buy in ISO 4217 format. |
required |
from_amount |
float | None
|
The amount of currency. Specify ONLY if you want to sell currency. |
None
|
to_amount |
float | None
|
The amount of currency. Specify ONLY if you want to buy currency. |
None
|
reference |
str | None
|
The reference for the exchange transaction, provided by you. It helps you to identify the transaction if you want to look it up later. |
None
|
Returns:
Type | Description |
---|---|
dict | Response
|
A dict with the information about the exchange transaction. |
Source code in pyrevolut/api/foreign_exchange/endpoint/asynchronous.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
get_exchange_rate(from_currency, to_currency, amount=None, **kwargs)
async
Get the sell exchange rate between two currencies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_currency |
str
|
The currency that you exchange from in ISO 4217 format. |
required |
to_currency |
str
|
The currency that you exchange to in ISO 4217 format. |
required |
amount |
float | None
|
The amount of the currency to exchange from. The default value is 1.00 if not provided. |
None
|
Returns:
Type | Description |
---|---|
dict | Response
|
A dict with the information about the exchange rate. |
Source code in pyrevolut/api/foreign_exchange/endpoint/asynchronous.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|