rate-api-python 1.0.1__tar.gz → 1.0.3__tar.gz

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.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rate-api-python
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: Official Python client for the Rate-API.com exchange-rate & crypto API
5
- Author-email: Vilgar <digitalbrainsllc@gmail.com>
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.timeseries("2020-01-01", "2026-12-31")
58
+ client.convert("USD", "ZZZ", 100)
60
59
  except RateApiError as e:
61
- print(e, e.status) # "Date range too large. Maximum is 366 days." 400
60
+ print(e, e.status) # "Invalid target currency" 400
62
61
  ```
63
62
 
64
- ## v2 features
63
+ ## Methods
65
64
 
66
- The client exposes the v2 endpoints directly (they resolve to `/api/v2` regardless of base URL):
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
 
@@ -21,39 +21,20 @@ print(rates["rates"]["EUR"])
21
21
  client.convert("USD", "EUR", 100) # Pro+
22
22
  client.historical("2026-01-15", "USD", ["EUR"]) # Pro+
23
23
  client.pair("USD", "EUR") # single pair
24
- client.timeseries("2026-01-01", "2026-01-31") # Business+
25
- client.fluctuation("2026-01-01", "2026-01-31") # Business+
26
24
  client.crypto(["BTC", "ETH"]) # Pro+
27
25
  client.currencies() # supported currencies
26
+ client.usage() # current-month usage vs quota
28
27
  client.health() # public
29
28
 
30
29
  try:
31
- client.timeseries("2020-01-01", "2026-12-31")
30
+ client.convert("USD", "ZZZ", 100)
32
31
  except RateApiError as e:
33
- print(e, e.status) # "Date range too large. Maximum is 366 days." 400
32
+ print(e, e.status) # "Invalid target currency" 400
34
33
  ```
35
34
 
36
- ## v2 features
35
+ ## Methods
37
36
 
38
- The client exposes the v2 endpoints directly (they resolve to `/api/v2` regardless of base URL):
39
-
40
- ```python
41
- # Latest with 24h change, metadata and precision
42
- r = client.latest_v2("USD", ["EUR", "GBP"], include_change=True, include_metadata=True, precision=4)
43
- print(r["changes_pct"]["EUR"])
44
-
45
- # Historical comparison between two dates (Pro+)
46
- cmp = client.historical_compare("2026-01-15", "2026-01-01", "USD", ["EUR"])
47
-
48
- # Batch conversion — up to 100 pairs in one call (Pro+)
49
- batch = client.batch_convert([
50
- {"from": "USD", "to": "EUR", "amount": 100},
51
- {"from": "GBP", "to": "JPY", "amount": 50},
52
- ])
53
-
54
- # Your configured rate alerts (Business+)
55
- alerts = client.alerts()
56
- ```
37
+ `latest` · `convert` · `pair` · `historical` · `crypto` · `currencies` · `usage` · `quota` · `health`
57
38
 
58
39
  ## Errors
59
40
 
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rate-api-python"
7
- version = "1.0.1"
7
+ version = "1.0.3"
8
8
  description = "Official Python client for the Rate-API.com exchange-rate & crypto API"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
11
11
  requires-python = ">=3.8"
12
12
  keywords = ["exchange-rate", "currency", "forex", "crypto", "api", "rate-api"]
13
- authors = [{ name = "Vilgar", email = "digitalbrainsllc@gmail.com" }]
13
+ authors = [{ name = "Vilgar", email = "digitalbrainsam@gmail.com" }]
14
14
  classifiers = [
15
15
  "License :: OSI Approved :: MIT License",
16
16
  "Operating System :: OS Independent",
@@ -12,7 +12,7 @@ import urllib.error
12
12
  import urllib.parse
13
13
  import urllib.request
14
14
 
15
- __version__ = "1.0.1"
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.1
3
+ Version: 1.0.3
4
4
  Summary: Official Python client for the Rate-API.com exchange-rate & crypto API
5
- Author-email: Vilgar <digitalbrainsllc@gmail.com>
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.timeseries("2020-01-01", "2026-12-31")
58
+ client.convert("USD", "ZZZ", 100)
60
59
  except RateApiError as e:
61
- print(e, e.status) # "Date range too large. Maximum is 366 days." 400
60
+ print(e, e.status) # "Invalid target currency" 400
62
61
  ```
63
62
 
64
- ## v2 features
63
+ ## Methods
65
64
 
66
- The client exposes the v2 endpoints directly (they resolve to `/api/v2` regardless of base URL):
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
 
File without changes