@bitcoin-api-net/sdk 0.0.1

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 ADDED
@@ -0,0 +1,46 @@
1
+ # Bitcoin API TypeScript SDK
2
+
3
+ A lightweight, type-safe TypeScript SDK for the [Bitcoin API](https://bitcoin-api.net), built on top of `openapi-fetch`.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @bitcoin-api-net/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { createBitcoinClient } from '@bitcoin-api-net/sdk';
15
+
16
+ const client = createBitcoinClient({
17
+ apiKey: 'your-api-key-here',
18
+ // baseUrl: 'https://bitcoin-api.net' // Optional, defaults to production
19
+ });
20
+
21
+ // Example: Get current Bitcoin price
22
+ const { data, error } = await client.GET('/api/v1/prices/current', {
23
+ params: {
24
+ query: { symbol: 'btcusdt' }
25
+ }
26
+ });
27
+
28
+ if (data) {
29
+ console.log(`Current price: ${data.price}`);
30
+ }
31
+ ```
32
+
33
+ ## Features
34
+
35
+ - **Full Type Safety:** Automatically generated types from our OpenAPI schema.
36
+ - **Lightweight:** Tiny footprint with minimal dependencies.
37
+ - **Promise-based:** Modern API using async/await.
38
+ - **Customizable:** Easily override the base URL or add custom headers.
39
+
40
+ ## Documentation
41
+
42
+ For more detailed documentation, visit [bitcoin-api.net/docs](https://bitcoin-api.net/docs).
43
+
44
+ ## License
45
+
46
+ MIT
@@ -0,0 +1,9 @@
1
+ import type { paths } from './schema.js';
2
+ export type BitcoinApiClientOptions = {
3
+ baseUrl?: string;
4
+ apiKey?: string;
5
+ };
6
+ export declare function createBitcoinClient(options?: BitcoinApiClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
7
+ export type BitcoinApiClient = ReturnType<typeof createBitcoinClient>;
8
+ export * from './schema.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,uBAA4B,gEAexE;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import createClient from 'openapi-fetch';
2
+ export function createBitcoinClient(options = {}) {
3
+ const client = createClient({
4
+ baseUrl: options.baseUrl ?? 'https://bitcoin.net/',
5
+ });
6
+ if (options.apiKey) {
7
+ client.use({
8
+ onRequest({ request }) {
9
+ request.headers.set('Authorization', `Bearer ${options.apiKey}`);
10
+ return request;
11
+ },
12
+ });
13
+ }
14
+ return client;
15
+ }
16
+ export * from './schema.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAC;AAOzC,MAAM,UAAU,mBAAmB,CAAC,UAAmC,EAAE;IACvE,MAAM,MAAM,GAAG,YAAY,CAAQ;QACjC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,sBAAsB;KACnD,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,CAAC;YACT,SAAS,CAAC,EAAE,OAAO,EAAE;gBACnB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;gBACjE,OAAO,OAAO,CAAC;YACjB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAGD,cAAc,aAAa,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@bitcoin-api-net/sdk",
3
+ "version": "0.0.1",
4
+ "description": "Bitcoin API TypeScript SDK",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "clean": "rm -rf dist",
21
+ "generate:types": "openapi-typescript ../../apps/api/files/openapi.json -o ./src/schema.d.ts",
22
+ "type-check": "tsc --noEmit"
23
+ },
24
+ "devDependencies": {
25
+ "openapi-typescript": "^7.13.0",
26
+ "typescript": "^5.9.3"
27
+ },
28
+ "dependencies": {
29
+ "openapi-fetch": "^0.17.0"
30
+ }
31
+ }