satsterminal-sdk
Version:
A TypeScript SDK for interacting with the SatsTerminal ecosystem.
57 lines (56 loc) • 1.86 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SatsTerminal = void 0;
const node_fetch_1 = __importDefault(require("node-fetch"));
class SatsTerminal {
constructor(config) {
if (!config.apiKey) {
throw new Error('API key is required');
}
this.apiKey = config.apiKey;
this.baseUrl = config.baseUrl || 'https://api.satsterminal.com/v1';
}
async request(endpoint, data) {
const response = await (0, node_fetch_1.default)(`${this.baseUrl}${endpoint}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': this.apiKey,
},
body: JSON.stringify(data),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.message || 'Request failed');
}
return response.json();
}
async search(params) {
return this.request('/runes/search', params);
}
async popularCollections(params) {
return this.request('/runes/popular_collections', params);
}
async fetchQuote(params) {
return this.request('/tba/fetch-quote', params);
}
async getPSBT(params) {
return this.request('/tba/get-psbt', params);
}
async confirmPSBT(params) {
return this.request('/tba/confirm-psbt', params);
}
async signIn(params) {
return this.request('/user/sign-in', params);
}
async bind(params) {
return this.request('/user/bind', params);
}
async points(params) {
return this.request('/user/points', params);
}
}
exports.SatsTerminal = SatsTerminal;