GET/api/clients/{clientId}/currency/rate
Node.js · native fetch
1
2const baseUrl = process.env.CRASSULA_BASE_URL;
3const apiKey = process.env.CRASSULA_API_KEY;
4const clientId = process.env.CRASSULA_CLIENT_ID;
5
6const path = `/api/clients/${encodeURIComponent(clientId)}/currency/rate`;
7const query = new URLSearchParams({
8 "fromCurrency": "EUR",
9 "toCurrency": "GBP",
10 "amount": "1000.00"
11});
12const response = await fetch(`${baseUrl}${path}?${query}`, {
13 method: 'GET',
14 headers: {
15 Authorization: apiKey,
16 },
17});
18
19if (!response.ok) throw new Error(`HTTP ${response.status}`);
20const data = await response.json();
Python · requests
1
2import os
3from urllib.parse import quote
4import requests
5
6base_url = os.environ["CRASSULA_BASE_URL"]
7api_key = os.environ["CRASSULA_API_KEY"]
8client_id = os.environ["CRASSULA_CLIENT_ID"]
9
10path = f'/api/clients/{quote(client_id, safe="")}/currency/rate'
11response = requests.get(
12 f"{base_url}{path}",
13 headers={"Authorization": api_key},
14 params={
15 "fromCurrency": "EUR",
16 "toCurrency": "GBP",
17 "amount": "1000.00"
18 },
19 timeout=30,
20)
21response.raise_for_status()
22data = response.json()
Shell · cURL
1
2curl --get --request GET \
3 "${CRASSULA_BASE_URL}/api/clients/${CRASSULA_CLIENT_ID}/currency/rate" \
4 --header "Authorization: ${CRASSULA_API_KEY}" \
5 --data-urlencode 'fromCurrency=EUR' \
6 --data-urlencode 'toCurrency=GBP' \
7 --data-urlencode 'amount=1000.00'