rate-api-python 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rate_api/__init__.py +10 -42
- {rate_api_python-1.0.1.dist-info → rate_api_python-1.0.3.dist-info}/METADATA +7 -26
- rate_api_python-1.0.3.dist-info/RECORD +6 -0
- rate_api_python-1.0.1.dist-info/RECORD +0 -6
- {rate_api_python-1.0.1.dist-info → rate_api_python-1.0.3.dist-info}/WHEEL +0 -0
- {rate_api_python-1.0.1.dist-info → rate_api_python-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {rate_api_python-1.0.1.dist-info → rate_api_python-1.0.3.dist-info}/top_level.txt +0 -0
rate_api/__init__.py
CHANGED
|
@@ -12,7 +12,7 @@ import urllib.error
|
|
|
12
12
|
import urllib.parse
|
|
13
13
|
import urllib.request
|
|
14
14
|
|
|
15
|
-
__version__ = "1.0.
|
|
15
|
+
__version__ = "1.0.3"
|
|
16
16
|
__all__ = ["RateApiClient", "RateApiError", "RateLimitError", "RateApiTimeoutError"]
|
|
17
17
|
|
|
18
18
|
|
|
@@ -56,14 +56,6 @@ class RateApiClient:
|
|
|
56
56
|
def pair(self, from_currency, to_currency):
|
|
57
57
|
return self._get(f"pair/{urllib.parse.quote(from_currency)}/{urllib.parse.quote(to_currency)}")
|
|
58
58
|
|
|
59
|
-
def timeseries(self, start_date, end_date, base="USD", symbols=None):
|
|
60
|
-
return self._get("timeseries", self._with_symbols(
|
|
61
|
-
{"start_date": start_date, "end_date": end_date, "base": base}, symbols))
|
|
62
|
-
|
|
63
|
-
def fluctuation(self, start_date, end_date, base="USD", symbols=None):
|
|
64
|
-
return self._get("fluctuation", self._with_symbols(
|
|
65
|
-
{"start_date": start_date, "end_date": end_date, "base": base}, symbols))
|
|
66
|
-
|
|
67
59
|
def crypto(self, symbols=None):
|
|
68
60
|
query = {"symbols": ",".join(symbols)} if symbols else {}
|
|
69
61
|
return self._get("crypto", query)
|
|
@@ -71,42 +63,18 @@ class RateApiClient:
|
|
|
71
63
|
def currencies(self):
|
|
72
64
|
return self._get("currencies")
|
|
73
65
|
|
|
66
|
+
def usage(self):
|
|
67
|
+
"""This key's current-month usage vs. its plan quota."""
|
|
68
|
+
return self._get("usage")
|
|
69
|
+
|
|
70
|
+
def quota(self):
|
|
71
|
+
"""Lean plan-quota / remaining-requests view."""
|
|
72
|
+
return self._get("quota")
|
|
73
|
+
|
|
74
74
|
def health(self):
|
|
75
|
+
"""Public service status + rate-data freshness (no key needed)."""
|
|
75
76
|
return self._request(f"{self.base_url}/health", {})
|
|
76
77
|
|
|
77
|
-
# ---- v2 endpoints (resolve to /api/v2 regardless of the configured base) ----
|
|
78
|
-
|
|
79
|
-
def _v2_base(self):
|
|
80
|
-
if self.base_url.endswith("/v1"):
|
|
81
|
-
return self.base_url[:-3] + "/v2"
|
|
82
|
-
return self.base_url.replace("/v1/", "/v2/")
|
|
83
|
-
|
|
84
|
-
def latest_v2(self, base="USD", symbols=None, include_metadata=False, include_change=False, precision=None):
|
|
85
|
-
"""v2 latest with metadata / 24h change / precision options."""
|
|
86
|
-
query = self._with_symbols({"base": base}, symbols)
|
|
87
|
-
if include_metadata:
|
|
88
|
-
query["include_metadata"] = "true"
|
|
89
|
-
if include_change:
|
|
90
|
-
query["include_change"] = "true"
|
|
91
|
-
if precision is not None:
|
|
92
|
-
query["precision"] = precision
|
|
93
|
-
return self._request(f"{self._v2_base()}/{self.api_key}/latest", query)
|
|
94
|
-
|
|
95
|
-
def historical_compare(self, date, compare_date=None, base="USD", symbols=None):
|
|
96
|
-
"""v2 historical with an optional compare_date for per-currency deltas (Pro+)."""
|
|
97
|
-
query = self._with_symbols({"date": date, "base": base}, symbols)
|
|
98
|
-
if compare_date:
|
|
99
|
-
query["compare_date"] = compare_date
|
|
100
|
-
return self._request(f"{self._v2_base()}/{self.api_key}/historical", query)
|
|
101
|
-
|
|
102
|
-
def batch_convert(self, conversions):
|
|
103
|
-
"""v2 batch conversion: list of {"from","to","amount"} dicts (Pro+). Max 100."""
|
|
104
|
-
return self._request(f"{self._v2_base()}/{self.api_key}/batch-convert", {}, method="POST", body=conversions)
|
|
105
|
-
|
|
106
|
-
def alerts(self):
|
|
107
|
-
"""List your configured rate alerts (Business+). Manage them in the dashboard."""
|
|
108
|
-
return self._request(f"{self._v2_base()}/{self.api_key}/alerts", {})
|
|
109
|
-
|
|
110
78
|
@staticmethod
|
|
111
79
|
def _with_symbols(query, symbols):
|
|
112
80
|
if symbols:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rate-api-python
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Official Python client for the Rate-API.com exchange-rate & crypto API
|
|
5
|
-
Author-email: Vilgar <
|
|
5
|
+
Author-email: Vilgar <digitalbrainsam@gmail.com>
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://rate-api.com
|
|
8
8
|
Project-URL: Documentation, https://rate-api.com/en/docs
|
|
@@ -49,39 +49,20 @@ print(rates["rates"]["EUR"])
|
|
|
49
49
|
client.convert("USD", "EUR", 100) # Pro+
|
|
50
50
|
client.historical("2026-01-15", "USD", ["EUR"]) # Pro+
|
|
51
51
|
client.pair("USD", "EUR") # single pair
|
|
52
|
-
client.timeseries("2026-01-01", "2026-01-31") # Business+
|
|
53
|
-
client.fluctuation("2026-01-01", "2026-01-31") # Business+
|
|
54
52
|
client.crypto(["BTC", "ETH"]) # Pro+
|
|
55
53
|
client.currencies() # supported currencies
|
|
54
|
+
client.usage() # current-month usage vs quota
|
|
56
55
|
client.health() # public
|
|
57
56
|
|
|
58
57
|
try:
|
|
59
|
-
client.
|
|
58
|
+
client.convert("USD", "ZZZ", 100)
|
|
60
59
|
except RateApiError as e:
|
|
61
|
-
print(e, e.status) # "
|
|
60
|
+
print(e, e.status) # "Invalid target currency" 400
|
|
62
61
|
```
|
|
63
62
|
|
|
64
|
-
##
|
|
63
|
+
## Methods
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```python
|
|
69
|
-
# Latest with 24h change, metadata and precision
|
|
70
|
-
r = client.latest_v2("USD", ["EUR", "GBP"], include_change=True, include_metadata=True, precision=4)
|
|
71
|
-
print(r["changes_pct"]["EUR"])
|
|
72
|
-
|
|
73
|
-
# Historical comparison between two dates (Pro+)
|
|
74
|
-
cmp = client.historical_compare("2026-01-15", "2026-01-01", "USD", ["EUR"])
|
|
75
|
-
|
|
76
|
-
# Batch conversion — up to 100 pairs in one call (Pro+)
|
|
77
|
-
batch = client.batch_convert([
|
|
78
|
-
{"from": "USD", "to": "EUR", "amount": 100},
|
|
79
|
-
{"from": "GBP", "to": "JPY", "amount": 50},
|
|
80
|
-
])
|
|
81
|
-
|
|
82
|
-
# Your configured rate alerts (Business+)
|
|
83
|
-
alerts = client.alerts()
|
|
84
|
-
```
|
|
65
|
+
`latest` · `convert` · `pair` · `historical` · `crypto` · `currencies` · `usage` · `quota` · `health`
|
|
85
66
|
|
|
86
67
|
## Errors
|
|
87
68
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
rate_api/__init__.py,sha256=CCLo6o7REOyFcqTcJULKSyEoNHVCvIbIbLZa-0-_8pU,6532
|
|
2
|
+
rate_api_python-1.0.3.dist-info/licenses/LICENSE,sha256=nCjIn_oDw98qUrGtfT5o19Qk02nDpkr3xbKgFtu3Z0A,1069
|
|
3
|
+
rate_api_python-1.0.3.dist-info/METADATA,sha256=8kLKSBgWirgKwyJX_HxMIm9r5tRm90VQyEbD0v0d-GM,3713
|
|
4
|
+
rate_api_python-1.0.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
rate_api_python-1.0.3.dist-info/top_level.txt,sha256=y8GBQa9yzwxT17UjU9xreA4yPbHqup7c0ryMbx1gYzI,9
|
|
6
|
+
rate_api_python-1.0.3.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
rate_api/__init__.py,sha256=3LBJWynyZ2cr1LSgqf77q3uDz9cvmZPglp2jlvJidhU,8314
|
|
2
|
-
rate_api_python-1.0.1.dist-info/licenses/LICENSE,sha256=nCjIn_oDw98qUrGtfT5o19Qk02nDpkr3xbKgFtu3Z0A,1069
|
|
3
|
-
rate_api_python-1.0.1.dist-info/METADATA,sha256=LE0rCncMicYuGjtDvdxxLyd2T4EW6cFFnKA-gwj1TA8,4358
|
|
4
|
-
rate_api_python-1.0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
-
rate_api_python-1.0.1.dist-info/top_level.txt,sha256=y8GBQa9yzwxT17UjU9xreA4yPbHqup7c0ryMbx1gYzI,9
|
|
6
|
-
rate_api_python-1.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|