@allratestoday/bcstp-exchange-rate 1.3.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AllRatesToday (https://allratestoday.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,308 @@
1
+ # Banco Central de São Tomé e Príncipe Exchange Rates API — bcstp-exchange-rate
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@allratestoday%2Fbcstp-exchange-rate.svg)](https://www.npmjs.com/package/@allratestoday/bcstp-exchange-rate)
4
+ [![license](https://img.shields.io/npm/l/@allratestoday%2Fbcstp-exchange-rate.svg)](https://github.com/AllRates-Today/bcstp-exchange-rate/blob/main/LICENSE)
5
+ [![zero dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](https://www.npmjs.com/package/@allratestoday/bcstp-exchange-rate)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-types%20included-3178C6.svg)](https://www.typescriptlang.org/)
7
+
8
+ **Official Banco Central de São Tomé e Príncipe (São Tomé and Príncipe) 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 Banco Central de São Tomé e Príncipe itself prints, every business day.**
9
+
10
+ ## 🚀 Why this client?
11
+
12
+ - 🏛️ **Official published rates** — Banco Central de São Tomé e Príncipe's own table, with the publisher's own `rate_date` on every response
13
+ - 📅 **History back to 2026** — point-in-time tables and daily series for any past date
14
+ - 🔀 **Published vs derived, always flagged** — computed inverse/cross pairs carry `derived: true`, never mixed with official prints
15
+ - ⚡ **Zero dependencies** — pure ESM + CJS over global `fetch`; Node 18+, Bun, Deno, and edge runtimes
16
+ - 🔷 **Type-safe** — full TypeScript definitions shipped with the package
17
+ - 🧾 **Compliance-grade metadata** — `rate_type`, publication date, and source disclaimer on every response
18
+
19
+ > **Official rate, not mid-market:** every value here is a number Banco Central de São Tomé e Príncipe itself published, fixed once printed and carrying the central bank's own `rate_date` — what filings and audits require. Need the live interbank midpoint for pricing or display instead? Use the [mid-market API](https://allratestoday.com/docs/) or [`@allratestoday/sdk`](https://www.npmjs.com/package/@allratestoday/sdk). The two can diverge by several percent.
20
+
21
+ ## ⚡ Try it without a key
22
+
23
+ The latest Banco Central de São Tomé e Príncipe table is also served keyless, CORS-open and edge-cached, for evaluation, embeds and AI agents:
24
+
25
+ ```bash
26
+ curl "https://allratestoday.com/api/open/central-bank/bcstp?source=USD&target=STN"
27
+ ```
28
+
29
+ ```js
30
+ const r = await fetch('https://allratestoday.com/api/open/central-bank/bcstp').then((x) => x.json());
31
+ console.log(r.rate_date, r.rates.length); // the central bank's latest published table, no key
32
+ ```
33
+
34
+ The open endpoint serves the *latest* table only and asks for a visible attribution link. The client below uses the keyed API, which adds point-in-time tables, history, and CSV/XML/Excel output.
35
+
36
+ ## 🔑 Get your API key
37
+
38
+ 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.
39
+
40
+ ## 📦 Installation
41
+
42
+ ```bash
43
+ npm install @allratestoday/bcstp-exchange-rate
44
+ ```
45
+
46
+ ```bash
47
+ yarn add @allratestoday/bcstp-exchange-rate
48
+ ```
49
+
50
+ ```bash
51
+ pnpm add @allratestoday/bcstp-exchange-rate
52
+ ```
53
+
54
+ Requires Node 18+ (global `fetch`); also runs on Bun, Deno and edge runtimes. Scoped mirror of [`bcstp-exchange-rate`](https://www.npmjs.com/package/bcstp-exchange-rate) — same code, same versions.
55
+
56
+ ## 🏁 Quick start
57
+
58
+ ```js
59
+ import { getRate } from '@allratestoday/bcstp-exchange-rate';
60
+
61
+ const pair = await getRate('USD', 'STN', { apiKey: 'art_live_...' });
62
+ console.log(pair.rate, pair.rate_date); // the official Banco Central de São Tomé e Príncipe rate, on the central bank's own date
63
+ ```
64
+
65
+ ## 📚 API reference
66
+
67
+ - [Latest pair rate](#latest-pair-rate) — one pair from the latest published table
68
+ - [Full published table](#full-published-table) — everything the central bank printed, in one call
69
+ - [Table for a date](#table-for-a-date) — the official table for an invoice or filing date
70
+ - [Daily time series](#daily-time-series) — one pair across a date range
71
+
72
+ ---
73
+
74
+ ### Latest pair rate
75
+
76
+ Free plan and up. Pairs the central bank does not print directly are resolved from its table and flagged (see *Published vs derived rates* below).
77
+
78
+ ```js
79
+ const pair = await getRate('USD', 'STN', { apiKey: 'art_live_...' });
80
+ ```
81
+
82
+ **Response:**
83
+
84
+ ```javascript
85
+ {
86
+ bank: 'bcstp',
87
+ name: 'Banco Central de São Tomé e Príncipe',
88
+ rate_date: '2026-09-25', // Banco Central de São Tomé e Príncipe's own publication date
89
+ source: 'USD',
90
+ target: 'STN',
91
+ rate: 21.7153,
92
+ rate_type: 'middle',
93
+ derived: false,
94
+ method: 'published',
95
+ disclaimer: 'Official rates as published by the named central bank. On weekends/holidays the most recent published rate_date is returned.'
96
+ }
97
+ ```
98
+
99
+ ### Full published table
100
+
101
+ Free plan and up. The complete table for the latest publication date.
102
+
103
+ ```js
104
+ import { getLatestRates } from '@allratestoday/bcstp-exchange-rate';
105
+
106
+ const table = await getLatestRates({ apiKey: 'art_live_...' });
107
+ console.log(table.rate_date, table.rates.length);
108
+ ```
109
+
110
+ **Response:**
111
+
112
+ ```javascript
113
+ {
114
+ bank: 'bcstp',
115
+ name: 'Banco Central de São Tomé e Príncipe',
116
+ rate_date: '2026-09-25',
117
+ rates: [
118
+ { "base": "USD", "quote": "STN", "type": "buy", "value": 21.5536 },
119
+ { "base": "USD", "quote": "STN", "type": "sell", "value": 21.8769 },
120
+ { "base": "USD", "quote": "STN", "type": "middle", "value": 21.7153 },
121
+ // … the rest of the published table (14 currencies vs STN)
122
+ ],
123
+ disclaimer: '…'
124
+ }
125
+ ```
126
+
127
+ ### Table for a date
128
+
129
+ Paid plans. The official table for any date since 2026 — weekends and holidays return the most recent published date, flagged via `published_on_requested_date`, which is exactly the in-force rate a filing needs.
130
+
131
+ ```js
132
+ import { getRatesForDate } from '@allratestoday/bcstp-exchange-rate';
133
+
134
+ const day = await getRatesForDate('2026-06-30', { apiKey: 'art_live_...' });
135
+ // Optionally narrow to one pair:
136
+ const one = await getRatesForDate('2026-06-30', { apiKey: 'art_live_...', source: 'USD', target: 'STN' });
137
+ ```
138
+
139
+ **Response:**
140
+
141
+ ```javascript
142
+ {
143
+ bank: 'bcstp',
144
+ requested_date: '2026-06-30',
145
+ rate_date: '2026-06-30', // the date actually published
146
+ published_on_requested_date: true, // false when a weekend/holiday fell back
147
+ rates: [ /* the full table for that date */ ],
148
+ disclaimer: '…'
149
+ }
150
+ ```
151
+
152
+ ### Daily time series
153
+
154
+ Paid plans. One resolved rate per publication date — ready for charting, revaluation runs, or audit workpapers.
155
+
156
+ ```js
157
+ import { getHistory } from '@allratestoday/bcstp-exchange-rate';
158
+
159
+ const series = await getHistory(
160
+ { source: 'USD', target: 'STN', from: '2026-01-01', to: '2026-09-25' },
161
+ { apiKey: 'art_live_...' }
162
+ );
163
+ ```
164
+
165
+ **Response:**
166
+
167
+ ```javascript
168
+ {
169
+ bank: 'bcstp',
170
+ source: 'USD',
171
+ target: 'STN',
172
+ from: '2026-01-01',
173
+ to: '2026-09-25',
174
+ count: 152,
175
+ rates: [
176
+ // one entry per publication date
177
+ { date: '2026-09-25', rate: 21.7153, rate_type: 'middle', derived: false, method: 'published' },
178
+ // …
179
+ ],
180
+ disclaimer: '…'
181
+ }
182
+ ```
183
+
184
+ Pass `{ symbol: 'USD' }` instead of `source`/`target` to get the raw published rows for one currency (all rate types, no pair resolution).
185
+
186
+ ---
187
+
188
+ ## 🗺️ Currencies covered
189
+
190
+ Banco Central de São Tomé e Príncipe currently publishes rates covering **14 currencies** against the STN (as of the latest table):
191
+
192
+ 🇧🇷 `BRL` · 🇨🇦 `CAD` · 🇨🇭 `CHF` · 🇨🇳 `CNY` · 🇩🇰 `DKK` · 🇪🇺 `EUR` · 🇬🇧 `GBP` · 🇯🇵 `JPY` · 🇳🇴 `NOK` · 🇸🇪 `SEK` · 🇺🇸 `USD` · `XAF` · `XDR` · 🇿🇦 `ZAR`
193
+
194
+ ## 🏛️ Source
195
+
196
+ Banco Central de São Tomé e Príncipe publishes a daily exchange bulletin for the dobra (STN): buying, selling and mid rates for 14 currencies and the SDR. The dobra has been pegged to the euro at 24.5 since 2010, so the euro line is fixed and the dollar, pound, yen, CFA franc, real and the rest move with the euro's crosses. The bulletin is the official rate for customs and tax purposes in São Tomé; the bank publishes the table in force only, so our archive builds forward from September 2026.
197
+
198
+ - Publisher's own page: [Boletim de Câmbio](https://www.bcstp.st/Cambio) · [www.bcstp.st](https://www.bcstp.st)
199
+ - Publication: every business day; the exact schedule, freshness status and any current delay are on the [Banco Central de São Tomé e Príncipe rates page](https://allratestoday.com/central-bank-rates-api/bcstp/)
200
+ - Values are stored unmodified, with the publisher's own `rate_date` on every row — see the [methodology](https://allratestoday.com/official-rates-methodology/)
201
+
202
+ ## 🧭 Reading the numbers
203
+
204
+ - `value` is always **quote currency per 1 unit of base currency** (`base: "EUR", quote: "USD", value: 1.15` means 1 EUR = 1.15 USD).
205
+ - Banco Central de São Tomé e Príncipe quotes **STN per 1 unit of foreign currency** (e.g. `base: "USD", quote: "STN"` means STN per one US dollar).
206
+ - Need the other way round? Ask `getRate(target, source)` and the API inverts or crosses for you, flagged `derived: true` — never divide a published rate yourself in a compliance workflow.
207
+ - `rate_type` tells you which of the central bank's series a row belongs to (`middle` here); some publishers print buy/sell or several fixings for the same pair.
208
+
209
+ ## 🧩 ERP & accounting systems
210
+
211
+ Loading the official Banco Central de São Tomé e Príncipe rate into an accounting system is a supported workflow, not a hack. Step-by-step guides with the direction each system expects:
212
+
213
+ - [Dynamics 365 Business Central](https://allratestoday.com/docs/integrations/business-central/) — built-in Currency Exchange Rate Service, no code
214
+ - [Xero](https://allratestoday.com/docs/integrations/xero/) · [QuickBooks Online](https://allratestoday.com/docs/integrations/quickbooks/) · [SAP S/4HANA and ECC](https://allratestoday.com/docs/integrations/sap/) · [Odoo](https://allratestoday.com/docs/integrations/odoo/)
215
+
216
+ The same keyed endpoints return `?format=csv`, `?format=xml` and `?format=xlsx`, and accept the key as `?api_key=` on the URL for importers that cannot send headers:
217
+
218
+ ```bash
219
+ curl "https://allratestoday.com/api/v1/central-bank/bcstp/latest?format=xml&api_key=art_live_..."
220
+ ```
221
+
222
+ ## 🤖 AI agents
223
+
224
+ - MCP server: `npx -y @allratestoday/central-bank-mcp` (stdio) or the hosted endpoint `https://allratestoday.com/api/mcp` — tools for official rates, history, cross-bank comparison and publication calendars
225
+ - Machine-readable site guide: [llms.txt](https://allratestoday.com/llms.txt) · [for-ai-agents](https://allratestoday.com/for-ai-agents/)
226
+
227
+ ## ⚖️ Published vs derived rates
228
+
229
+ If Banco Central de São Tomé e Príncipe 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:
230
+
231
+ | `method` | `derived` | Meaning |
232
+ | --- | --- | --- |
233
+ | `published` | `false` | The central bank printed this pair directly |
234
+ | `inverse` | `true` | Computed as 1 ÷ the published opposite direction |
235
+ | `cross` | `true` | Computed via STN from two published rates |
236
+
237
+ ## 🛡️ Error handling
238
+
239
+ Errors are thrown as `Error` with `status` (HTTP code) and `body` (the API's JSON error) attached:
240
+
241
+ ```js
242
+ try {
243
+ const pair = await getRate('USD', 'XXX', { apiKey: 'art_live_...' });
244
+ } catch (err) {
245
+ console.log(err.message); // human-readable reason
246
+ console.log(err.status); // e.g. 404
247
+ }
248
+ ```
249
+
250
+ | Status | Meaning |
251
+ | ------ | ------- |
252
+ | — | Missing `apiKey` (thrown before any request) |
253
+ | `400` | Malformed date or parameters |
254
+ | `401` | Invalid API key |
255
+ | `403` | Endpoint needs a [paid plan](https://allratestoday.com/pricing/) (historical dates & series) |
256
+ | `404` | Pair or date range not covered by Banco Central de São Tomé e Príncipe |
257
+ | `429` | Monthly quota exceeded |
258
+
259
+ ## 🔷 TypeScript
260
+
261
+ Full definitions ship with the package — no `@types` install:
262
+
263
+ ```ts
264
+ import type { LatestRates, PairRate, DatedRates, RateEntry, HistoryQuery, RequestOptions } from '@allratestoday/bcstp-exchange-rate';
265
+ ```
266
+
267
+ ## 📦 CommonJS
268
+
269
+ ```javascript
270
+ const { getRate } = require('@allratestoday/bcstp-exchange-rate');
271
+
272
+ getRate('USD', 'STN', { apiKey: 'art_live_...' }).then((pair) => console.log(pair.rate));
273
+ ```
274
+
275
+ ## 💡 Quota tips
276
+
277
+ - Rates change once per business day — cache the published table locally and a small monthly quota goes a long way.
278
+ - Every request counts toward your AllRatesToday quota, shared across all AllRatesToday endpoints on your key.
279
+
280
+ ## 📖 Methods reference
281
+
282
+ | Method | Plan | Description |
283
+ | ------ | ---- | ----------- |
284
+ | `getRate(source, target, { apiKey })` | Free | Latest rate for one pair, resolved from the published table |
285
+ | `getLatestRates({ apiKey })` | Free | The central bank's full latest published table |
286
+ | `getRatesForDate(date, { apiKey, source?, target? })` | Paid | The official table (or one pair) for a YYYY-MM-DD date |
287
+ | `getHistory({ symbol \| source+target, from?, to? }, { apiKey })` | Paid | Daily series since 2026 |
288
+
289
+ ## 📥 Bulk data (no key)
290
+
291
+ Need the whole archive rather than an API call? The same published tables are mirrored daily as open data:
292
+
293
+ - Hugging Face: [AllRates/central-bank-exchange-rates](https://huggingface.co/datasets/AllRates/central-bank-exchange-rates) — one CSV per institution (`rates/bcstp.csv`)
294
+ - Kaggle: [allratestoday/central-bank-exchange-rates](https://www.kaggle.com/datasets/allratestoday/central-bank-exchange-rates)
295
+ - CDN JSON: `https://cdn.jsdelivr.net/gh/AllRates-Today/central-bank-exchange-rates@main/data/bcstp/latest.json`
296
+
297
+ ## 🔗 Links
298
+
299
+ - [Banco Central de São Tomé e Príncipe rates page](https://allratestoday.com/central-bank-rates-api/bcstp/) — live table, publication cadence, FAQ
300
+ - [All central bank sources](https://allratestoday.com/central-bank-rates-api/)
301
+ - [Package docs on the site](https://allratestoday.com/docs/sdk/bcstp-exchange-rate/) · [ERP integration guides](https://allratestoday.com/docs/integrations/)
302
+ - [API documentation](https://allratestoday.com/docs/#central-bank) · [Interactive reference](https://allratestoday.com/api-reference/) · [Methodology](https://allratestoday.com/official-rates-methodology/)
303
+ - [Register (free)](https://allratestoday.com/register) · [Pricing](https://allratestoday.com/pricing/)
304
+ - [GitHub](https://github.com/AllRates-Today/bcstp-exchange-rate)
305
+
306
+ ## 📜 License
307
+
308
+ MIT
package/index.cjs ADDED
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+ // Banco Central de São Tomé e Príncipe exchange rates via the AllRatesToday API.
3
+ const BASE = 'https://allratestoday.com/api/v1/central-bank/bcstp';
4
+ const KEY_HINT = 'An apiKey is required — get a free key at https://allratestoday.com/register (no credit card required).';
5
+
6
+ async function request(path, params, options) {
7
+ const apiKey = options && options.apiKey;
8
+ if (!apiKey) throw new Error(KEY_HINT);
9
+ const url = new URL(BASE + path);
10
+ for (const [k, v] of Object.entries(params || {})) {
11
+ if (v !== undefined && v !== null) url.searchParams.set(k, v);
12
+ }
13
+ const res = await fetch(url, { headers: { Authorization: 'Bearer ' + apiKey } });
14
+ let body;
15
+ try { body = await res.json(); } catch { body = {}; }
16
+ if (!res.ok) {
17
+ const err = new Error(body.error || ('Request failed: HTTP ' + res.status));
18
+ err.status = res.status;
19
+ err.body = body;
20
+ throw err;
21
+ }
22
+ return body;
23
+ }
24
+
25
+ /** Latest published table (all plans, including free). */
26
+ async function getLatestRates(options) {
27
+ return request('/latest', {}, options);
28
+ }
29
+
30
+ /** Latest rate for one pair, e.g. getRate('USD', 'STN', { apiKey }). */
31
+ async function getRate(source, target, options) {
32
+ return request('/latest', { source, target }, options);
33
+ }
34
+
35
+ /** Published table for a date (YYYY-MM-DD). Paid plans. Weekends/holidays return the most recent published date. */
36
+ async function getRatesForDate(date, options) {
37
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(String(date))) throw new Error('date must be YYYY-MM-DD');
38
+ return request('/' + date, options && options.source ? { source: options.source, target: options.target } : {}, options);
39
+ }
40
+
41
+ /** Daily time series. Pass { symbol } or { source, target }, optional from/to (YYYY-MM-DD). Paid plans. */
42
+ async function getHistory(query, options) {
43
+ const { symbol, source, target, from, to } = query || {};
44
+ return request('/history', { symbol, source, target, from, to }, options);
45
+ }
46
+
47
+ module.exports = { getLatestRates, getRate, getRatesForDate, getHistory };
package/index.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ export interface RequestOptions {
2
+ /** AllRatesToday API key — free at https://allratestoday.com/register */
3
+ apiKey: string;
4
+ }
5
+
6
+ export interface RateEntry {
7
+ base: string;
8
+ quote: string;
9
+ type: string;
10
+ value: number;
11
+ }
12
+
13
+ export interface LatestRates {
14
+ bank: 'bcstp';
15
+ name: string;
16
+ rate_date: string;
17
+ rates: RateEntry[];
18
+ disclaimer: string;
19
+ }
20
+
21
+ export interface PairRate {
22
+ bank: 'bcstp';
23
+ name: string;
24
+ rate_date: string;
25
+ source: string;
26
+ target: string;
27
+ rate: number;
28
+ rate_type: string;
29
+ /** true when the pair was computed (inverse/cross) rather than published directly */
30
+ derived: boolean;
31
+ method: 'published' | 'inverse' | 'cross';
32
+ disclaimer: string;
33
+ }
34
+
35
+ export interface DatedRates extends Omit<LatestRates, 'rate_date'> {
36
+ requested_date: string;
37
+ rate_date: string;
38
+ published_on_requested_date: boolean;
39
+ }
40
+
41
+ export interface HistoryQuery {
42
+ symbol?: string;
43
+ source?: string;
44
+ target?: string;
45
+ from?: string;
46
+ to?: string;
47
+ }
48
+
49
+ export declare function getLatestRates(options: RequestOptions): Promise<LatestRates>;
50
+ export declare function getRate(source: string, target: string, options: RequestOptions): Promise<PairRate>;
51
+ export declare function getRatesForDate(date: string, options: RequestOptions & { source?: string; target?: string }): Promise<DatedRates>;
52
+ export declare function getHistory(query: HistoryQuery, options: RequestOptions): Promise<unknown>;
package/index.mjs ADDED
@@ -0,0 +1,44 @@
1
+ // Banco Central de São Tomé e Príncipe exchange rates via the AllRatesToday API.
2
+ const BASE = 'https://allratestoday.com/api/v1/central-bank/bcstp';
3
+ const KEY_HINT = 'An apiKey is required — get a free key at https://allratestoday.com/register (no credit card required).';
4
+
5
+ async function request(path, params, options) {
6
+ const apiKey = options && options.apiKey;
7
+ if (!apiKey) throw new Error(KEY_HINT);
8
+ const url = new URL(BASE + path);
9
+ for (const [k, v] of Object.entries(params || {})) {
10
+ if (v !== undefined && v !== null) url.searchParams.set(k, v);
11
+ }
12
+ const res = await fetch(url, { headers: { Authorization: 'Bearer ' + apiKey } });
13
+ let body;
14
+ try { body = await res.json(); } catch { body = {}; }
15
+ if (!res.ok) {
16
+ const err = new Error(body.error || ('Request failed: HTTP ' + res.status));
17
+ err.status = res.status;
18
+ err.body = body;
19
+ throw err;
20
+ }
21
+ return body;
22
+ }
23
+
24
+ /** Latest published table (all plans, including free). */
25
+ export async function getLatestRates(options) {
26
+ return request('/latest', {}, options);
27
+ }
28
+
29
+ /** Latest rate for one pair, e.g. getRate('USD', 'STN', { apiKey }). */
30
+ export async function getRate(source, target, options) {
31
+ return request('/latest', { source, target }, options);
32
+ }
33
+
34
+ /** Published table for a date (YYYY-MM-DD). Paid plans. Weekends/holidays return the most recent published date. */
35
+ export async function getRatesForDate(date, options) {
36
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(String(date))) throw new Error('date must be YYYY-MM-DD');
37
+ return request('/' + date, options && options.source ? { source: options.source, target: options.target } : {}, options);
38
+ }
39
+
40
+ /** Daily time series. Pass { symbol } or { source, target }, optional from/to (YYYY-MM-DD). Paid plans. */
41
+ export async function getHistory(query, options) {
42
+ const { symbol, source, target, from, to } = query || {};
43
+ return request('/history', { symbol, source, target, from, to }, options);
44
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@allratestoday/bcstp-exchange-rate",
3
+ "version": "1.3.2",
4
+ "description": "Official Banco Central de São Tomé e Príncipe (São Tomé and Príncipe) daily exchange rates — 14 currencies vs STN, history since 2026. Zero-dependency Node.js/TypeScript client.",
5
+ "keywords": [
6
+ "bcstp",
7
+ "banco",
8
+ "central",
9
+ "de",
10
+ "são",
11
+ "tomé",
12
+ "e",
13
+ "príncipe",
14
+ "exchange-rate",
15
+ "exchange-rates",
16
+ "currency",
17
+ "forex",
18
+ "fx",
19
+ "stn",
20
+ "central-bank",
21
+ "official-rates",
22
+ "são-tomé-and-príncipe",
23
+ "api",
24
+ "typescript"
25
+ ],
26
+ "homepage": "https://allratestoday.com/central-bank-rates-api/bcstp/",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/AllRates-Today/bcstp-exchange-rate.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/AllRates-Today/bcstp-exchange-rate/issues"
33
+ },
34
+ "license": "MIT",
35
+ "author": "AllRatesToday <hello@allratestoday.com> (https://allratestoday.com)",
36
+ "type": "module",
37
+ "main": "./index.cjs",
38
+ "module": "./index.mjs",
39
+ "types": "./index.d.ts",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./index.d.ts",
43
+ "import": "./index.mjs",
44
+ "require": "./index.cjs"
45
+ }
46
+ },
47
+ "files": [
48
+ "index.mjs",
49
+ "index.cjs",
50
+ "index.d.ts",
51
+ "README.md",
52
+ "LICENSE"
53
+ ],
54
+ "engines": {
55
+ "node": ">=18"
56
+ },
57
+ "sideEffects": false
58
+ }