cbb-exchange-rate 1.3.27 โ 1.3.30
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 +63 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
[](https://github.com/AllRates-Today/cbb-exchange-rate/blob/main/LICENSE)
|
|
5
5
|
[](https://www.npmjs.com/package/cbb-exchange-rate)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
|
-
[](https://allratestoday.com/central-bank-rates-api/cbb/)
|
|
8
8
|
[](https://allratestoday.com/central-bank-rates-api/cbb/)
|
|
9
9
|
|
|
10
10
|
**Official Central Bank of Bahrain (Bahrain) daily exchange rates for Node.js and TypeScript. The published central bank rates behind tax filings, customs valuations, audits, and compliant invoicing โ not market estimates, but the numbers Central Bank of Bahrain itself prints, every business day.**
|
|
11
11
|
|
|
12
12
|
## ๐ Why this client?
|
|
13
13
|
|
|
14
|
-
- ๐๏ธ **Official
|
|
14
|
+
- ๐๏ธ **Official rates** โ Central Bank of Bahrain's own table, with the publisher's own `rate_date` on every response
|
|
15
15
|
- ๐
**History back to 2016** โ point-in-time tables and daily series for any past date
|
|
16
|
-
- ๐ **
|
|
16
|
+
- ๐ **Official vs derived, always flagged** โ computed inverse/cross pairs carry `derived: true`, never mixed with official prints
|
|
17
17
|
- โก **Zero dependencies** โ pure ESM + CJS over global `fetch`; Node 18+, Bun, Deno, and edge runtimes
|
|
18
18
|
- ๐ท **Type-safe** โ full TypeScript definitions shipped with the package
|
|
19
19
|
- ๐งพ **Compliance-grade metadata** โ `rate_type`, publication date, and source disclaimer on every response
|
|
@@ -24,14 +24,55 @@
|
|
|
24
24
|
|
|
25
25
|
Get a free API key at [allratestoday.com/register](https://allratestoday.com/register) โ no credit card required. Latest rates are on every plan, including free.
|
|
26
26
|
|
|
27
|
-
## ๐ Latest
|
|
27
|
+
## ๐ Latest official table
|
|
28
28
|
|
|
29
29
|
[](https://allratestoday.com/central-bank-rates-api/cbb/)
|
|
30
30
|
|
|
31
31
|
The image is rendered live from the keyless endpoint, so it follows the central bank's publications on npm and on GitHub alike without a new release. The same table as text is folded below for search and copy-paste: on GitHub [a daily Action](.github/workflows/daily-table.yml) refreshes it whenever the central bank publishes a new table; on npm it is as of the package's publish date.
|
|
32
32
|
|
|
33
33
|
<!-- daily-table:start -->
|
|
34
|
-
|
|
34
|
+
<details>
|
|
35
|
+
<summary>Table as text: published 2026-11-11 by Central Bank of Bahrain โ 33 rates. Updated 2026-11-11.</summary>
|
|
36
|
+
|
|
37
|
+
| Base | Quote | Type | Rate |
|
|
38
|
+
| --- | --- | --- | ---: |
|
|
39
|
+
| AED | BHD | reference | 0.102389 |
|
|
40
|
+
| ANG | BHD | reference | 0.210101 |
|
|
41
|
+
| AUD | BHD | reference | 0.258462 |
|
|
42
|
+
| BDT | BHD | reference | 0.003018 |
|
|
43
|
+
| CAD | BHD | reference | 0.265042 |
|
|
44
|
+
| CHF | BHD | reference | 0.455525 |
|
|
45
|
+
| CNY | BHD | reference | 0.056321 |
|
|
46
|
+
| EGP | BHD | reference | 0.007054 |
|
|
47
|
+
| EUR | BHD | reference | 0.419914 |
|
|
48
|
+
| GBP | BHD | reference | 0.502012 |
|
|
49
|
+
| HKD | BHD | reference | 0.047936 |
|
|
50
|
+
| IDR | BHD | reference | 0.000021 |
|
|
51
|
+
| ILS | BHD | reference | 0.11838 |
|
|
52
|
+
| INR | BHD | reference | 0.004004 |
|
|
53
|
+
| JOD | BHD | reference | 0.531113 |
|
|
54
|
+
| JPY | BHD | reference | 0.002368 |
|
|
55
|
+
| KWD | BHD | reference | 1.208371 |
|
|
56
|
+
| LBP | BHD | reference | 0.000004 |
|
|
57
|
+
| LKR | BHD | reference | 0.001132 |
|
|
58
|
+
| MAD | BHD | reference | 0.038433 |
|
|
59
|
+
| NOK | BHD | reference | 0.039556 |
|
|
60
|
+
| NPR | BHD | reference | 0.002493 |
|
|
61
|
+
| NZD | BHD | reference | 0.210812 |
|
|
62
|
+
| OMR | BHD | reference | 0.976796 |
|
|
63
|
+
| PHP | BHD | reference | 0.005958 |
|
|
64
|
+
| PKR | BHD | reference | 0.001358 |
|
|
65
|
+
| QAR | BHD | reference | 0.103166 |
|
|
66
|
+
| SAR | BHD | reference | 0.100203 |
|
|
67
|
+
| SGD | BHD | reference | 0.293458 |
|
|
68
|
+
| THB | BHD | reference | 0.011192 |
|
|
69
|
+
| TND | BHD | reference | 0.12511 |
|
|
70
|
+
| TRY | BHD | reference | 0.007487 |
|
|
71
|
+
| USD | BHD | reference | 0.376081 |
|
|
72
|
+
|
|
73
|
+
</details>
|
|
74
|
+
|
|
75
|
+
Source: [Official rates published by CBB, served by AllRatesToday](https://allratestoday.com/central-bank-rates-api/cbb/). Rates are as printed by the central bank; AllRatesToday is not affiliated with it.
|
|
35
76
|
<!-- daily-table:end -->
|
|
36
77
|
|
|
37
78
|
## ๐ฆ Installation
|
|
@@ -61,8 +102,8 @@ console.log(pair.rate, pair.rate_date); // the official Central Bank of Bahrain
|
|
|
61
102
|
|
|
62
103
|
## ๐ API reference
|
|
63
104
|
|
|
64
|
-
- [Latest pair rate](#latest-pair-rate) โ one pair from the latest
|
|
65
|
-
- [Full
|
|
105
|
+
- [Latest pair rate](#latest-pair-rate) โ one pair from the latest official table
|
|
106
|
+
- [Full official table](#full-official-table) โ everything the central bank printed, in one call
|
|
66
107
|
- [Table for a date](#table-for-a-date) โ the official table for an invoice or filing date
|
|
67
108
|
- [Daily time series](#daily-time-series) โ one pair across a date range
|
|
68
109
|
|
|
@@ -70,7 +111,7 @@ console.log(pair.rate, pair.rate_date); // the official Central Bank of Bahrain
|
|
|
70
111
|
|
|
71
112
|
### Latest pair rate
|
|
72
113
|
|
|
73
|
-
Free plan and up. Pairs the central bank does not print directly are resolved from its table and flagged (see *
|
|
114
|
+
Free plan and up. Pairs the central bank does not print directly are resolved from its table and flagged (see *Official vs derived rates* below).
|
|
74
115
|
|
|
75
116
|
```js
|
|
76
117
|
const pair = await getRate('USD', 'BHD', { apiKey: 'art_live_...' });
|
|
@@ -82,7 +123,7 @@ const pair = await getRate('USD', 'BHD', { apiKey: 'art_live_...' });
|
|
|
82
123
|
{
|
|
83
124
|
bank: 'cbb',
|
|
84
125
|
name: 'Central Bank of Bahrain',
|
|
85
|
-
rate_date: '2026-
|
|
126
|
+
rate_date: '2026-11-11', // Central Bank of Bahrain's own publication date
|
|
86
127
|
source: 'USD',
|
|
87
128
|
target: 'BHD',
|
|
88
129
|
rate: 0.376081,
|
|
@@ -93,7 +134,7 @@ const pair = await getRate('USD', 'BHD', { apiKey: 'art_live_...' });
|
|
|
93
134
|
}
|
|
94
135
|
```
|
|
95
136
|
|
|
96
|
-
### Full
|
|
137
|
+
### Full official table
|
|
97
138
|
|
|
98
139
|
Free plan and up. The complete table for the latest publication date.
|
|
99
140
|
|
|
@@ -110,10 +151,10 @@ console.log(table.rate_date, table.rates.length);
|
|
|
110
151
|
{
|
|
111
152
|
bank: 'cbb',
|
|
112
153
|
name: 'Central Bank of Bahrain',
|
|
113
|
-
rate_date: '2026-
|
|
154
|
+
rate_date: '2026-11-11',
|
|
114
155
|
rates: [
|
|
115
156
|
{ "base": "USD", "quote": "BHD", "type": "reference", "value": 0.376081 },
|
|
116
|
-
// โฆ the rest of the
|
|
157
|
+
// โฆ the rest of the official table (33 currencies vs BHD)
|
|
117
158
|
],
|
|
118
159
|
disclaimer: 'โฆ'
|
|
119
160
|
}
|
|
@@ -152,7 +193,7 @@ Paid plans. One resolved rate per publication date โ ready for charting, reval
|
|
|
152
193
|
import { getHistory } from 'cbb-exchange-rate';
|
|
153
194
|
|
|
154
195
|
const series = await getHistory(
|
|
155
|
-
{ source: 'USD', target: 'BHD', from: '2026-01-01', to: '2026-
|
|
196
|
+
{ source: 'USD', target: 'BHD', from: '2026-01-01', to: '2026-11-11' },
|
|
156
197
|
{ apiKey: 'art_live_...' }
|
|
157
198
|
);
|
|
158
199
|
```
|
|
@@ -165,11 +206,11 @@ const series = await getHistory(
|
|
|
165
206
|
source: 'USD',
|
|
166
207
|
target: 'BHD',
|
|
167
208
|
from: '2026-01-01',
|
|
168
|
-
to: '2026-
|
|
209
|
+
to: '2026-11-11',
|
|
169
210
|
count: 152,
|
|
170
211
|
rates: [
|
|
171
212
|
// one entry per publication date
|
|
172
|
-
{ date: '2026-
|
|
213
|
+
{ date: '2026-11-11', rate: 0.376081, rate_type: 'reference', derived: false, method: 'published' },
|
|
173
214
|
// โฆ
|
|
174
215
|
],
|
|
175
216
|
disclaimer: 'โฆ'
|
|
@@ -223,7 +264,7 @@ curl "https://allratestoday.com/api/v1/central-bank/cbb/latest?format=xml&api_ke
|
|
|
223
264
|
- Evaluating? Agents can self-issue a trial key with no signup: `POST https://allratestoday.com/api/agent/keys` (send `Content-Type: application/json`) returns a 100-call key valid 7 days that covers the free-plan methods (latest table, pairs); dated tables and history need a [paid plan](https://allratestoday.com/pricing/). The MCP servers expose it as `request_trial_key`
|
|
224
265
|
- Machine-readable site guide: [llms.txt](https://allratestoday.com/llms.txt) ยท [for-ai-agents](https://allratestoday.com/for-ai-agents/)
|
|
225
266
|
|
|
226
|
-
## โ๏ธ
|
|
267
|
+
## โ๏ธ Official vs derived rates
|
|
227
268
|
|
|
228
269
|
If Central Bank of Bahrain does not print a pair directly, the API resolves it from the central bank's own table and says so โ official and computed values are never confused:
|
|
229
270
|
|
|
@@ -273,21 +314,21 @@ getRate('USD', 'BHD', { apiKey: 'art_live_...' }).then((pair) => console.log(pai
|
|
|
273
314
|
|
|
274
315
|
## ๐ก Quota tips
|
|
275
316
|
|
|
276
|
-
- Rates change once per business day โ cache the
|
|
317
|
+
- Rates change once per business day โ cache the official table locally and a small monthly quota goes a long way.
|
|
277
318
|
- Every request counts toward your AllRatesToday quota, shared across all AllRatesToday endpoints on your key.
|
|
278
319
|
|
|
279
320
|
## ๐ Methods reference
|
|
280
321
|
|
|
281
322
|
| Method | Plan | Description |
|
|
282
323
|
| ------ | ---- | ----------- |
|
|
283
|
-
| `getRate(source, target, { apiKey })` | Free | Latest rate for one pair, resolved from the
|
|
284
|
-
| `getLatestRates({ apiKey })` | Free | The central bank's full latest
|
|
324
|
+
| `getRate(source, target, { apiKey })` | Free | Latest rate for one pair, resolved from the official table |
|
|
325
|
+
| `getLatestRates({ apiKey })` | Free | The central bank's full latest official table |
|
|
285
326
|
| `getRatesForDate(date, { apiKey, source?, target? })` | Paid | The official table (or one pair) for a YYYY-MM-DD date |
|
|
286
327
|
| `getHistory({ symbol \| source+target, from?, to? }, { apiKey })` | Paid | Daily series since 2016 |
|
|
287
328
|
|
|
288
329
|
## ๐ฅ Bulk data (no key)
|
|
289
330
|
|
|
290
|
-
Need the whole archive rather than an API call? The same
|
|
331
|
+
Need the whole archive rather than an API call? The same official tables are mirrored daily as open data:
|
|
291
332
|
|
|
292
333
|
- Hugging Face: [AllRatesToday/central-bank-exchange-rates](https://huggingface.co/datasets/AllRatesToday/central-bank-exchange-rates) โ one CSV per institution (`rates/cbb.csv`)
|
|
293
334
|
- Kaggle: [allratestoday/central-bank-exchange-rates](https://www.kaggle.com/datasets/allratestoday/central-bank-exchange-rates)
|
|
@@ -297,7 +338,7 @@ Need the whole archive rather than an API call? The same published tables are mi
|
|
|
297
338
|
|
|
298
339
|
- **Website:** [allratestoday.com](https://allratestoday.com)
|
|
299
340
|
- [Central Bank of Bahrain rates page](https://allratestoday.com/central-bank-rates-api/cbb/) โ live table, publication cadence, FAQ
|
|
300
|
-
- [All central bank sources](https://allratestoday.com/central-bank-rates-api/)
|
|
341
|
+
- [All central bank sources](https://allratestoday.com/central-bank-rates-api/) ยท [Full list of 130+ central banks and tax authorities](https://allratestoday.com/central-bank-rates-api/institutions/) โ one API, the same response shape for every source
|
|
301
342
|
- [Download central bank rates](https://allratestoday.com/download-central-bank-rates/) โ every bank's latest table and history as Excel, CSV or JSON
|
|
302
343
|
- [Package docs on the site](https://allratestoday.com/docs/sdk/cbb-exchange-rate/) ยท [ERP integration guides](https://allratestoday.com/docs/integrations/)
|
|
303
344
|
- [API documentation](https://allratestoday.com/docs/#central-bank) ยท [Interactive reference](https://allratestoday.com/api-reference/) ยท [Methodology](https://allratestoday.com/official-rates-methodology/)
|
|
@@ -305,6 +346,7 @@ Need the whole archive rather than an API call? The same published tables are mi
|
|
|
305
346
|
- [Status](https://allratestoday.com/status)
|
|
306
347
|
- [Postman collection](https://allratestoday.com/postman/)
|
|
307
348
|
- [ChatGPT app](https://chatgpt.com/plugins/plugin_asdk_app_6ae1e76098f48191a285ac3f5ab7a83b) โ ask ChatGPT for live and official central bank rates
|
|
349
|
+
- [OpenAPI reference on Bump.sh](https://bump.sh/allratestoday/doc/allratestoday-api) โ also on [SwaggerHub](https://app.swaggerhub.com/apis-docs/allratestoday/allratestoday-exchange-rate-central-bank-rates-api/2.2.0)
|
|
308
350
|
- [GitHub](https://github.com/AllRates-Today/cbb-exchange-rate)
|
|
309
351
|
|
|
310
352
|
## ๐ License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cbb-exchange-rate",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.30",
|
|
4
4
|
"description": "Official Central Bank of Bahrain (Bahrain) daily exchange rates โ 33 currencies vs BHD, history since 2016. Zero-dependency Node.js/TypeScript client.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cbb",
|