radarbg 0.0.0-stage → 0.1.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/LICENSE +5 -0
- package/README.md +10 -2
- package/index.js +15 -0
- package/package.json +8 -4
package/LICENSE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# radarbg
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Tiny Node client (no dependencies, Node 18+) for the [Radar APIs](https://radarbg.com/apis?ref=npm): IBAN, EU VAT via VIES, HS codes, SEPA XML, sanctions screening, geocoding, bank statements, PDF and 130+ more. No key: 3 calls/day per IP; free key: 100 calls/month (`POST https://radarbg.com/v1/signup`); paid plans from EUR 15/mo.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
const { Client } = require("radarbg");
|
|
7
|
+
const r = await new Client().call("iban-validator", { iban: "DE89 3704 0044 0532 0130 00" });
|
|
8
|
+
console.log(r.items[0].valid, r.items[0].bankName);
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Docs: https://radarbg.com/docs?ref=npm
|
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// radarbg - tiny client for Radar APIs (https://radarbg.com/?ref=npm). No key: 25 calls/day per IP.
|
|
2
|
+
const BASE = "https://radarbg.com";
|
|
3
|
+
class RadarError extends Error { constructor(status, body) { super(`HTTP ${status}: ${(body && (body.error || body.message)) || body}`); this.status = status; this.body = body; } }
|
|
4
|
+
class Client {
|
|
5
|
+
constructor({ apiKey = process.env.RADARBG_API_KEY, base = BASE } = {}) { this.apiKey = apiKey; this.base = base.replace(/\/$/, ""); }
|
|
6
|
+
async call(api, params = {}) {
|
|
7
|
+
const h = { "Content-Type": "application/json", "User-Agent": "radarbg-js/0.1.0 (+https://radarbg.com/docs)" };
|
|
8
|
+
if (this.apiKey) h["X-API-Key"] = this.apiKey;
|
|
9
|
+
const r = await fetch(`${this.base}/v1/${api}`, { method: "POST", headers: h, body: JSON.stringify(params) });
|
|
10
|
+
const t = await r.text(); let b; try { b = JSON.parse(t); } catch { b = t; }
|
|
11
|
+
if (!r.ok) throw new RadarError(r.status, b);
|
|
12
|
+
return b;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
module.exports = { Client, RadarError, call: (api, p) => new Client().call(api, p) };
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "radarbg",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tiny client for Radar APIs: IBAN, EU VAT (VIES), SEPA XML, HS codes, sanctions, geocoding, bank statements and 130+ more. 3 free calls/day without a key, 100/month with a free key.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://radarbg.com/apis?ref=npm",
|
|
8
|
+
"keywords": ["iban", "vat", "vies", "sepa", "hs-code", "sanctions", "geocoding", "bank-statement", "e-invoice", "api"],
|
|
9
|
+
"engines": {"node": ">=18"}
|
|
10
|
+
}
|