@allratestoday/sdk 1.0.0 → 1.2.0
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.
- package/README.md +23 -23
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +8 -3
- package/dist/index.mjs +8 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,12 +12,12 @@ npm install @allratestoday/sdk
|
|
|
12
12
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Get your free API key at [allratestoday.com/register](https://allratestoday.com/register) (300 requests/month free).
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
import AllRatesToday from '@allratestoday/sdk';
|
|
19
19
|
|
|
20
|
-
const client = new AllRatesToday();
|
|
20
|
+
const client = new AllRatesToday({ apiKey: 'art_live_your_key_here' });
|
|
21
21
|
|
|
22
22
|
// Get exchange rate
|
|
23
23
|
const rate = await client.getRate('USD', 'EUR');
|
|
@@ -26,18 +26,6 @@ console.log(`1 USD = ${rate.rate} EUR`);
|
|
|
26
26
|
// Convert amount
|
|
27
27
|
const result = await client.convert('USD', 'EUR', 100);
|
|
28
28
|
console.log(`$100 = €${result.result}`);
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Authenticated Rates (API Key Required)
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import AllRatesToday from '@allratestoday/sdk';
|
|
35
|
-
|
|
36
|
-
const client = new AllRatesToday({ apiKey: 'art_live_your_key_here' });
|
|
37
|
-
|
|
38
|
-
// Get authenticated rates
|
|
39
|
-
const rates = await client.getRates('USD', 'EUR');
|
|
40
|
-
console.log(rates);
|
|
41
29
|
|
|
42
30
|
// Get historical rates
|
|
43
31
|
const history = await client.getHistoricalRates('USD', 'EUR', '30d');
|
|
@@ -46,22 +34,24 @@ console.log(history.rates);
|
|
|
46
34
|
|
|
47
35
|
## API Reference
|
|
48
36
|
|
|
49
|
-
### `new AllRatesToday(options
|
|
37
|
+
### `new AllRatesToday(options)`
|
|
50
38
|
|
|
51
39
|
| Option | Type | Default | Description |
|
|
52
40
|
|--------|------|---------|-------------|
|
|
53
|
-
| `apiKey` | `string` |
|
|
41
|
+
| `apiKey` | `string` | **required** | Your API key ([register free](https://allratestoday.com/register)) |
|
|
54
42
|
| `baseUrl` | `string` | `https://allratestoday.com` | API base URL |
|
|
55
43
|
| `timeout` | `number` | `10000` | Request timeout in ms |
|
|
56
44
|
|
|
57
45
|
### Methods
|
|
58
46
|
|
|
59
|
-
| Method |
|
|
60
|
-
|
|
61
|
-
| `getRate(from, to, amount?)` |
|
|
62
|
-
| `convert(from, to, amount)` |
|
|
63
|
-
| `getRates(source, target)` |
|
|
64
|
-
| `getHistoricalRates(source, target, period)` |
|
|
47
|
+
| Method | Description |
|
|
48
|
+
|--------|-------------|
|
|
49
|
+
| `getRate(from, to, amount?)` | Get exchange rate between two currencies |
|
|
50
|
+
| `convert(from, to, amount)` | Convert amount between currencies |
|
|
51
|
+
| `getRates(source, target)` | Get rate data with metadata |
|
|
52
|
+
| `getHistoricalRates(source, target, period)` | Historical rates (1d/7d/30d/1y) |
|
|
53
|
+
|
|
54
|
+
All methods require an API key.
|
|
65
55
|
|
|
66
56
|
### Error Handling
|
|
67
57
|
|
|
@@ -78,10 +68,20 @@ try {
|
|
|
78
68
|
}
|
|
79
69
|
```
|
|
80
70
|
|
|
71
|
+
## Pricing
|
|
72
|
+
|
|
73
|
+
| Plan | Requests/Month | Price |
|
|
74
|
+
|------|---------------|-------|
|
|
75
|
+
| Free | 300 | Free |
|
|
76
|
+
| Small | 5,000 | €4.99/mo |
|
|
77
|
+
| Medium | 10,000 | €9.99/mo |
|
|
78
|
+
| Large | 100,000 | €49.99/mo |
|
|
79
|
+
|
|
81
80
|
## Links
|
|
82
81
|
|
|
83
82
|
- [API Documentation](https://allratestoday.com/docs)
|
|
84
|
-
- [
|
|
83
|
+
- [Register (Free)](https://allratestoday.com/register)
|
|
84
|
+
- [Dashboard](https://allratestoday.com/profile)
|
|
85
85
|
- [Pricing](https://allratestoday.com/pricing)
|
|
86
86
|
- [Status](https://allratestoday.com/status)
|
|
87
87
|
|
package/dist/index.d.mts
CHANGED
|
@@ -38,10 +38,14 @@ declare class AllRatesToday {
|
|
|
38
38
|
private apiKey?;
|
|
39
39
|
private baseUrl;
|
|
40
40
|
private timeout;
|
|
41
|
+
/**
|
|
42
|
+
* Create an AllRatesToday client.
|
|
43
|
+
* @param options - API key is required. Register for free at https://allratestoday.com/register
|
|
44
|
+
*/
|
|
41
45
|
constructor(options?: AllRatesTodayOptions);
|
|
42
46
|
private request;
|
|
43
47
|
/**
|
|
44
|
-
* Get exchange rate between two currencies (
|
|
48
|
+
* Get exchange rate between two currencies (requires API key)
|
|
45
49
|
*/
|
|
46
50
|
getRate(from: string, to: string, amount?: number): Promise<RateResponse>;
|
|
47
51
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -38,10 +38,14 @@ declare class AllRatesToday {
|
|
|
38
38
|
private apiKey?;
|
|
39
39
|
private baseUrl;
|
|
40
40
|
private timeout;
|
|
41
|
+
/**
|
|
42
|
+
* Create an AllRatesToday client.
|
|
43
|
+
* @param options - API key is required. Register for free at https://allratestoday.com/register
|
|
44
|
+
*/
|
|
41
45
|
constructor(options?: AllRatesTodayOptions);
|
|
42
46
|
private request;
|
|
43
47
|
/**
|
|
44
|
-
* Get exchange rate between two currencies (
|
|
48
|
+
* Get exchange rate between two currencies (requires API key)
|
|
45
49
|
*/
|
|
46
50
|
getRate(from: string, to: string, amount?: number): Promise<RateResponse>;
|
|
47
51
|
/**
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,10 @@ __export(index_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
var BASE_URL = "https://allratestoday.com";
|
|
29
29
|
var AllRatesToday = class {
|
|
30
|
+
/**
|
|
31
|
+
* Create an AllRatesToday client.
|
|
32
|
+
* @param options - API key is required. Register for free at https://allratestoday.com/register
|
|
33
|
+
*/
|
|
30
34
|
constructor(options = {}) {
|
|
31
35
|
this.apiKey = options.apiKey;
|
|
32
36
|
this.baseUrl = options.baseUrl || BASE_URL;
|
|
@@ -55,12 +59,13 @@ var AllRatesToday = class {
|
|
|
55
59
|
return response.json();
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
58
|
-
* Get exchange rate between two currencies (
|
|
62
|
+
* Get exchange rate between two currencies (requires API key)
|
|
59
63
|
*/
|
|
60
64
|
async getRate(from, to, amount) {
|
|
61
|
-
|
|
65
|
+
if (!this.apiKey) throw new AllRatesTodayError("API key required. Register for free at https://allratestoday.com/register");
|
|
66
|
+
const params = { source: from, target: to };
|
|
62
67
|
if (amount !== void 0) params.amount = String(amount);
|
|
63
|
-
return this.request("/api/
|
|
68
|
+
return this.request("/api/v1/rates", params);
|
|
64
69
|
}
|
|
65
70
|
/**
|
|
66
71
|
* Get authenticated exchange rate (requires API key)
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var BASE_URL = "https://allratestoday.com";
|
|
3
3
|
var AllRatesToday = class {
|
|
4
|
+
/**
|
|
5
|
+
* Create an AllRatesToday client.
|
|
6
|
+
* @param options - API key is required. Register for free at https://allratestoday.com/register
|
|
7
|
+
*/
|
|
4
8
|
constructor(options = {}) {
|
|
5
9
|
this.apiKey = options.apiKey;
|
|
6
10
|
this.baseUrl = options.baseUrl || BASE_URL;
|
|
@@ -29,12 +33,13 @@ var AllRatesToday = class {
|
|
|
29
33
|
return response.json();
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
|
-
* Get exchange rate between two currencies (
|
|
36
|
+
* Get exchange rate between two currencies (requires API key)
|
|
33
37
|
*/
|
|
34
38
|
async getRate(from, to, amount) {
|
|
35
|
-
|
|
39
|
+
if (!this.apiKey) throw new AllRatesTodayError("API key required. Register for free at https://allratestoday.com/register");
|
|
40
|
+
const params = { source: from, target: to };
|
|
36
41
|
if (amount !== void 0) params.amount = String(amount);
|
|
37
|
-
return this.request("/api/
|
|
42
|
+
return this.request("/api/v1/rates", params);
|
|
38
43
|
}
|
|
39
44
|
/**
|
|
40
45
|
* Get authenticated exchange rate (requires API key)
|